Implementation:Cohere ai Cohere python EmbedByTypeResponse Model
| Knowledge Sources | |
|---|---|
| Domains | SDK, Embeddings |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
EmbedByTypeResponse is a Pydantic model representing the Cohere Embed API response when embeddings are returned in multiple numeric formats (float, int8, uint8, binary, ubinary, base64).
Description
The EmbedByTypeResponse class encapsulates the response from the Cohere Embed API when the embedding_types parameter is used to request embeddings in specific numeric formats. Instead of returning a flat list of float arrays, this response wraps an EmbedByTypeResponseEmbeddings object that contains separate arrays for each requested embedding type.
The response includes the unique request id, the embeddings object organized by type, the original texts that were embedded, any images that were embedded, optional response_type metadata, and an ApiMeta object with API usage information such as token counts and warnings.
The class extends UncheckedBaseModel and is auto-generated by the Fern API definition toolchain. It supports both Pydantic v1 and v2 through a compatibility layer.
Usage
Use EmbedByTypeResponse when calling the Embed API with the embedding_types parameter to receive embeddings in multiple numeric formats simultaneously. This is useful for applications that need quantized embeddings for efficient storage or specific numeric precision requirements.
Code Reference
Source Location
- Repository: Cohere Python SDK
- File:
src/cohere/types/embed_by_type_response.py
Signature
class EmbedByTypeResponse(UncheckedBaseModel):
response_type: typing.Optional[EmbedByTypeResponseResponseType] = None
id: str
embeddings: EmbedByTypeResponseEmbeddings
texts: typing.Optional[typing.List[str]] = None
images: typing.Optional[typing.List[Image]] = None
meta: typing.Optional[ApiMeta] = None
Import
from cohere.types import EmbedByTypeResponse
I/O Contract
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
response_type |
Optional[EmbedByTypeResponseResponseType] |
No | None |
The response type indicator |
id |
str |
Yes | -- | Unique identifier for this embed request |
embeddings |
EmbedByTypeResponseEmbeddings |
Yes | -- | An object with different embedding types; array lengths match the original input length |
texts |
Optional[List[str]] |
No | None |
The text entries for which embeddings were returned |
images |
Optional[List[Image]] |
No | None |
The image entries for which embeddings were returned |
meta |
Optional[ApiMeta] |
No | None |
API metadata including token counts and warnings |
Usage Examples
Accessing Typed Embeddings
import cohere
co = cohere.Client()
response = co.embed(
texts=["Hello world", "Cohere embeddings"],
model="embed-english-v3.0",
input_type="search_document",
embedding_types=["float", "int8", "uint8"],
)
# response is an EmbedByTypeResponse
print(response.id)
# Access float embeddings
if response.embeddings.float_:
for embedding in response.embeddings.float_:
print(f"Float embedding dimension: {len(embedding)}")
# Access int8 embeddings
if response.embeddings.int8:
for embedding in response.embeddings.int8:
print(f"Int8 embedding dimension: {len(embedding)}")
# Access the original texts
if response.texts:
print(f"Embedded texts: {response.texts}")
Checking API Metadata
import cohere
co = cohere.Client()
response = co.embed(
texts=["Sample text for embedding"],
model="embed-english-v3.0",
input_type="search_query",
embedding_types=["float"],
)
if response.meta:
print(f"API metadata: {response.meta}")