Implementation:Cohere ai Cohere python EmbedFloatsResponse Model
| Knowledge Sources | |
|---|---|
| Domains | SDK, Embeddings |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
EmbedFloatsResponse is a Pydantic model representing the Cohere Embed API response containing embeddings exclusively as arrays of floats.
Description
The EmbedFloatsResponse class encapsulates the response from the Cohere Embed API when embeddings are returned in the default float-only format. Unlike EmbedByTypeResponse which supports multiple numeric formats, this response contains a single embeddings field as a nested list of floats (List[List[float]]).
The response includes:
- id: A unique identifier for the embed request
- embeddings: The embedding vectors as a list of float arrays, where each inner list corresponds to one input text or image
- texts: The original text entries that were embedded
- images: The image entries that were embedded (if any)
- meta: Optional API metadata including token counts and warnings
The length of the embeddings array matches the number of input texts provided. The class extends UncheckedBaseModel and is auto-generated by the Fern API definition toolchain.
Usage
Use EmbedFloatsResponse when working with the default float embedding response from the Cohere Embed API. This is the standard response type when no specific embedding_types parameter is provided or when only float embeddings are needed.
Code Reference
Source Location
- Repository: Cohere Python SDK
- File:
src/cohere/types/embed_floats_response.py
Signature
class EmbedFloatsResponse(UncheckedBaseModel):
id: str
embeddings: typing.List[typing.List[float]]
texts: typing.List[str]
images: typing.Optional[typing.List[Image]] = None
meta: typing.Optional[ApiMeta] = None
Import
from cohere.types import EmbedFloatsResponse
I/O Contract
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id |
str |
Yes | -- | Unique identifier for this embed request |
embeddings |
List[List[float]] |
Yes | -- | An array of embeddings where each embedding is an array of floats; length matches the input array |
texts |
List[str] |
Yes | -- | 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
Basic Float Embedding Response
import cohere
co = cohere.Client()
response = co.embed(
texts=["Hello world", "Embeddings are useful"],
model="embed-english-v3.0",
input_type="search_document",
)
# Access the embeddings
print(f"Request ID: {response.id}")
print(f"Number of embeddings: {len(response.embeddings)}")
print(f"Embedding dimension: {len(response.embeddings[0])}")
# Iterate over text-embedding pairs
for text, embedding in zip(response.texts, response.embeddings):
print(f"Text: {text[:30]}... -> Embedding dim: {len(embedding)}")
Computing Cosine Similarity
import cohere
import numpy as np
co = cohere.Client()
response = co.embed(
texts=["machine learning", "artificial intelligence", "cooking recipes"],
model="embed-english-v3.0",
input_type="search_document",
)
# Convert to numpy arrays for similarity computation
embeddings = np.array(response.embeddings)
# Cosine similarity between first two texts
similarity = np.dot(embeddings[0], embeddings[1]) / (
np.linalg.norm(embeddings[0]) * np.linalg.norm(embeddings[1])
)
print(f"Similarity between '{response.texts[0]}' and '{response.texts[1]}': {similarity:.4f}")