API Gateway
What is the API Gateway?
AQBot includes a built-in local API server that exposes your configured providers as OpenAI-compatible, Claude-native, and Gemini-native endpoints. Any tool or client that speaks one of these protocols can use AQBot as its backend — no separate API keys or relay services required.
Use cases:
- Run Claude Code CLI, OpenAI Codex CLI, Gemini CLI, or OpenCode through AQBot.
- Feed your IDE extensions through a single, locally managed endpoint.
- Share one set of provider keys across many tools with per-key rate limiting.
Getting Started
- Open Settings → API Gateway (or press Cmd/Ctrl+Shift+G).
- Click Start to launch the gateway server.
- By default the server listens on
127.0.0.1:8080(HTTP). You can change the listen address and port in the Settings tab.
TIP
Enable Auto-start in the gateway settings to launch the server automatically when AQBot starts.
API Key Management
The gateway authenticates incoming requests with its own API keys, separate from your provider keys.
- Go to the API Keys tab.
- Click Generate New Key.
- Optionally add a description (e.g. Claude Code, VS Code) to identify each key.
- Copy the key — it is only displayed once.
Each key shows its prefix, creation date, and last used timestamp. You can enable/disable or delete keys at any time.
WARNING
Treat gateway keys like any other API key. Anyone with the key can send requests to your local gateway while it is running.
Program Policies
Program policies let you control which models each connected tool can access and how fast it can make requests.
| Setting | Description |
|---|---|
| Model whitelist | Restrict the tool to a specific set of models. Requests for unlisted models are rejected. |
| Rate limiting | Cap the number of requests per minute for this tool. |
Create policies in the Program Policies section of the gateway settings.
SSL/TLS
The gateway can serve HTTPS alongside or instead of HTTP.
Auto-Generated Certificate
Open the Settings tab.
Enable SSL/TLS and select Generate mode.
AQBot creates a self-signed certificate and private key at:
~/.aqbot/ssl/cert.pem ~/.aqbot/ssl/key.pemSet the HTTPS port (default
8443).Optionally enable Force SSL to redirect all HTTP requests to HTTPS.
Custom Certificate
Select Upload mode and provide the paths to your own certificate and private key files.
INFO
The private key is stored with file mode 0600 on Unix systems to prevent other users from reading it.
Usage Analytics
The Metrics tab provides dashboards for monitoring gateway activity:
| View | Description |
|---|---|
| By API Key | Request volume and token usage broken down by each gateway key |
| By Provider | Requests and tokens routed to each upstream AI provider |
| By Day | Daily usage trends over time |
Use these dashboards to track cost, spot anomalies, and balance load across providers.
Request Logs
The Overview tab shows recent request logs with the following details:
- Timestamp, HTTP method, path
- Status code and response time
- Provider and model used
- Token count (prompt + completion)
Click any log entry to inspect the full request and response. Use the Clear Logs button to reset the log history.
Configuration Templates
AQBot ships with ready-made configuration snippets for popular CLI tools. Go to the Templates tab, pick a tool, and click Copy to get the configuration you need.
Claude Code CLI
claude config set --global apiUrl http://127.0.0.1:8080
claude config set --global apiKey aqbot-xxxxOpenAI Codex CLI
export OPENAI_BASE_URL=http://127.0.0.1:8080/v1
export OPENAI_API_KEY=aqbot-xxxx
codexOpenCode
Add to your OpenCode configuration:
{
"provider": "openai",
"baseURL": "http://127.0.0.1:8080/v1",
"apiKey": "aqbot-xxxx"
}Gemini CLI
export GEMINI_API_BASE=http://127.0.0.1:8080
export GEMINI_API_KEY=aqbot-xxxx
geminiCustom Client
Any tool that accepts an OpenAI-compatible base URL can connect to the gateway:
Base URL: http://127.0.0.1:8080/v1
API Key: aqbot-xxxxReplace aqbot-xxxx with a key generated in the API Keys tab. If SSL is enabled, use https:// and port 8443 (or your configured HTTPS port).
Connecting External Tools
Below is a general pattern for connecting any OpenAI-compatible client:
- Generate a gateway API key in AQBot.
- Set the base URL in your tool's configuration to
http://127.0.0.1:8080/v1(or the HTTPS equivalent). - Set the API key to the gateway key you generated.
- Select a model that you have configured in one of your AQBot providers.
- Start using the tool — all requests route through AQBot to the upstream provider.
TIP
If a tool requires a specific API format (e.g. Claude or Gemini native), AQBot automatically detects the request format and routes it to the correct provider. You do not need to configure separate endpoints per format.
Next Steps
- Getting Started — return to the quick start guide
- Configure Providers — add the upstream providers the gateway routes to
- MCP Servers — connect external tools for AI tool calling
