Skip to content

Serve models to agents

A model provider can run the router to serve its own models to HexaEight agents.

Today a customer creates an API key with you and keeps it wherever their software runs. Whoever holds the key can spend on that account, and the key names an account, not the agent or the person behind a request.

With a router:

  • Your models have a name on your domain, such as large.example.com. Serve all your models under one name, or give each model its own, such as large.example.com and fast.example.com. Each name is a router of its own.
  • Your customers’ agents call that name directly. When an agent starts, it checks that the address answers as that name, and it does not use an address that does not.
  • There is no API key and no OAuth. Every request is encrypted end to end between the customer’s agent and your router, and proves which agent sent it. That proof is the credential: there is nothing to issue, store, rotate or leak.
  • You decide who may use it, by identity: a person, or a customer’s agent.
  • You bill by identity. Every call is recorded with who it was for, the model and the tokens used.

The customer’s agent decides whether the person is named:

the customer’s agent is working foryour router sees, and bills
a person signed in to itthat person, proven with their own key
a caller it keeps privateonly the agent

An agent can keep every caller from outside its company private. The agent itself is then your customer: for a personal agent, one person; for a company’s agent, the company.

Your router accepts private callers unless upstreams.yaml says otherwise:

requireIdentifiedCaller: true # refuse callers who are not named

A provider normally leaves this out. Who a customer’s own users are is the customer’s business.

In the HexaEight Authenticator, use an identity whose email is at your domain, add a Domain Resource such as large.example.com, and publish the DNS TXT record the app gives you. The record is checked when the licence is granted. See Domain resource.

Run the one-line installer. In the licence step, scan with the domain resource. When the installer asks Where are your models?, choose 3 or 8, another endpoint that speaks the Anthropic or the OpenAI API, and give the address of your model.

From the router’s folder:

Terminal window
cd ~/heia-router
cp -p router-policy.he "router-policy.he.bak_$(date +%Y%m%d_%H%M%S)"
set -a; . ./env-file; set +a
./hexaeight-router-linux-x64 --init-policy
it asksanswer
Do you have an external authorization service?N
Who may use this router?the customers you admit, comma-separated
Which models may they use?* for every model, or the routes their plan includes, each as route|*
Which agents may vouch for them?blank
Write this policy?y

Admit each customer as:

  • a customer’s agent, by its name, such as agent01.example.org. Use this when the agent keeps its callers private.

  • a person, twice: by their email address, and by the SHA-512 hash of the lower-cased address:

    Terminal window
    printf '%s' '[email protected]' | tr '[:upper:]' '[:lower:]' | sha512sum | cut -d' ' -f1

The router reads its rules when it starts, so restart it:

Terminal window
heia restart router

Run --init-policy again for each new customer: it adds to the rules already there. More in Run your own router.

The router listens on port 5100. Publish it at an address on the same name, such as https://large.example.com, for example through your load balancer.

The router adds one line per call to usage.jsonl, in its folder:

field
tswhen the call ended
sessionthe session it belongs to
emailwho the call was for: the person, or the agent’s name for a private caller
route, modelwhat was called
input_tokens, output_tokenstokens in and out
cache_read_input_tokens, cache_creation_input_tokenscached tokens, when the model reports them
meteredfalse when the model reported no token counts
latency_mshow long the call took

Total it by customer with any tool you already use. The router also keeps a sealed audit trail: every session it allowed or refused, and every call.

They add an engine pointed at your router, by its name and address, with a route name you publish:

Terminal window
hexaeight-activate engine --add chat \
--name chat \
--model "large|<model id>" \
--router "large.example.com|https://large.example.com"

Their agent holds no key of yours. See Use someone else’s router.