For a developer or platform engineer connecting an existing OpenAI-compatible chat server to Hivenet Router, the first useful test is a chat reply. A green health check only tells you the backend is reachable and reports ready. Router can still advertise a model name that the server rejects. Register the backend’s base URL, readiness URL, and accepted model ID with the custom agent. Then send one short chat request directly and through Router. Comparing those two responses tells you where to investigate before you change a working application.
This walkthrough uses the custom agent in Router v0.1.7 for a server without a dedicated Router integration. If you run llama.cpp, use the llama.cpp setup guide for its model discovery behavior. For the custom agent, you supply both the model ID and the full readiness URL.
An OpenAI-compatible chat API accepts a JSON payload at POST /v1/chat/completions and returns the model’s assistant message. The backend runs the model. A chat interface such as Open WebUI displays the conversation in a browser and calls an API. Here the custom agent sits beside the backend. Clients, including a self-hosted chat interface, connect to Router’s client API.
Choose the agent for the software actually serving your self-hosted models. A vLLM server serves models over HTTP with both Completions and Chat Completions APIs. Ollama can run open-weight models locally and exposes an OpenAI-compatible API for chat. Router has a dedicated agent for each. If you have Ollama, the Ollama connection guide shows how to register the model by tag. Continue here if you have another compatible service and already know its model ID.
Open Bash on the backend host. You’ll need curl 7.76 or later, a running chat server, an installed Router agent, and a reachable Router deployment. The example backend listens on loopback and accepts local requests without a key. Replace port 8000, the readiness path /ready, and the example model ID support-chat with values from your server. Keep this shell open for the final comparison.
Look for HTTP 200 from the exact URL the agent will poll. A health check tells you the server is ready according to that endpoint. To see whether the server accepts the model ID and chat format, send a short prompt directly.
The Content-Type: application/json header describes the request body. In messages, the role identifies the speaker, and the content string holds the user’s text. Starting with one user message and stream: false gives you a single response to inspect. Leave sampling parameters at the backend’s default values for this first test.
Check for an assistant reply in choices[0].message.content. If the server reports an unknown model, change the ID in CHAT_BODY and repeat the direct call. Use that same ID in the agent command below. Save the model ID that worked, including its spelling and any namespace. The custom agent forwards the chat body to the backend, so an invented display name here can break an otherwise healthy setup.
In a second shell on the same host, run the agent. Replace the binary path, Router gRPC address, and file paths with yours. The JWT secret file must contain the shared secret for this Router. Choose a persistent identity path in an existing directory the agent can write to. The agent must be able to reach the Router’s gRPC listener and its advertised peer address.
Use the base address for --backend-url. The agent appends /v1/chat/completions when forwarding this request. For --health-url, give the complete URL that returned 200. For --model, use the ID from the successful direct request. The custom engine takes this value from configuration and skips backend model discovery. Leave the agent running. The custom engine reference also covers Docker and protected backends.
If your backend requires a bearer token, add its authorization header to both direct curl checks. Use the backend credential for those calls. In Router v0.1.7, supply the agent with a protected key file using --backend-api-key-file. The agent sends that key as a bearer token to the backend and to the configured health URL, so verify both destinations before starting it. Router strips the client’s authorization header on the way to the backend. Keep the backend key on the server. The agent configuration reference describes this behavior.
Return to the first shell so CHAT_BODY still contains the working request. Enter the HTTPS base URL for Router’s client API and an inference key allowed to call this model. The agent’s gRPC address and shared JWT secret serve a separate purpose. First check what this client can see in the Router model catalog.
Find your exact model ID in data. For this single-agent example, its agents.engines should include custom and agents.healthy should be at least one. Now change the HTTP destination to Router and send the original chat body with the client key.
A successful non-streaming call returns one JSON response. Read choices[0].message.content as you did on the direct call. The wording can vary between runs. If several agents serve the same name or your policy allows fallback, a successful reply alone cannot identify the backend. To trace a specific call, add -i before sending it. Find the request_id in the Router audit log that matches the response’s X-Request-ID header. Read agent_id in that record to identify the selected agent or provider.
Suppose the backend accepts support-chat, but the agent starts with --model support. Its readiness check can still pass, and Router can list support. A client that requests support can then reach a backend that rejects that name. Compare the model in the working direct request, the agent flag, and the routed JSON. Restart the agent with the backend’s accepted ID, check the catalog again, and replay the original request.
If the ID is missing from the catalog, check the readiness URL from the agent host, the agent’s registration logs, and the client key’s model permissions. If the direct request itself fails, inspect the backend path, its authentication requirements, and the response body first. Once both calls work, keep the short request as a repeatable check after a backend upgrade or a model rename.
Once curl works, use the same requested model in your application. With the OpenAI Python client, set base_url to Router’s HTTPS address ending in /v1 and api_key to the Router inference key. The SDK appends the chat completions path. If the command line works but the application returns a path error, check whether its configured base URL already contains /v1/chat/completions. The Router client examples show the complete Python and JavaScript calls.
For a browser-based chat application, configure the OpenAI-compatible endpoint in the chat interface’s server settings. Open WebUI can connect to Router this way. Use HTTPS for the public connection and restrict the API key to the models its users may call. For a multi-user deployment, require each person to sign in to the chat interface. Keep the shared Router credential in the application’s server-side configuration. Router applies the limits configured for the connection’s key, so one user can exhaust the shared allowance. Set a request limit to bound call volume and a token limit to bound model usage. See the Router API key settings for the available controls. The Open WebUI guide covers that setup.
If curl works but your own browser client fails, check which component sends the request. A server-side connection from Open WebUI to Router does not depend on browser CORS rules. If browser JavaScript calls a different origin directly, configure that API or its proxy to allow the intended frontend origin. Keep authentication in place. CORS governs which cross-origin responses a browser exposes to scripts. See the browser CORS guide.
The chat completions API uses the conversation history you send in messages. For a follow-up such as “Make that title shorter,” your application should include the first user request, the assistant’s actual reply, and the new user message in order. Include the system prompt again if your model supports it and your application depends on it. The chat completions call is stateless: sending only the follow-up leaves the model without the title it should shorten. Replaying a long transcript also uses input tokens on every turn. Keep the turns your application needs and budget room for the answer within the model’s context window. For an API provider that bills by input token, resending unnecessary history can also increase the cost of each follow-up. On a self-hosted model, those tokens still consume context capacity. Verify the second turn with a question that depends on the first answer.
Test streaming directly on the backend, then repeat the request through Router. Set stream to true and use curl -N so curl displays incoming data as it arrives. A backend that supports OpenAI-compatible streaming sends server-sent events. A streamed chunk can contain a fragment in choices[0].delta.content, allowing the interface to display the answer before generation finishes. Router relays what the backend sends. If the direct stream arrives progressively but the routed answer arrives all at once, check for buffering in the proxy.
OpenAI-compatible servers can differ in which message roles, tools, and sampling parameters they accept. If your application needs tool calls, run a separate request with the tool definition it actually uses. Check the returned tool name and arguments before your application acts on them. For example, vLLM accepts top_k as an extra parameter through the OpenAI client’s extra_body. If an application was written for that API provider and now targets a different server, remove the extension for the first test and restore it only if the backend documents support. The vLLM server reference lists its extensions. A plain text reply verifies the basic chat route. The Router chat completions reference describes what the backend controls.
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.