BGE-M3 API
Available PopularBGE-M3 is a widely used open-weight embedding model from BAAI. It covers more than 100 languages, accepts inputs up to 8,192 tokens and returns 1,024-dimension vectors. It is served here on the OpenAI-compatible embeddings endpoint, so existing code works by changing the base URL and the model id.
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": "BAAI/bge-m3",
"input": ["The cat sat on the mat.", "Le chat est sur le tapis."]
}'
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="BAAI/bge-m3",
input=["The cat sat on the mat.", "Le chat est sur le tapis."],
)
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: "BAAI/bge-m3",
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
- Multilingual search and RAG: one model for more than 100 languages
- You want an open-weight embedding model, so your vectors never depend on one vendor keeping a model alive
- You need vectors shorter or longer than 1,024 dimensions
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 |
|---|---|
BAAI/bge-m3 | Canonical |
bge-m3 | Alias |
Request body
| Parameter | Type | Description |
|---|---|---|
model required |
string | Model ID: BAAI/bge-m3 — also accepted: bge-m3 |
input required |
string | array | One text or an array of up to 2,048 texts. Each text can be up to 8K tokens. |
dimensions |
integer | Not supported by this model; vectors are always 1,024 dimensions. |
encoding_format |
string | float (default) or base64. |
Response
{
"object": "list",
"model": "BAAI/bge-m3",
"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 are not comparable. Switching models means re-embedding your corpus, which is the reason to pick an open-weight model you can always run somewhere.
- There is no per-minute or per-day cap, so bulk indexing jobs are not throttled by a quota; usage draws on your prepaid balance.
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.
