diff --git a/.fern/metadata.json b/.fern/metadata.json index b6717147c..3f69c9919 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { "cliVersion": "5.37.7", "generatorName": "fernapi/fern-python-sdk", - "generatorVersion": "5.14.1", + "generatorVersion": "5.14.4", "generatorConfig": { "inline_request_params": false, "extras": { @@ -94,10 +94,10 @@ } ] }, - "originGitCommit": "06c89ed3d92de0b191ec8eb5eb542753390b6c7f", + "originGitCommit": "6b200e3df80ccea85f9d69dc3c5572410454d8b7", "originGitCommitIsDirty": true, "invokedBy": "ci", - "requestedVersion": "7.0.0", + "requestedVersion": "7.0.1", "ciProvider": "github", - "sdkVersion": "7.0.0" + "sdkVersion": "7.0.1" } \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 01bf5ad81..cecbbbe7a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1032,17 +1032,18 @@ httpx = ">=0.27.0" [[package]] name = "huggingface-hub" -version = "1.16.1" +version = "1.17.0" description = "Client library to download and publish models, datasets and other repos on the huggingface.co hub" optional = false python-versions = ">=3.10.0" groups = ["main"] files = [ - {file = "huggingface_hub-1.16.1-py3-none-any.whl", hash = "sha256:64340de934b9ce37857ef85a82de72f5629e8a270f9119eabb12bf495eb53c22"}, - {file = "huggingface_hub-1.16.1.tar.gz", hash = "sha256:7f1dc4c5ec21aed69be630ad0c3378616be16f3de1a47b141c0e812965d9c832"}, + {file = "huggingface_hub-1.17.0-py3-none-any.whl", hash = "sha256:3b8156d23118e87f6a587648bfbc04f04a12a757ccb4ed298b35c4ae638bf24c"}, + {file = "huggingface_hub-1.17.0.tar.gz", hash = "sha256:fad842b6763ef70ebc3919665b1b9273645203185400a7d6c5eddc2323cc3435"}, ] [package.dependencies] +click = ">=8.4.0" filelock = ">=3.10.0" fsspec = ">=2023.5.0" hf-xet = {version = ">=1.4.3,<2.0.0", markers = "platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"arm64\" or platform_machine == \"aarch64\""} @@ -1050,7 +1051,7 @@ httpx = ">=0.23.0,<1" packaging = ">=20.9" pyyaml = ">=5.1" tqdm = ">=4.42.1" -typer = ">=0.20.0" +typer = ">=0.20.0,<0.26.0" typing-extensions = ">=4.1.0" [package.extras] @@ -1068,14 +1069,14 @@ typing = ["types-PyYAML", "types-simplejson", "types-toml", "types-tqdm", "types [[package]] name = "idna" -version = "3.16" +version = "3.17" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "idna-3.16-py3-none-any.whl", hash = "sha256:cc246e3a3f89580c3a951b5ad298ca4638078b2cdd4f115654332b5c26daded5"}, - {file = "idna-3.16.tar.gz", hash = "sha256:d7a6da03db833450fca25d2358ac9ff06cd624577a4aea3a596d5c0f77b8e03d"}, + {file = "idna-3.17-py3-none-any.whl", hash = "sha256:466e48829084efe2548012b855df21540b96f2e20e51bd124c851536556a592c"}, + {file = "idna-3.17.tar.gz", hash = "sha256:5eb0cb53bc467c12eadcf6de83163ad8527cec9416f44b9b61b19caedad2b87f"}, ] [package.extras] @@ -1357,15 +1358,15 @@ files = [ [[package]] name = "oci" -version = "2.175.0" +version = "2.176.0" description = "Oracle Cloud Infrastructure Python SDK" optional = true python-versions = "*" groups = ["main"] markers = "extra == \"oci\"" files = [ - {file = "oci-2.175.0-py3-none-any.whl", hash = "sha256:a63c002aa1e3f4c7e26f394f6ea8cc988627aa7634cc30c284e9dd23e542711a"}, - {file = "oci-2.175.0.tar.gz", hash = "sha256:a2c0f7a61e26a430cb5d2f611226eca6ee49f113ba6326ca97c8608be54f168c"}, + {file = "oci-2.176.0-py3-none-any.whl", hash = "sha256:242144cda6f938af431f5a462299e2073100d6f293b02b31466245d47cb4ae76"}, + {file = "oci-2.176.0.tar.gz", hash = "sha256:ddf7d5734209e32c7a260e7f93e1e73d13409b8d2cf33d66392348a385714eb6"}, ] [package.dependencies] @@ -1770,23 +1771,23 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests [[package]] name = "pytest-asyncio" -version = "1.3.0" +version = "1.4.0" description = "Pytest support for asyncio" optional = false python-versions = ">=3.10" groups = ["dev"] files = [ - {file = "pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5"}, - {file = "pytest_asyncio-1.3.0.tar.gz", hash = "sha256:d7f52f36d231b80ee124cd216ffb19369aa168fc10095013c6b014a34d3ee9e5"}, + {file = "pytest_asyncio-1.4.0-py3-none-any.whl", hash = "sha256:933ca923a23075a87fb7070c0ec272a6848489824d887c85c812670932835aa1"}, + {file = "pytest_asyncio-1.4.0.tar.gz", hash = "sha256:c6c0d2259945122819f171a32ecea2c349ead889ee28176caaf492143424be42"}, ] [package.dependencies] backports-asyncio-runner = {version = ">=1.1,<2", markers = "python_version < \"3.11\""} -pytest = ">=8.2,<10" +pytest = ">=8.4,<10" typing-extensions = {version = ">=4.12", markers = "python_version < \"3.13\""} [package.extras] -docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1)"] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1)", "sphinx-tabs (>=3.5)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 0202faeed..28a78da98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ dynamic = ["version"] [tool.poetry] name = "cohere" -version = "7.0.0" +version = "7.0.1" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index e56a1809c..2d9434adf 100644 --- a/reference.md +++ b/reference.md @@ -1538,11 +1538,15 @@ client.embed( **images:** `typing.Optional[typing.List[str]]` -An array of image data URIs for the model to embed. Maximum number of images per call is `1`. +An array of image data URIs for the model to embed. -The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. +The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. -Images are only supported with Embed v3.0 and newer models. +Image embeddings are supported with Embed v3.0 and newer models. + +For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + +For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. @@ -2967,11 +2971,15 @@ client.v2.embed( **images:** `typing.Optional[typing.List[str]]` -An array of image data URIs for the model to embed. Maximum number of images per call is `1`. +An array of image data URIs for the model to embed. -The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. +The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. + +For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + +For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. diff --git a/src/cohere/base_client.py b/src/cohere/base_client.py index cc717fb80..1b3af8024 100644 --- a/src/cohere/base_client.py +++ b/src/cohere/base_client.py @@ -1082,11 +1082,15 @@ def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. - Images are only supported with Embed v3.0 and newer models. + Image embeddings are supported with Embed v3.0 and newer models. + + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. model : typing.Optional[str] ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed). @@ -2662,11 +2666,15 @@ async def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. + + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. + + Image embeddings are supported with Embed v3.0 and newer models. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. - Images are only supported with Embed v3.0 and newer models. + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. model : typing.Optional[str] ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed). diff --git a/src/cohere/core/client_wrapper.py b/src/cohere/core/client_wrapper.py index afb1bd9ed..d7d1ef431 100644 --- a/src/cohere/core/client_wrapper.py +++ b/src/cohere/core/client_wrapper.py @@ -31,12 +31,12 @@ def get_headers(self) -> typing.Dict[str, str]: import platform headers: typing.Dict[str, str] = { - "User-Agent": "cohere/7.0.0", + "User-Agent": "cohere/7.0.1", "X-Fern-Language": "Python", "X-Fern-Runtime": f"python/{platform.python_version()}", "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", "X-Fern-SDK-Name": "cohere", - "X-Fern-SDK-Version": "7.0.0", + "X-Fern-SDK-Version": "7.0.1", **(self.get_custom_headers() or {}), } if self._client_name is not None: diff --git a/src/cohere/core/pydantic_utilities.py b/src/cohere/core/pydantic_utilities.py index df3e720da..6587f5e18 100644 --- a/src/cohere/core/pydantic_utilities.py +++ b/src/cohere/core/pydantic_utilities.py @@ -135,111 +135,21 @@ def _decimal_encoder(dec_value: Any) -> Any: Model = TypeVar("Model", bound=pydantic.BaseModel) -def _get_discriminator_and_variants(type_: Type[Any]) -> Tuple[Optional[str], Optional[List[Type[Any]]]]: - """ - Extract the discriminator field name and union variants from a discriminated union type. - Supports Annotated[Union[...], Field(discriminator=...)] patterns. - Returns (discriminator, variants) or (None, None) if not a discriminated union. - """ - origin = typing_extensions.get_origin(type_) - - if origin is typing_extensions.Annotated: - args = typing_extensions.get_args(type_) - if len(args) >= 2: - inner_type = args[0] - # Check annotations for discriminator - discriminator = None - for annotation in args[1:]: - if hasattr(annotation, "discriminator"): - discriminator = getattr(annotation, "discriminator", None) - break - - if discriminator: - inner_origin = typing_extensions.get_origin(inner_type) - if inner_origin is Union: - variants = list(typing_extensions.get_args(inner_type)) - return discriminator, variants - return None, None - - -def _get_field_annotation(model: Type[Any], field_name: str) -> Optional[Type[Any]]: - """Get the type annotation of a field from a Pydantic model.""" - if IS_PYDANTIC_V2: - fields = getattr(model, "model_fields", {}) - field_info = fields.get(field_name) - if field_info: - return cast(Optional[Type[Any]], field_info.annotation) - else: - fields = getattr(model, "__fields__", {}) - field_info = fields.get(field_name) - if field_info: - return cast(Optional[Type[Any]], field_info.outer_type_) - return None - - -def _find_variant_by_discriminator( - variants: List[Type[Any]], - discriminator: str, - discriminator_value: Any, -) -> Optional[Type[Any]]: - """Find the union variant that matches the discriminator value.""" - for variant in variants: - if not (inspect.isclass(variant) and issubclass(variant, pydantic.BaseModel)): - continue - - disc_annotation = _get_field_annotation(variant, discriminator) - if disc_annotation and is_literal_type(disc_annotation): - literal_args = get_args(disc_annotation) - if literal_args and literal_args[0] == discriminator_value: - return variant - return None - - -def _is_string_type(type_: Type[Any]) -> bool: - """Check if a type is str or Optional[str].""" - if type_ is str: - return True - - origin = typing_extensions.get_origin(type_) - if origin is Union: - args = typing_extensions.get_args(type_) - # Optional[str] = Union[str, None] - non_none_args = [a for a in args if a is not type(None)] - if len(non_none_args) == 1 and non_none_args[0] is str: - return True - - return False - - def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T: """ Parse a ServerSentEvent into the appropriate type. - Handles two scenarios based on where the discriminator field is located: + This function handles data-level discrimination where the discriminator + (e.g., 'type') is inside the 'data' payload. It parses the SSE data field + as JSON and deserializes it into the target type. - 1. Data-level discrimination: The discriminator (e.g., 'type') is inside the 'data' payload. - The union describes the data content, not the SSE envelope. - -> Returns: json.loads(data) parsed into the type - - Example: ChatStreamResponse with discriminator='type' - Input: ServerSentEvent(event="message", data='{"type": "content-delta", ...}', id="") - Output: ContentDeltaEvent (parsed from data, SSE envelope stripped) - - 2. Event-level discrimination: The discriminator (e.g., 'event') is at the SSE event level. - The union describes the full SSE event structure. - -> Returns: SSE envelope with 'data' field JSON-parsed only if the variant expects non-string - - Example: JobStreamResponse with discriminator='event' - Input: ServerSentEvent(event="ERROR", data='{"code": "FAILED", ...}', id="123") - Output: JobStreamResponse_Error with data as ErrorData object - - But for variants where data is str (like STATUS_UPDATE): - Input: ServerSentEvent(event="STATUS_UPDATE", data='{"status": "processing"}', id="1") - Output: JobStreamResponse_StatusUpdate with data as string (not parsed) + Note: Protocol-level discrimination (where the discriminator comes from + the SSE event: field) is handled at code-generation time and does not + use this function. Args: sse: The ServerSentEvent object to parse - type_: The target discriminated union type + type_: The target type to deserialize into Returns: The parsed object of type T @@ -248,66 +158,18 @@ def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T: This function is only available in SDK contexts where http_sse module exists. """ sse_event = asdict(sse) - discriminator, variants = _get_discriminator_and_variants(type_) - - if discriminator is None or variants is None: - # Not a discriminated union - parse the data field as JSON - data_value = sse_event.get("data") - if isinstance(data_value, str) and data_value: - try: - parsed_data = json.loads(data_value) - return parse_obj_as(type_, parsed_data) - except json.JSONDecodeError as e: - _logger.warning( - "Failed to parse SSE data field as JSON: %s, data: %s", - e, - data_value[:100] if len(data_value) > 100 else data_value, - ) - return parse_obj_as(type_, sse_event) - data_value = sse_event.get("data") - - # Check if discriminator is at the top level (event-level discrimination) - if discriminator in sse_event: - # Case 2: Event-level discrimination - # Find the matching variant to check if 'data' field needs JSON parsing - disc_value = sse_event.get(discriminator) - matching_variant = _find_variant_by_discriminator(variants, discriminator, disc_value) - - if matching_variant is not None: - # Check what type the variant expects for 'data' - data_type = _get_field_annotation(matching_variant, "data") - if data_type is not None and not _is_string_type(data_type): - # Variant expects non-string data - parse JSON - if isinstance(data_value, str) and data_value: - try: - parsed_data = json.loads(data_value) - new_object = dict(sse_event) - new_object["data"] = parsed_data - return parse_obj_as(type_, new_object) - except json.JSONDecodeError as e: - _logger.warning( - "Failed to parse SSE data field as JSON for event-level discrimination: %s, data: %s", - e, - data_value[:100] if len(data_value) > 100 else data_value, - ) - # Either no matching variant, data is string type, or JSON parse failed - return parse_obj_as(type_, sse_event) - - else: - # Case 1: Data-level discrimination - # The discriminator is inside the data payload - extract and parse data only - if isinstance(data_value, str) and data_value: - try: - parsed_data = json.loads(data_value) - return parse_obj_as(type_, parsed_data) - except json.JSONDecodeError as e: - _logger.warning( - "Failed to parse SSE data field as JSON for data-level discrimination: %s, data: %s", - e, - data_value[:100] if len(data_value) > 100 else data_value, - ) - return parse_obj_as(type_, sse_event) + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + return parse_obj_as(type_, parsed_data) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + return parse_obj_as(type_, sse_event) _type_adapter_cache: Dict[int, Any] = {} diff --git a/src/cohere/raw_base_client.py b/src/cohere/raw_base_client.py index db525c987..40b814c21 100644 --- a/src/cohere/raw_base_client.py +++ b/src/cohere/raw_base_client.py @@ -1627,11 +1627,15 @@ def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. - Images are only supported with Embed v3.0 and newer models. + Image embeddings are supported with Embed v3.0 and newer models. + + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. model : typing.Optional[str] ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed). @@ -4590,11 +4594,15 @@ async def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. + + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. + + Image embeddings are supported with Embed v3.0 and newer models. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. - Images are only supported with Embed v3.0 and newer models. + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. model : typing.Optional[str] ID of one of the available [Embedding models](https://docs.cohere.com/docs/cohere-embed). diff --git a/src/cohere/v2/client.py b/src/cohere/v2/client.py index 489ec3093..5ca28c84c 100644 --- a/src/cohere/v2/client.py +++ b/src/cohere/v2/client.py @@ -415,12 +415,16 @@ def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. + inputs : typing.Optional[typing.Sequence[EmbedInput]] An array of inputs for the model to embed. Maximum number of inputs per call is `96`. An input can contain a mix of text and image components. @@ -972,12 +976,16 @@ async def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. + inputs : typing.Optional[typing.Sequence[EmbedInput]] An array of inputs for the model to embed. Maximum number of inputs per call is `96`. An input can contain a mix of text and image components. diff --git a/src/cohere/v2/raw_client.py b/src/cohere/v2/raw_client.py index e72a08674..9575a8b0a 100644 --- a/src/cohere/v2/raw_client.py +++ b/src/cohere/v2/raw_client.py @@ -760,12 +760,16 @@ def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. + inputs : typing.Optional[typing.Sequence[EmbedInput]] An array of inputs for the model to embed. Maximum number of inputs per call is `96`. An input can contain a mix of text and image components. @@ -1903,12 +1907,16 @@ async def embed( An array of strings for the model to embed. Maximum number of texts per call is `96`. images : typing.Optional[typing.Sequence[str]] - An array of image data URIs for the model to embed. Maximum number of images per call is `1`. + An array of image data URIs for the model to embed. - The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format and has a maximum size of 5MB. + The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg`, `image/png`, `image/webp`, or `image/gif` format. Image embeddings are supported with Embed v3.0 and newer models. + For **Embed v3.x** models, the maximum number of images per call is `1`, and each image has a maximum size of `5MB`. + + For **Embed v4.0 and newer** models, there is no limit on the number of images per call. The combined size of all images in the request must be at most `20MB`. + inputs : typing.Optional[typing.Sequence[EmbedInput]] An array of inputs for the model to embed. Maximum number of inputs per call is `96`. An input can contain a mix of text and image components.