For developers building semantic search or retrieval-augmented generation (RAG), a self-hosted embeddings API lets you turn private documents and search queries into numeric vectors on infrastructure you choose. This is useful when you need to control where the text is processed or keep an index tied to a specific model revision. In this setup, your application posts text to Hivenet Router at /v1/embeddings, and Infinity runs the model.
You’ll check one query with curl, then submit a two-document batch and match the returned vectors to their document IDs. An HTTP success alone can miss a costly indexing error: a billing article stored under the ID for a password-reset guide.
For semantic search, the application embeds both the documents and the query with a compatible model and compares their vectors. The API generates the embeddings. Your application still needs somewhere to store and search them. This guide starts after you’ve chosen a model. For help deciding which model fits your corpus, see how to choose an embedding model for your retrieval workload.
Self-hosting gives your team control over where inference runs, which model version serves requests, and when it changes. That matters if a search index must stay on one model revision or if sensitive documents need to stay within an approved network. Map the route from application to Router, Infinity, and the vector store. Check access and retention on each system. Router’s dedicated audit records omit request and response bodies, but an application or reverse proxy can log them separately. See the Router audit logging reference.
With a managed embeddings API, the provider runs and updates the model servers. With a self-hosted service, you choose the model revision and rollout schedule. Your team also owns health checks, capacity, patches, and rollback. For an occasional indexing job, paying a provider for just the input you send may be simpler than keeping a GPU allocated between runs.
If a hosted API bills per input token, multiply the tokens in a representative indexing run by the provider’s rate. For self-hosting, add hardware or rental time, storage, and operations, including idle capacity. Divide each total by the same number of successfully embedded documents. A steady, high-volume workload can make a fixed allocation easier to budget. Measure it against your own traffic before drawing a savings conclusion.
Running the embedding model near the application can remove a round trip to an external API. Time the full request from the client, including queueing and inference. Test a single search query while a batch job is running so the latency figure reflects the service your users will see.
Yes. The Router integration supports Infinity on a CPU as well as on a GPU. The command below selects CUDA and float16. For CPU inference, choose a CPU-compatible Infinity installation, device setting, and data type. Measure your own queries on the hardware you intend to run. A batch indexing job and an interactive search box can have quite different latency requirements.
For a deployment with data privacy requirements, plan model installation separately from inference. Obtain the model files and runtime dependencies before starting an isolated deployment, then test startup and a request under the network policy it will actually use. Check where the client, logs, and vector database run as well.
The example assumes a running Hivenet Router with client authentication enabled. On the backend host, you’ll need a compatible NVIDIA CUDA environment, access to the model weights, and a Router agent binary. Use Bash, curl 7.76 or later, and a Python environment with infinity-emb 0.0.80 installed. This is the Python infinity_emb v2 server documented for Router v0.1.7. The Infinity agent setup guide also covers containers and running multiple models.
Start Infinity in one terminal. The command pins the BAAI/bge-m3 weights to a specific revision and exposes the model as bge-m3. Record both values with your index so you can reproduce the deployment. The agent will run on the same host, so the server can listen on loopback. If you already run this model, use its configured address and served name. BGE-M3 is a multilingual text embedding model that supports dense vectors, sparse lexical weights, and multi-vector retrieval. This endpoint example requests a dense vector. The model card lists support for more than 100 languages and a context length of 8,192 tokens. Check the backend’s configured input limit before sending a long document.
Leave Infinity running. From a second terminal on the same host, check readiness and discovery. Wait for the health check to succeed and look for bge-m3 in the model list. If discovery returns 404, check the URL prefix and port before changing anything in Router.
In the second terminal, start a Router agent with --capability embedding. Router uses the capability and model name to select an eligible backend. A working chat agent on the same Router does not establish that an embedding request can be served.
Replace the sample Router gRPC address and paths below. The agent must be able to reach the Router, read its shared JWT secret file, and write to the directory for its persistent identity. Use the backend origin without /v1. Leave this process running while you test from a client shell.
In the client shell, replace the example origin with the HTTPS address your application uses, without a trailing slash or /v1. Load a Router inference key that can access bge-m3 into ROUTER_CLIENT_KEY. The client authenticates with this key. The agent’s JWT secret stays on the backend host.
Look for one entry in data with index: 0 and a nonempty numeric array in embedding. The API returns the complete vector in the response. Receiving a vector checks the serving path. You’ll need labeled queries and relevant documents to judge retrieval quality.
Yes. The endpoint uses the OpenAI-compatible embeddings format. If your application already uses the OpenAI Python SDK, keep the embeddings.create call and point the client’s base URL at Router, including /v1. Supply the Router API key and the served model name. From the client shell above, this example prints the length of the returned vector.
Applications usually have document IDs before they have vectors. Keep those IDs beside the exact strings you send. Each response entry has a zero-based index into the original input array. Use it to recover the document ID even if the entries arrive in a different order.
Run this Python 3 example from the same client shell. It uses the standard library, asks for two vectors, and prints each document ID and its vector length. It checks that each input index appears exactly once and that each vector has the 1,024 numeric values expected from this model. If you use a different model, set the expected dimension from its specification.
A successful check prints help-17 and help-42, each with the same positive dimension count. The BGE-M3 model card specifies 1,024 dimensions for its dense vectors. With that model and its standard output, expect both lines to end in 1024. Compare the result with your vector index’s configured dimension before inserting either document. If you split a larger job into batches, each request starts counting at zero. Keep a separate document-ID list for each batch.
Store each document’s ID, text reference, model revision, and vector together. At query time, send the search query through the same model and look up the nearest document vectors in your vector database.
Changing the base URL moves the API call. It does not move your stored vectors into a shared vector space with a new embedding model. Before switching traffic, check which model file and revision each endpoint loads, the text preprocessing it applies, and the embedding dimension it returns. Use the similarity metric expected by your index, such as cosine similarity for a configuration that compares vector directions. Different models can return the same embedding dimension while placing the same text at different coordinates. When you change models, build a new index and re-embed the documents before directing search queries to it.
Try a query whose answer you know. With the two example documents, use a password question and check whether help-17 ranks ahead of the billing document. That is a small retrieval check you can repeat when you change the serving configuration. For a production decision, test representative queries from your own application.
Measure indexing and interactive search separately. Batching several texts into one API call can improve indexing throughput, while one long batch can keep a short query waiting. Start with the two-input request, increase the batch size in steps, and record documents per second, query latency, errors, and peak memory at each step. Use the same input lengths and model revision across runs. If a run slows down, compare client latency with backend processing time. Use separate network and queue measurements before attributing the difference to either one.
GET /v1/models with the client key. Check for the exact served ID and the embedding capability. If it’s missing, inspect agent registration and the key’s model permissions.model_forbidden, check whether the key permits the requested model.The Router embeddings API reference documents the request fields, response, and limits. Once your search system has retrieved candidates, you can pass those documents and the query to a separate model for scoring. That step is covered in RAG reranking with Hivenet Router.
Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.