Qwen3 Embedding 8B API
AvailableQwen3 Embedding 8B is the largest model of Alibaba's Qwen3 embedding series. It is multilingual, accepts inputs up to 32K tokens and returns 4,096-dimension vectors by default. It was trained so that vectors can be shortened with the dimensions parameter; we verified that a request for 512 dimensions returns 512.
Quickstart
Set INFERENCE_API_KEY to your key from the API Keys page, then run:
curl https://api.inferenceapis.com/v1/embeddings \
-H "Authorization: Bearer $INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-Embedding-8B",
"input": ["The cat sat on the mat.", "Le chat est sur le tapis."],
"dimensions": 1024
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.inferenceapis.com/v1",
api_key=os.environ["INFERENCE_API_KEY"],
)
resp = client.embeddings.create(
model="Qwen/Qwen3-Embedding-8B",
input=["The cat sat on the mat.", "Le chat est sur le tapis."],
dimensions=1024,
)
vectors = [d.embedding for d in resp.data]
print(len(vectors), len(vectors[0]), resp.usage.total_tokens)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inferenceapis.com/v1",
apiKey: process.env.INFERENCE_API_KEY,
});
const resp = await client.embeddings.create({
model: "Qwen/Qwen3-Embedding-8B",
input: ["The cat sat on the mat.", "Le chat est sur le tapis."],
});
console.log(resp.data.length, resp.data[0].embedding.length, resp.usage.total_tokens);
When to use it
- You want to choose the vector size: the dimensions parameter shortens vectors from 4,096 down
- Long inputs up to 32K tokens
- Storage is tight and you will not shorten the vectors; 4,096 floats per text adds up
What it costs in practice
| Workload | Cost |
|---|---|
| Index 10,000 documents of 500 tokens | $0.10 |
| Index 1 million documents of 500 tokens | $10.00 |
| 1 million search queries of 20 tokens | $0.40 |
Computed from the live rate below. There is no subscription or minimum; new accounts start with free credit.
Endpoint
Content-Type: application/json
/openai/v1/… is accepted too, so Groq-style base URLs work with only the host changed.
Model IDs and aliases
Send any of these as model; they all resolve to this model and bill at its rate.
| ID | Note |
|---|---|
Qwen/Qwen3-Embedding-8B | Canonical |
qwen3-embedding-8b | Alias |
Request body
| Parameter | Type | Description |
|---|---|---|
model required |
string | Model ID: Qwen/Qwen3-Embedding-8B — also accepted: qwen3-embedding-8b |
input required |
string | array | One text or an array of up to 1,024 texts. Each text can be up to 32K tokens. |
dimensions |
integer | Shorten the vectors (for example 1024 or 512). This model is trained so that the leading dimensions carry the most information. |
encoding_format |
string | float (default) or base64. |
Response
{
"object": "list",
"model": "Qwen/Qwen3-Embedding-8B",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, ...] },
{ "object": "embedding", "index": 1, "embedding": [0.0119, -0.0431, ...] }
],
"usage": { "prompt_tokens": 17, "total_tokens": 17 }
}
Pricing
| Price | $0.02 / 1M input tokens |
| Billing | Pay as you go from prepaid credits. No subscription, no daily request or token cap. See all pricing. |
Notes
- Vectors from different embedding models, or of different lengths, are not comparable. Pick a dimension count once per index.
Errors
Errors use the OpenAI envelope: {"error": {"message", "type", "code"}}. 401 missing or invalid key · 402 insufficient_balance · 404 model_not_found · 503 model_unavailable · 502 backend error, safe to retry. Full table with what to retry: API documentation. Errors from other providers: provider error reference.
