bitsrun

Self-hosted embeddings API for RAG and search

Run a self-hosted embeddings API for RAG and search on Text Embeddings Inference. Private, OpenAI-compatible, billed per second, with real cost math.

Updated

On this page

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.

ModelDeploy asDimensionsMax inputSizeNotes
Snowflake Arctic Embed L v2.0hf:Snowflake/snowflake-arctic-embed-l-v2.01,024 (MRL down to 256)8,192 tokens568M parametersMultilingual. Add query: before each query, not before documents
Qwen3 Embedding 0.6Bhf:Qwen/Qwen3-Embedding-0.6BUp to 1,024 (custom from 32)32K tokens0.6B parameters100+ 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 bitsrun command: curl -fsSL https://get.bitsrun.com | sh, then bitsrun login. Or use the dashboard.
  • Python 3 with pip install openai for 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.

  1. Deploy the model with a key that works only with this endpoint:

    bash
    bitsrun deploy hf:Snowflake/snowflake-arctic-embed-l-v2.0 --name "Docs search" --key

    You see the endpoint URL, the GPU (1x L4 (24 GB)) and an API key that starts with brk_. Save the key now; it is shown once.

  2. In the dashboard, the card shows Model type: Embeddings.

  3. Set your key in your shell:

    bash
    export 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.

python
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:

bash
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:

ModelQueries (about 27 tokens each), 1 clientQueries, 16 clientsDocuments (batches of 32, about 360 tokens each), 4 clientsModel load, including download
Snowflake Arctic Embed L v2.05,500 tokens/s23,400 tokens/s56,600 tokens/s116 s
Qwen3 Embedding 0.6B3,900 tokens/s17,300 tokens/s27,000 tokens/s36 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 embedArctic Embed L v2.0 on an L4Qwen3 Embedding 0.6B on an L4OpenAI text-embedding-3-small at $0.02 per 1M
10 millionabout 3 minutes, $0.06about 6 minutes, $0.11$0.20
100 millionabout 29 minutes, $0.48about 62 minutes, $0.99$2.00
1 billionabout 4.9 hours, $4.68about 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 codeWhat to do
404 not_found on /v1/chat/completionsEmbedding endpoints only answer /v1/embeddings and /v1/models.
400 context_too_long, or a cut-off resultSplit long documents into chunks of a few hundred words.
model_startingThe start took longer than 8 minutes, or you sent X-BitsRun-Wait: 0. Send the request again.
429 rate_limitedToo many requests open at once. Use fewer workers or bigger batches.
402 payment_requiredYour balance is $0. Add credit and the endpoint answers again within seconds.

Every code is on Error codes.

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.

Try it on your own model

Sign up with your email, add $10 of credit and deploy from an Ollama name or a Hugging Face repo. An L4 costs $0.95 an hour, billed per second only while your model is awake. Waking up is never billed, and credit you buy does not expire.