EmbeddingResponse class
A response from the embeddings API.
Contains the generated embeddings along with token usage information.
Example
final response = await client.embeddings.create(request);
for (final embedding in response.data) {
print('Embedding ${embedding.index}: ${embedding.embedding.length} dims');
}
if (response.usage != null) {
print('Used ${response.usage!.totalTokens} tokens');
}
- Annotations
-
- @immutable
Constructors
-
EmbeddingResponse({required String object, required List<
Embedding> data, required String model, EmbeddingUsage? usage}) -
Creates an EmbeddingResponse.
const
-
EmbeddingResponse.fromJson(Map<
String, dynamic> json) -
Creates an EmbeddingResponse from JSON.
factory
Properties
-
data
→ List<
Embedding> -
The list of embeddings generated.
final
-
firstEmbedding
→ List<
double> -
Gets the first embedding vector.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- model → String
-
The model used for generating embeddings.
final
- object → String
-
The object type (always "list").
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- usage → EmbeddingUsage?
-
Token usage statistics.
final
Methods
-
copyWith(
{String? object, List< Embedding> ? data, String? model, Object? usage = unsetCopyWithValue}) → EmbeddingResponse - Creates a copy with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts to JSON.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override