Get started

How it works

How OpenLLM routes a request through the hosted gateway or the daemon on your device, falls back along a chain, and what its servers can and cannot see.

Every AI tool wants its own key, base URL, and model names, and some models can only be reached from your own machine: a Claude or ChatGPT subscription runs through the vendor's CLI, and a local model server listens on localhost. OpenLLM puts all of them behind one endpoint and one key, and decides for each request where the work runs.

The three parts

  • Hosted gateway (https://www.openllm.sh/v1). It checks your key, resolves model names and chains, serves API-key and included models, records usage, and hosts the dashboard.
  • Local daemon. One per device, built into the openllm binary and run as a background service. It serves your subscriptions and local model servers, and listens on http://127.0.0.1:8787/v1 by default. It keeps a connection to the gateway so the dashboard can manage it and the gateway can hand requests to it.
  • CLI and MCP server (openllm). It installs the daemon, starts clients with OpenLLM applied, and runs an MCP server for your clients. On a Mac, the Mac app can set up the daemon instead. See Install.

The request path

  1. Check the key. Your tool sends an OpenAI- or Anthropic-shaped request with your sk-llm-… key in Authorization: Bearer or x-api-key. The key also unlocks your vault for this one request.
  2. Resolve the model. A full id such as provider/model names one model. An alias such as ultra, or a chain you made in Configuration, expands to an ordered list. Models you can't use right now drop out: a model cooling down after a rate limit, or an included model whose monthly allowance is spent.
  3. Choose where it runs. If the chain starts with a subscription or local model and one of your online devices can serve it, the gateway hands the whole request to that device. Otherwise the gateway runs it.
  4. Walk the chain. OpenLLM tries the first model. On a rate limit, an exhausted quota, an auth error, or a missing model, it moves to the next one. On a network or server error it retries the same model once first.
  5. Stream the answer back in your tool's format. The x-openllm-resolved-model header names the model that answered, and x-openllm-chain lists the models tried.
  6. Record usage. After the response, OpenLLM records one row of metadata: model, provider, token counts, latency, and status. When a device served the request, the device records it.
Steps 1 to 4 happen before any output; step 5 streams the answer back.

Hosted gateway and your devices

Model sourceHosted gatewayYour device (daemon)
API keysRuns the requestSends the hop to the gateway; credentials are not decrypted on the device
Included modelsRuns the requestSends the hop to the gateway
SubscriptionsNeverRuns the request through the vendor's own CLI
Local model serversNeverRuns the request against the server on the device
Credentials stay in their lane; requests cross between lanes, logins never do.

The gateway never holds a subscription login or a local server's key, so those models are only available while one of your devices is online. When a hosted request's chain starts with one of them, the gateway hands the request to an online device that can serve it. The device runs the subscription and local models itself and sends any API-key models in the chain back to the gateway.

If no online device can serve those models, or the chain starts with an API-key model, the gateway skips subscription and local models and continues with the rest of the chain. If nothing is left, the request fails with 403 and subscription_requires_daemon or local_requires_daemon.

A client pointed at the daemon on its own machine skips the hand-off. openllm claude does this whenever the daemon is running. The daemon asks the gateway for a routing plan, sending the model name and a token estimate but not the prompt, and runs the plan locally. If the plan has no subscription or local model, the daemon passes the whole request to the gateway instead.

The first remaining model in the chain decides where a hosted request runs.

Fallback

Fallback happens only before a response starts. Once a model begins streaming output, OpenLLM stays on it, and a failure after that point reaches your tool as an error. A request that every model would reject, such as a malformed or oversized one, fails on the first model without moving on. To edit chains and context-overflow behavior, see Routing and fallback.

What OpenLLM's servers see

DataWhat OpenLLM's servers see
API-key provider credentialsCiphertext encrypted in your browser. Decrypted in memory for one request, then wiped.
Subscription loginsNever. They stay in the vendor CLI on your device.
Local model serversNever their keys. Only the list of models an online device reports.
Recovery phraseNever.
Vault keyOnly wrapped copies at rest. Unwrapped in memory for one request, using your sk-llm key.
Your sk-llm keysEach request's key in its header. At rest, only a copy encrypted under your vault key.
Prompts and completions on hosted requestsIn memory while forwarding. Not logged, except a response cached for 10 minutes when you send an Idempotency-Key.
Prompts sent straight to your daemon that run on a subscription or local modelNever. The prompt goes from your device to the vendor or the local server.
Request metadataStored: model, provider, token counts, latency, status, key id, and time.
Your browser and your device hold the secrets; the servers hold ciphertext and open it only in memory.

OpenLLM does not use your prompts or completions to train models. Retention periods are on Privacy.

Limitations

  • Subscription and local models need one of your devices online with the daemon running.
  • After a model starts streaming, there is no fallback.
  • Your sk-llm key carries a wrapped copy of your vault key, so anyone holding it can decrypt your stored provider credentials. If a key leaks, delete it in Devices & keys. See If a key leaks.
  • Hosted requests pass through OpenLLM's servers in memory on the way to the provider.

Further reading

Last updated on

On this page