Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:BerriAI Litellm Embedding Types

From Leeroopedia
Attribute Value
Sources litellm/types/embedding.py
Domains Embeddings, Vector Representations, API Requests
Last Updated 2026-02-15 16:00 GMT

Overview

Pydantic model defining the request schema for LiteLLM's embedding API, supporting all providers through a unified interface.

Description

This module contains a single Pydantic model, EmbeddingRequest, that represents the parameters for making an embedding API call through LiteLLM. It provides a provider-agnostic request format that gets transformed into provider-specific requests by LiteLLM's embedding handler. The model uses ConfigDict(extra="allow") to permit additional provider-specific parameters to be passed through.

Usage

Import from this module when:

  • Building embedding requests programmatically before passing them to litellm.embedding().
  • Validating embedding request parameters in middleware or custom code.
  • Working with the internal embedding pipeline where request objects are constructed and validated.

Code Reference

Source Location

litellm/types/embedding.py (21 lines)

Signature

class EmbeddingRequest(BaseModel):
    model: str
    input: List[str] = []
    timeout: int = 600
    api_base: Optional[str] = None
    api_version: Optional[str] = None
    api_key: Optional[str] = None
    api_type: Optional[str] = None
    caching: bool = False
    user: Optional[str] = None
    custom_llm_provider: Optional[Union[str, dict]] = None
    litellm_call_id: Optional[str] = None
    litellm_logging_obj: Optional[dict] = None
    logger_fn: Optional[str] = None

    model_config = ConfigDict(extra="allow")

Import

from litellm.types.embedding import EmbeddingRequest

I/O Contract

Inputs (EmbeddingRequest)

Field Type Default Description
model str (required) The embedding model identifier (e.g., "text-embedding-3-small")
input List[str] [] List of text strings to embed
timeout int 600 Request timeout in seconds
api_base Optional[str] None Custom API base URL
api_version Optional[str] None API version string (e.g., for Azure)
api_key Optional[str] None API key for authentication
api_type Optional[str] None API type identifier
caching bool False Whether to cache results
user Optional[str] None End-user identifier for tracking
custom_llm_provider Optional[Union[str, dict]] None Override provider routing
litellm_call_id Optional[str] None Internal call identifier for logging
litellm_logging_obj Optional[dict] None Internal logging object
logger_fn Optional[str] None Custom logger function name

Outputs

This module defines only the request type. The response is returned as LiteLLM's standard EmbeddingResponse (defined in litellm/types/utils.py).

Usage Examples

Creating an embedding request

from litellm.types.embedding import EmbeddingRequest

request = EmbeddingRequest(
    model="text-embedding-3-small",
    input=["Hello, world!", "How are you?"],
    timeout=300,
    caching=True,
)

With provider-specific parameters

from litellm.types.embedding import EmbeddingRequest

# Extra fields are allowed via ConfigDict(extra="allow")
request = EmbeddingRequest(
    model="azure/text-embedding-ada-002",
    input=["Embed this text"],
    api_base="https://my-azure.openai.azure.com/",
    api_version="2024-02-01",
    api_key="sk-...",
    api_type="azure",
)

Related Pages

  • RAG Types -- RAG ingest pipeline types that use embedding models for vector generation.
  • Vector Store Types -- Vector store types that store the output of embedding operations.
  • Rerank Types -- Reranking types that complement embedding-based retrieval.

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment