Embedding
Embedding
any_llm.embedding(model, inputs, *, api_key=None, api_base=None, **kwargs)
Create an embedding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
str
|
Model identifier in format 'provider/model' (e.g., 'mistral/mistral-small') |
required |
inputs
|
str | list[str]
|
The input text to embed |
required |
api_key
|
Optional[str]
|
API key for the provider |
None
|
api_base
|
Optional[str]
|
Base URL for the provider API |
None
|
**kwargs
|
Any
|
Additional provider-specific parameters |
{}
|
Returns:
Type | Description |
---|---|
CreateEmbeddingResponse
|
The embedding of the input text |
Source code in src/any_llm/api.py
any_llm.aembedding(model, inputs, *, api_key=None, api_base=None, **kwargs)
async
Create an embedding asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
str
|
Model identifier in format 'provider/model' (e.g., 'openai/text-embedding-3-small') |
required |
inputs
|
str | list[str]
|
The input text to embed |
required |
api_key
|
Optional[str]
|
API key for the provider |
None
|
api_base
|
Optional[str]
|
Base URL for the provider API |
None
|
**kwargs
|
Any
|
Additional provider-specific parameters |
{}
|
Returns:
Type | Description |
---|---|
CreateEmbeddingResponse
|
The embedding of the input text |