Local API Guide contents
Overview
OpenAI-compatible embeddings from Qwen3-Embedding-4B, the model behind the app's Knowledge search. It runs on the GPU next to the loaded chat model, so a chat model must be loaded. Vectors are 2,560-dimensional and normalised (length 1), so the dot product is the cosine similarity. Embeddings don't count toward your daily allowance.
Request body
| Parameter | Description |
|---|---|
inputstring | string[]required | The text, or up to 2,048 texts in one request. Each must be non-empty. |
input_typestring | document (default) embeds the text as it is. query adds the model's search instruction: use it for search queries, and document for the passages you search through. |
instructionstring | With input_type: "query": your own task description instead of the default search instruction. |
dimensionsinteger | 32 to 2,560: shorter vectors (the first n values, normalised again). Smaller indexes, slightly lower quality. |
encoding_formatstring | float (default) or base64 (little-endian float32). |
modelstring | Ignored: always Qwen3-Embedding-4B. |
| Authorization header | Authorization: Bearer <key>, only when Require API key is on in the app. |
Response
| Field | Description |
|---|---|
objectstring | list |
data[].embeddingnumber[] | string | The vector (or base64), with index matching the input's position. |
modelstring | qwen3-embedding-4b |
usageobject | prompt_tokens and total_tokens. |
timings.msnumber | Time on the GPU, in milliseconds. |
Example
curl http://localhost:1234/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"input": ["The RTX 5090 has 32 GB of memory.", "Cats sleep a lot."], "dimensions": 1024}'
from openai import OpenAI client = OpenAI(base_url="http://localhost:1234/v1", api_key="not-needed") docs = ["The RTX 5090 has 32 GB of memory.", "Cats sleep a lot."] d = client.embeddings.create(model="qwen3-embedding-4b", input=docs).data q = client.embeddings.create(model="qwen3-embedding-4b", input="How much VRAM does a 5090 have?", extra_body={"input_type": "query"}).data[0].embedding scores = [sum(a * b for a, b in zip(q, e.embedding)) for e in d] print(max(zip(scores, docs)))
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "http://localhost:1234/v1", apiKey: "not-needed" }); const r = await client.embeddings.create({ model: "qwen3-embedding-4b", input: ["The RTX 5090 has 32 GB of memory."], dimensions: 1024 }); console.log(r.data[0].embedding.length); // 1024
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0213, -0.0047, 0.0391, …] },
{ "object": "embedding", "index": 1, "embedding": [-0.0102, 0.0288, 0.0015, …] }
],
"model": "qwen3-embedding-4b",
"usage": { "prompt_tokens": 17, "total_tokens": 17 },
"timings": { "ms": 9.6 }
}Errors
| Status | Code | When |
|---|---|---|
| 401 | invalid_api_key | Require API key is on and the key is missing or wrong. |
| 400 | (none) | input is empty or has more than 2,048 items, or another parameter is out of range. |
| 503 | model_not_loaded | No chat model is loaded: the knowledge model runs inside the engine. |
| 500 | (none) | The knowledge model file is missing: download it on the Models page in the app. |