Embeddings
The embeddings endpoint generates vector representations of input text. This endpoint is compatible with OpenAI’s/v1/embeddings API.
Request
Parameters
Required
string | array
required
Input text to generate embeddings for. Can be:
- A single string
- An array of strings for batch processing
- An array of token IDs (integers)
- An array of arrays of token IDs
- An array of multimodal embedding inputs (for multimodal models)
string
default:"default"
Model name to use for embeddings.
Optional
string
default:"float"
Format of the embeddings. Currently only
"float" is supported.integer
Number of dimensions for the output embeddings. If specified, the model will reduce the embedding dimensionality.
string
Unique identifier for the end-user.
SGLang Extensions
string
Path to LoRA adapter weights to apply to the model.
string
Request ID for tracking.
integer
Priority level for the request.
Multimodal Embeddings
For multimodal embedding models, you can provide text, images, and videos:Multimodal Input Format
string
Text content for the embedding.
string
Image URL, file path, or base64-encoded image.
string
Video URL, file path, or base64-encoded video.
Response
string
Always
"list".array
string
Model used to generate embeddings.
object
Examples
Single Text Embedding
Batch Embeddings
Semantic Similarity
With LoRA Adapter
Supported Models
SGLang supports various embedding models including:-
Text Embeddings:
BAAI/bge-large-en-v1.5BAAI/bge-base-en-v1.5intfloat/e5-mistral-7b-instructsentence-transformers/all-MiniLM-L6-v2
-
Multimodal Embeddings:
- Models supporting text + image embeddings
- Models supporting text + video embeddings
Response Format
Use Cases
Retrieval-Augmented Generation (RAG)
Embeddings are commonly used in RAG systems to find relevant documents:Clustering
Group similar texts together:See Also
- Chat Completions - Generate text
- Completions - Text completions
- Models - List available models
