Skip to main content
Connect a gateway you already run in either direction: your gateway calls xpander, or xpander calls your gateway. Either way, xpander checks each call against your models, budgets and policies and records it in Logs. The diagram shows the first direction.

Your gateway in front of xpander

Your gateway treats xpander as one more upstream, and your apps change nothing. 1. Create an xpander API key and keep it in your gateway’s secret store. A person’s key from AI models & keys records calls under that person, with their models and budgets; an organization API key records them under the key. To try the commands here, export it as XPANDER_GATEWAY_KEY:
2. Add xpander as an upstream, one entry per model your apps should reach: If your gateway uses Authorization for its own sign-in, send the key as x-xpander-api-key instead. xpander removes it before the provider. On a self-hosted install, use https://llm-gw.<your domain>. List the model names your key may use:
Each call is one request in Logs, under the key’s person or the key, and the organization, person, group and key budgets apply. Claude Code calls /v1/messages, so point its ANTHROPIC_BASE_URL at your gateway only if your gateway serves that path, or connect it to xpander directly.

xpander in front of your gateway

In Models, add your gateway as a custom endpoint: usually OpenAI-compatible, a Base URL with /v1 (such as https://ai-gateway.example.com/v1), and Create a new key with the key your gateway issued for xpander. List the models with Test connection or Add model, then save.
  • xpander sends your gateway only that key, never an xpander key or another provider’s key.
  • On xpander cloud the address must be public https (address rules). On Hybrid or Air-Gapped it can be private.
  • Listed models are on for the organization when you save. A group with its own model list needs them ticked in Who may use it…, or callers get This model is not enabled for you on the xpander AI Gateway.
  • Call them as <provider ID>::<model>, such as ai_gateway::gpt-4o-mini.
  • To count spend, set a price per 1M tokens (USD) with Edit model. Without one, spend reads zero and dollar budgets don’t count it. These calls are never charged in xpander credits.
  • Claude Code can use these models too: xpander converts its Messages calls to the OpenAI-compatible format, so your gateway only needs /v1/chat/completions.

Route a self-hosted install through your gateway

On Hybrid and Air-Gapped, each provider’s upstream is an environment variable on the Agent Controller, so your gateway can sit between xpander and the vendor. The controller egresses to api.anthropic.com by default; with an override, the override is the only host it needs. xpander applies its policy, budget and record before the call leaves. Your gateway’s other clients stay outside xpander’s controls.

Send records to your own observability

Log destinations copies every request record to an OpenTelemetry collector or your own bucket, never with prompt or response text.

Next steps

Add a custom endpoint

Every field of the form.

Send records to your observability

OpenTelemetry and buckets.