← Blog
Published on
2026-11-26

Connect Ollama to Hivenet Router and send your first chat request

If you already run a local LLM and want colleagues or an application to reach it through one API, you can use Ollama with Hivenet Router. Ollama runs the model on your hardware. A Router agent beside Ollama registers one model tag and forwards chat requests to it. This gives the team a stable address even when you move the model to another machine. You’ll check the tag on the host, find the corresponding ID from a client machine, and use that ID to get your first answer. Those checks tell you where to look if a model works locally but disappears from the client’s model list.

This walkthrough uses a running Router with client authentication enabled, an Ollama server with a local chat model, Bash, and curl 7.76 or later. The example model is llama3.1:8b. If you still need to install Ollama or pull a model onto a GPU host, start with the self-hosted Ollama setup guide.

Which address do I use for Ollama with Hivenet Router?

Hivenet Router is open-source inference routing software. It gives applications a single API endpoint for the models their key can access. The difference between the three addresses matters when a first request fails. An application that points to Router’s gRPC authentication port will never reach the chat API.

  • Ollama’s HTTP address is the agent’s backend URL. In this example, the model server listens on 127.0.0.1:11434 on the agent’s machine.
  • Router’s gRPC address is where the agent authenticates at startup. Router then advertises a peer address for registration and request forwarding. An agent on another host must be able to reach both.
  • The client-facing HTTPS base URL is where your application lists models and sends chat messages. The examples assume a reverse proxy or load balancer provides HTTPS in front of Router’s HTTP listener (port 8080 by default).

Find your local model in the Ollama API

Run this command on the Ollama host. Port 11434 belongs to the local Ollama server. The agent will call that same address, so Ollama can keep listening on loopback.

curl --fail-with-body -sS http://127.0.0.1:11434/api/tags

Look for llama3.1:8b in the name field of a models entry. If you use a different chat model, copy its name, including the tag, into the agent command below. If the model is missing, pull it on this Ollama server and repeat the check. For example, ollama pull llama3.1:8b downloads the tag used here. Choose a model your host has enough memory to run. An entry here tells you Ollama has the model. Router discovery comes after agent registration. See Ollama’s model list response.

Configure the Hivenet Router agent for Ollama

Run the agent beside Ollama. The example assumes the v0.1.7 agent binary is at ./bin/hivenet-agent. Replace the example Router address and region with your own. The agent needs a readable copy of the Router’s shared JWT secret and a writable, persistent directory for its identity file. The v0.1.7 Ollama agent guide covers preparing those paths and running the agent in Docker.

./bin/hivenet-agent \
  --engine ollama \
  --model llama3.1:8b \
  --backend-url http://127.0.0.1:11434 \
  --router-grpc 192.168.1.100:50051 \
  --jwt-secret-file /opt/hivenet-router/jwt.secret \
  --region EU-France \
  --identity-path /var/lib/hivenet-router/agent/ollama-8b.key

Leave the agent running in this shell. For a pinned chat model, the agent checks that Ollama is reachable and sends the selected model a warm-up request with max_tokens: 1. It registers after that request succeeds. A large model can take time to load even after its tag appears locally.

Without --model, the agent registers the first model returned by Ollama. Pinning the tag makes the choice explicit when someone pulls another model onto the same host. To expose a second model from the same Ollama server, run a second agent with its own model tag and identity file.

Can Ollama and the agent run in Docker?

Yes. The Ollama deployment docs show separate server and agent containers on Linux with host networking. They can share the host’s loopback address without running in the same container. If you use bridge networking, 127.0.0.1 inside the agent container points back to that container. Check the backend URL from the agent’s network before troubleshooting Router.

Give the agent read access to the shared secret and a separate writable, persistent location for its identity file. Replacing the container with the same identity file preserves its peer ID. On a CPU-only host, omit the GPU option from the documented Docker commands.

Check which model your Router API key can see

Open a second Bash shell on the client machine. Enter your Router’s HTTPS base URL and an inference API key that can access the model. The previous command used a shared secret to register the agent. The client uses its own key to make requests.

read -rp 'Router HTTPS base URL (without /v1): ' ROUTER_URL
read -rsp 'Router inference API key: ' ROUTER_API_KEY
printf '\n'
curl --fail-with-body -sS "${ROUTER_URL%/}/v1/models" \
  -H "Authorization: Bearer ${ROUTER_API_KEY}"

Read the data array in the JSON output. Find the entry whose id string is llama3.1:8b. Check that agents.engines includes ollama and agents.healthy is at least 1. Copy the returned id for the chat request. With --model, the agent uses the name you supplied. If you omit the flag, automatic discovery strips a trailing :latest and preserves other tags, including :8b. See the Router model catalog fields.

Send a chat completion to the Router API

In the same client shell, send a short prompt to POST /v1/chat/completions. Use the model ID from the Router catalog in the JSON body. Setting stream to false makes the first reply easier to inspect as a single JSON response.

curl --fail-with-body -sS "${ROUTER_URL%/}/v1/chat/completions" \
  -H "Authorization: Bearer ${ROUTER_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data '{
    "model": "llama3.1:8b",
    "messages": [{"role": "user", "content": "What is a model tag? Answer in one sentence."}],
    "stream": false
  }'

Read the assistant’s answer in choices[0].message.content. A successful response confirms that this key can get a chat completion through Router for the requested model. If several backends serve the same ID, the reply alone does not identify which one answered. For testing, use a model ID served only by your Ollama agent and a policy without fallback. On a shared deployment, add -i to the curl command to include response headers in the output. An operator can then match the response’s X-Request-ID header to request_id and read the agent_id field in Router’s request audit record. The record omits prompt and response bodies, so you can investigate which backend answered without copying sensitive information from a conversation. The chat completions reference describes the response.

What changes when you add a second Ollama host?

Suppose a second machine serves the same model and tag. Start an agent beside that Ollama instance and give it its own persistent identity. The application can keep its Router URL and model ID. Router filters out unhealthy agents and applies the configured routing policy. For example, a least-loaded policy ranks eligible agents by current load. If the new machine serves a different model ID, select that ID in the request body instead. See the routing policy selection order.

If this client must use local infrastructure, check its YAML routing policy before adding another host. A configured external fallback can send a request to a cloud provider after local routing options are exhausted. To control which models a user can call and how much they can send, configure model access and request or token quotas on the inference key. See Router API key settings.

Monitor requests across Ollama instances

Router collects routing metrics in one place across its connected agents. Before sending more traffic, compare request counts, failures, and per-agent latency. The Ollama agent can report CPU and memory data, plus GPU utilization when NVIDIA’s NVML is available. Ollama does not expose engine queue depth through this integration. To bound concurrent work, set max_inflight in the model policy. The admission control reference defines it per healthy replica. For example, a setting of 2 gives a two-replica pool a ceiling of four requests in flight. If one replica becomes unhealthy, the ceiling drops to two. A per-key quota separately controls how much a client can send over time. The Router monitoring guide explains where to look when a request slows down.

Troubleshoot Ollama model discovery and chat errors

  • Ollama lists the tag, but Router has no entry. Read the agent’s startup logs. Verify the pinned tag, the shared secret file, and whether the agent can reach both Router’s gRPC endpoint and its advertised peer address. Then check that the client key has access to the model.
  • Router lists a different model. Compare the agent’s --model value with the local tag list. If the flag was omitted, restart the agent with an explicit tag and check the catalog again.
  • Discovery works, but chat fails. Use the same Router address and client key for both calls. Read the HTTP status and the error code in the response body. A 401 unauthorized points to the key. A 403 model_forbidden means the key cannot call that model. For 503 no_agents_available, check for a healthy matching agent. For 503 no_capacity, matching agents are already busy.
  • A short prompt works, but a long conversation fails. Check the error code before increasing the context window. A 400 context_length_exceeded means the backend rejected the context length. Retry with a shorter message history. A 429 token_limit_exceeded points to the client’s token budget. Changing the model’s context settings will not fix that quota.

Once the request returns an answer, you can use the same Router endpoint for a browser-based chat interface. Follow the Open WebUI connection guide to configure the client and check which models its users can select.

Your next workload belongs on Hivenet.

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.