This guide shows how to run a self-hosted embeddings API for RAG and semantic search: an open embedding model on its own GPU, behind your own key, answering the OpenAI /v1/embeddings format. Deploying takes about 5 minutes. You also get the real numbers: how fast it embeds on one NVIDIA L4 and what a bulk indexing job costs compared with a per-token API.
What embeddings are
An embedding is a list of numbers (a vector) that captures what a piece of text means. Texts with similar meaning get vectors that sit close together. You store the vectors of your documents in a vector database, embed each search query the same way, and return the closest documents. That is semantic search. RAG (retrieval-augmented generation) adds one step: you hand the closest documents to a chat model so it answers from your data.
One rule matters more than any other: vectors from different models cannot be compared. Embed your documents and your queries with the same model.
How to choose an embedding model
Our docs use these two models. Both are released under the Apache 2.0 licence, so you can use them commercially.
| Model | Deploy as | Dimensions | Max input | Size | Notes |
|---|---|---|---|---|---|
| Snowflake Arctic Embed L v2.0 | hf:Snowflake/snowflake-arctic-embed-l-v2.0 | 1,024 (MRL down to 256) | 8,192 tokens | 568M parameters | Multilingual. Add query: before each query, not before documents |
| Qwen3 Embedding 0.6B | hf:Qwen/Qwen3-Embedding-0.6B | Up to 1,024 (custom from 32) | 32K tokens | 0.6B parameters | 100+ languages. Put a one-line task instruction before each query |
Dimensions and limits come from each model card. MRL (Matryoshka representation learning) means you can keep only the first part of each vector to save storage, with a small loss in quality. BitsRun passes the dimensions field for models that can shorten their vectors.
Pick Arctic Embed L v2.0 for the fastest bulk indexing in our tests. Pick Qwen3 Embedding 0.6B if you want instruction-aware queries or a model that loads faster.
Before you start
- A BitsRun account with credit (from $10). Create your account.
- The
bitsruncommand:curl -fsSL https://get.bitsrun.com | sh, thenbitsrun login. Or use the dashboard. - Python 3 with
pip install openaifor the examples.
How to deploy an embedding model on Text Embeddings Inference
Embedding models in safetensors format run on Text Embeddings Inference (TEI), Hugging Face's server for embedding models with token-based dynamic batching. BitsRun picks it for you from the model's files.
Deploy the model with a key that works only with this endpoint:
bashbitsrun deploy hf:Snowflake/snowflake-arctic-embed-l-v2.0 --name "Docs search" --keyYou see the endpoint URL, the GPU (
1x L4 (24 GB)) and an API key that starts withbrk_. Save the key now; it is shown once.In the dashboard, the card shows Model type: Embeddings.
Set your key in your shell:
bashexport BITSRUN_API_KEY="brk_your_key"
Embedding models are small, so they fit the smallest GPU size. In the dashboard, type the same hf: name into Model on New endpoint, select Check model, then Create and start.
How to call /v1/embeddings with the OpenAI SDK
Replace <endpoint-id> with the id from your endpoint URL.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://<endpoint-id>.endpoint.bitsrun.com/v1",
api_key=os.environ["BITSRUN_API_KEY"],
)
documents = [
"To reset your password, open Settings and select Reset password.",
"You can change your login email on the Account page.",
]
doc_vectors = client.embeddings.create(model="snowflake-arctic-embed-l-v2.0", input=documents)
query = client.embeddings.create(
model="snowflake-arctic-embed-l-v2.0",
input="query: How do I reset my password?",
)
print(len(query.data[0].embedding))You should see 1024. Store doc_vectors.data[i].embedding in your vector database next to each document.
The same call with curl:
curl https://<endpoint-id>.endpoint.bitsrun.com/v1/embeddings \
-H "Authorization: Bearer $BITSRUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "arctic", "input": "query: How do I reset my password?"}'Embedding endpoints answer only /v1/embeddings and /v1/models. LangChain works too, with OpenAIEmbeddings and check_embedding_ctx_length=False; see Embeddings.
How fast is a self-hosted embeddings API on one L4?
We measured TEI on one NVIDIA L4:
| Model | Queries (about 27 tokens each), 1 client | Queries, 16 clients | Documents (batches of 32, about 360 tokens each), 4 clients | Model load, including download |
|---|---|---|---|---|
| Snowflake Arctic Embed L v2.0 | 5,500 tokens/s | 23,400 tokens/s | 56,600 tokens/s | 116 s |
| Qwen3 Embedding 0.6B | 3,900 tokens/s | 17,300 tokens/s | 27,000 tokens/s | 36 s |
To get close to the document numbers, send batches (one request with 32 to 64 texts, not one request per text) from a few workers in parallel. Pay as you go allows 10 requests open at once, which is plenty for 4 workers.
How much does it cost to embed a large dataset?
An L4 costs $0.000264 a second while awake. The cold start is free. With Sleep after set to 60 seconds, the job is billed for its run time plus one minute.
At the measured document throughput:
| Tokens to embed | Arctic Embed L v2.0 on an L4 | Qwen3 Embedding 0.6B on an L4 | OpenAI text-embedding-3-small at $0.02 per 1M |
|---|---|---|---|
| 10 million | about 3 minutes, $0.06 | about 6 minutes, $0.11 | $0.20 |
| 100 million | about 29 minutes, $0.48 | about 62 minutes, $0.99 | $2.00 |
| 1 billion | about 4.9 hours, $4.68 | about 10.3 hours, $9.79 | $20.00 |
The math for 100 million tokens on Arctic: 100,000,000 / 56,600 = 1,767 s, plus 60 s of idle time, = 1,827 s x $0.000264 = $0.48. The OpenAI price is the standard rate listed on OpenAI's pricing page on 2026-11-14 ($0.13 per 1M for text-embedding-3-large).
Be fair to the comparison:
- Bulk jobs favor self-hosting. You pay for GPU time, so a busy GPU is cheap per token.
- Light query traffic favors per-token APIs. A search box that gets one query a minute keeps your endpoint awake all day: about $22.80 a day on an L4. A per-token API would charge cents for the same queries. For light traffic, let the endpoint sleep and accept a cold start, or embed queries in batches.
- Your speed will differ. Longer chunks, smaller batches or fewer workers lower throughput. Run a sample and scale it up.
Model your own job in the cost calculator.
Is a self-hosted embeddings API private?
Yes. BitsRun never logs or stores your prompts or outputs, which for embeddings means the texts you send and the vectors you get back. Your data is never used for training, and each endpoint runs for you alone. We keep request records (time, endpoint, which key, a scrambled form of the caller's IP address, and the caller's approximate location and network) for 180 days, for billing disputes and abuse checks. See Privacy and your data.
If something goes wrong
| Message or code | What to do |
|---|---|
404 not_found on /v1/chat/completions | Embedding endpoints only answer /v1/embeddings and /v1/models. |
400 context_too_long, or a cut-off result | Split long documents into chunks of a few hundred words. |
model_starting | The start took longer than 8 minutes, or you sent X-BitsRun-Wait: 0. Send the request again. |
429 rate_limited | Too many requests open at once. Use fewer workers or bigger batches. |
402 payment_required | Your balance is $0. Add credit and the endpoint answers again within seconds. |
Every code is on Error codes.
Related guides
- Run a Hugging Face model as a private API
- Deploy an Ollama model to the cloud as a private API
- Host a GGUF model as an OpenAI-compatible API
Ready to index your documents? Create your account.
Frequently asked questions
Which embedding model should I start with?
Snowflake Arctic Embed L v2.0 is a good default: multilingual, 1,024 dimensions, Apache 2.0, and the fastest for bulk indexing in our tests on one L4. Qwen3 Embedding 0.6B is a good second choice if you want instruction-aware queries.
Can I switch embedding models later?
Yes, but you must embed all your documents again with the new model. Vectors from different models cannot be compared, so queries and documents always need the same model.
Does it work with the OpenAI SDK and LangChain?
Yes. Set the base URL to your endpoint address ending in /v1 and the key to your BitsRun key, then call embeddings.create. In LangChain, use OpenAIEmbeddings with check_embedding_ctx_length=False.
Is self-hosting cheaper than OpenAI embeddings?
For bulk indexing, usually yes: 100 million tokens cost about $0.48 on one L4 with Arctic Embed L v2.0, against $2.00 for text-embedding-3-small. For a trickle of queries spread over the day, a per-token API is usually cheaper because a GPU kept awake costs $0.95 an hour.
Are my documents stored or logged?
No. BitsRun passes your texts to the model and returns the vectors without writing either to logs or databases, and never trains on them.