POST /v2/embed to create one embedding per input sample. The endpoint returns all results in one JSON response, in input order. It uses the served model’s existing embedding and pooling implementation.
The request and response format targets vLLM v0.32.0’s Cohere-style embedding API. For the OpenAI request format, use /v1/embeddings.
Start an embedding server
The commands below target Linux with one NVIDIA CUDA GPU and a SGLang build that includes/v2/embed. Install SGLang using the installation guide. The client example requires the Python requests package.
Start Qwen/Qwen3-Embedding-0.6B:
Authorization: Bearer YOUR_API_KEY in each request. Keep the tokenizer enabled; /v2/embed requires it.
Embed text
After the server is ready, send a JSON request:model selects the model already served by this process; the request does not load another model.
Request fields
SendContent-Type: application/json. Provide exactly one non-null field among texts, images, and inputs, and give it a nonempty list. For example, sending both texts and images returns HTTP 400. Use inputs to combine text and images in one sample.
All samples in a request share the task, dimension, encoding, and truncation settings. Unknown JSON fields are ignored. In particular,
stream: true does not enable streaming.
Task instructions
input_type is a model-defined key. The server reads string-valued entries from the model’s task_instructions configuration. If that mapping is empty, it reads prompts from config_sentence_transformers.json.
For example, a model with this instruction mapping accepts "input_type": "query":
search_document instruction.
For texts, a nonempty instruction becomes the system message when a chat template is available. Without a chat template, the server concatenates the instruction and the text exactly; it inserts no separator. In the example above, the instruction’s trailing space separates it from the text.
When input_type is omitted, texts are tokenized without adding a task instruction or rendering a chat template. images and inputs always use a chat template, including inputs containing only text.
Image and mixed inputs
Image request conversion is implemented. Real image-model GPU inference and Nemotron 3.5 Embed HF-reference validation have not been completed for this endpoint. The examples below specify the request format; they do not provide a validated multimodal model deployment recipe.
data:image/png;base64,.... The server must be able to fetch or decode the image. A content block uses one of these forms:
The
image_url field is an object containing url, not a string. Audio and video content blocks are not accepted.
The following example constructs two request bodies from a local PNG. Place an existing PNG at image.png before running it:
POST /v2/embed to a multimodal embedding server. In mixed_request, vector 0 represents the text and image together; vector 1 represents the text-only sample. Each content list must be nonempty and can contain multiple images.
Token limits and truncation
The budget applies separately to each sample after task instructions, templates, special tokens, and multimodal preprocessing have been applied. The server input limit accounts for context length, reserved tokens, and scheduling limits; it is not necessarily equal to--context-length.
Let B be the server’s available input-token limit and N a positive max_tokens value.
For
texts not rendered through a chat template, tokens added by the tokenizer (such as BOS or EOS) are kept and count toward the budget; only text tokens are removed. If the budget cannot fit the required special tokens, the request returns HTTP 400. A budget equal to their count can leave only special tokens.
For example, if the tokenizer produces [A, B, C, D, <|endoftext|>], with the final EOS token added by the tokenizer and max_tokens: 3:
ENDremoves text tokens from the end and retains[A, B, <|endoftext|>].STARTremoves text tokens from the start and retains[C, D, <|endoftext|>].NONEreturns HTTP 400 instead of truncating.
texts and text-only inputs, END keeps the beginning of the token sequence and START keeps the end, up to the effective budget; template tokens outside that slice can be removed.
A final empty token sequence returns HTTP 400. An empty string is not rejected solely for being empty: the result depends on the tokens added during preprocessing.
For multimodal inputs, truncation has additional restrictions:
STARTreturns HTTP 400 when shortening is required.ENDcan remove only a trailing text region while keeping every image token span and boundary token.- Image inputs with MRoPE or separate vision-position metadata cannot be shortened by this endpoint. Missing or invalid image span boundaries also cause HTTP 400 when shortening is required.
- Image inputs without a complete, consistent expanded token sequence return HTTP 400 in all three modes, even if the input fits the token budget.
Output dimensions and encodings
Setoutput_dimension to request a shorter vector. The server checks that the model supports Matryoshka embeddings, that the dimension is in its configured allowed list when one exists, and that it does not exceed the model’s maximum dimension. A failed check returns HTTP 400.
The server command above explicitly enables 128-dimensional output. Request that dimension and two encodings:
N samples with dimension D, the response contains:
Binary encodings require
D to be divisible by 8; otherwise the request returns HTTP 400. Each component greater than or equal to zero maps to bit 1, and each negative component maps to bit 0. The first component occupies the most significant bit.
For example, [1, -1, 1, -1, 1, -1, 1, -1] becomes 10101010, so ubinary is [170] and binary is [42]. Requesting several encodings converts the same inference result into each format.
Response fields
A successful request returns HTTP 200 with these fields:
Token counts include preprocessing and reflect truncation. For a mixed batch containing an image,
image_tokens includes text tokens and tokens from text-only samples as well. It is request-level accounting, not a count of visual tokens alone or a monetary charge.
Errors
The endpoint uses anerror object containing message, type, param, and code. param is null when no parameter name is supplied.
For example, requesting an unknown task key on a model with no configured instructions returns HTTP 400 with this structure:
Every 5xx response uses the generic message
Internal server error; the detail is written to the server log. The response keeps its status code, such as 503, and headers such as Retry-After.
Server authentication and scheduling also apply their existing checks.
Current scope
- GPU integration tests cover text requests with
Alibaba-NLP/gte-Qwen2-1.5B-instruct,Qwen/Qwen3-Embedding-0.6B, andnvidia/Nemotron-3-Embed-1B-BF16. These tests compare results with/v1/embeddings. The Nemotron test also checks the model-definedqueryanddocumenttask prefixes. - The endpoint adapts requests to installed model implementations. It does not add Nemotron model implementations.
- Encoder/language disaggregation is not supported for these embedding requests. Use a server that runs the model and its encoder together for image requests.
- The endpoint returns embeddings only. It does not implement Cohere chat, text generation, reranking, audio/video inputs, or streaming.
