AI Gateway Endpoints and Environment Variables
Beyond using one-click takeover to configure off-the-shelf AI tools, you can also call the AI Gateway directly from your own apps, scripts, or any AI tool. This article covers the endpoint formats the gateway exposes and how to connect to it using a virtual key.
Proxy Endpoints
The AI Gateway's proxy service listens on http://127.0.0.1:11580. To stay compatible with SDKs and tools from different vendors, the gateway offers multiple protocol formats on the same port:
| Protocol Format | Endpoint Path | Use Case |
|---|---|---|
| OpenAI compatible | http://127.0.0.1:11580/v1 | Any SDK / tool that uses the OpenAI API format (e.g., /v1/chat/completions) |
| Anthropic compatible | http://127.0.0.1:11580/v1/messages | The Anthropic SDK, Claude Code, and more |
| Gemini compatible | http://127.0.0.1:11580/v1beta | The Google Gemini SDK, and more |
Simply pick the format that matches the protocol of the SDK you're using, and point your requests at the gateway address. The gateway will route each request to the corresponding provider channel based on the permissions of the virtual key.
Authentication: Using a Virtual Key
All requests to the gateway are authenticated with a virtual key, not a real provider key. First, create a virtual key on the Keys page and copy its plaintext value.
On the AI Gateway → Endpoints page, you can select a virtual key, and the gateway will generate copy-ready environment variable snippets for common tools.
Environment Variable Examples
The following examples assume you already have a virtual key (referred to as <your virtual key>).
OpenAI-Compatible SDKs / Tools
bash
export OPENAI_BASE_URL="http://127.0.0.1:11580/v1"
export OPENAI_API_KEY="<your virtual key>"1
2
2
Claude Code / Anthropic
bash
# Note: the Anthropic protocol uses the gateway root address, without /v1
export ANTHROPIC_BASE_URL="http://127.0.0.1:11580"
export ANTHROPIC_AUTH_TOKEN="<your virtual key>"1
2
3
2
3
Gemini
bash
export GOOGLE_GEMINI_BASE_URL="http://127.0.0.1:11580"
export GEMINI_API_KEY="<your virtual key>"1
2
2
Example Call (OpenAI-Compatible)
bash
curl http://127.0.0.1:11580/v1/chat/completions \
-H "Authorization: Bearer <your virtual key>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}]
}'1
2
3
4
5
6
7
2
3
4
5
6
7
Here, model must be a model that you've already configured in a channel and that the virtual key is allowed to call.
Prerequisites
- The AI Gateway proxy service is running.
- At least one healthy channel is configured, and a virtual key with the appropriate model / channel permissions has been created.
FAQ
- Q: The request returns an authentication failure.
- A: Make sure you're using a virtual key (not a real provider key), and that the key hasn't expired or been revoked.
- Q: It says the model is unavailable or I don't have permission.
- A: Make sure the
modelis configured in some channel, and that the virtual key's "allowed models / channels" list includes it.
- A: Make sure the
- Q: Which endpoint format should I use?
- A: Pick based on your SDK's protocol — use
/v1for OpenAI-style,/v1/messagesfor Anthropic-style (with a Base URL that doesn't include/v1), and/v1betafor Gemini-style.
- A: Pick based on your SDK's protocol — use
- Q: Can other devices on my LAN access the gateway?
- A: By default, the gateway only listens on
127.0.0.1(localhost only). This is the recommended setting for security reasons.
- A: By default, the gateway only listens on
Summary
The AI Gateway provides a unified local endpoint in three compatible formats — OpenAI, Anthropic, and Gemini. Combined with virtual key authentication, you can connect any app or AI tool to the gateway and enjoy unified key management and usage statistics. For common CLI tools, using one-click takeover is even easier.
