EmbeddingResponse
Contains generated embeddings.
For the list of response object types, see Response Objects.
Use EmbeddingResponse to inspect embedding vectors generated for one or more input text values.
Attributes
| Attribute | Type | Description |
|---|---|---|
data |
list[VectorEmbedItem] |
Generated embedding results. |
Methods
| Method | Return Type | Description |
|---|---|---|
model_dump() |
dict[str, Any] |
Returns a dictionary representation of the response. |
model_dump_json() |
str |
Returns a JSON string representation of the response. |
to_dict() |
dict[str, Any] |
Returns a dictionary representation compatible with earlier SDK response handling. |
to_json() |
str |
Returns a JSON string representation compatible with earlier SDK response handling. |
to_str() |
str |
Returns a readable string representation compatible with earlier SDK response handling. |
model_validate(obj) |
EmbeddingResponse |
Creates a response object from a dictionary payload. |
model_validate_json(json_data) |
EmbeddingResponse |
Creates a response object from a JSON string. |
Iterate Attributes
Use serialization helpers to iterate response attributes and item attributes.
response = client.generate_embedding(
model_name="ALL_MINILM_L12_V2",
inputs=["Trail running shoes"],
)
payload = response.to_dict()
for attribute, value in payload.items():
print(attribute, value)
for item in response.data:
item_payload = item.to_dict()
for attribute, value in item_payload.items():
print(attribute, value)
Sample Response
{
"data": [
{
"text": "Trail running shoes",
"embedding": [0.12, 0.45, 0.32]
}
]
}
Returned By
Returned by: generate_embedding().