Skip to main content
SGLang provides OpenAI-compatible APIs to enable a smooth transition from OpenAI services to self-hosted local models. A complete reference for the API is available in the OpenAI API Reference. This tutorial covers the embedding APIs for embedding models. For a list of the supported models see the corresponding overview page

Launch A Server

Launch the server in your terminal and wait for it to initialize. Native encoder embedding architectures and google/embeddinggemma-300m are detected automatically. Decoder-style embedding models still require --is-embedding.
Example

Using cURL

Example

Using Python Requests

Example

Using OpenAI Python Client

Example

Using Input IDs

SGLang also supports input_ids as input to get the embedding.
Example

Compact Base64 Responses

Set encoding_format to base64 when JSON arrays would dominate response size. The encoded value contains little-endian FP32 values and can be decoded by OpenAI-compatible clients.
Example
Example

Multi-Modal Embedding Model

Please refer to Multi-Modal Embedding Model