API Documentation
Get started with the KiroGate API
Authentication
All API requests must include an API key in the header. Three authentication modes are supported:
Mode 1: User API Key (sk-xxx format) โญ Recommended
# OpenAI format Authorization: Bearer sk-xxxxxxxxxxxxxxxx # Anthropic format x-api-key: sk-xxxxxxxxxxxxxxxx
Generate one in the user center after login. Uses your added tokens or the public token pool automatically.
Mode 2: Combined Mode (user-supplied REFRESH_TOKEN)
# OpenAI format Authorization: Bearer YOUR_PROXY_API_KEY:YOUR_REFRESH_TOKEN # Anthropic format x-api-key: YOUR_PROXY_API_KEY:YOUR_REFRESH_TOKEN
Mode 3: Simple Mode (uses server-configured REFRESH_TOKEN)
# OpenAI format Authorization: Bearer YOUR_PROXY_API_KEY # Anthropic format x-api-key: YOUR_PROXY_API_KEY
๐ก Recommended Usage
- โข Regular users: After login, generate an API key in
sk-xxxformat - the simplest option. - โข Self-hosted users: Use combined mode with your own REFRESH_TOKEN - no server config needed.
- โข Cache optimization: Each user's auth info is cached (up to 100 users) for improved performance.
Endpoints
/
Health check endpoint
/health
Detailed health check; returns token status and cache info
/v1/models
List available models (authentication required)
/v1/chat/completions
OpenAI-compatible chat completions API (authentication required)
/v1/messages
Anthropic-compatible messages API (authentication required)
Usage Examples
๐ OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="YOUR_PROXY_API_KEY"
)
response = client.chat.completions.create(
model="claude-sonnet-4-5",
messages=[{"role": "user", "content": "Hello!"}],
stream=True
)
for chunk in response:
print(chunk.choices[0].delta.content, end="")
๐ค Anthropic SDK (Python)
import anthropic
client = anthropic.Anthropic(
base_url="http://localhost:8000",
api_key="YOUR_PROXY_API_KEY"
)
message = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)
$ cURL
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer YOUR_PROXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [{"role": "user", "content": "Hello!"}]
}'
CLI Tools Integration
Auto-generated configuration for popular AI coding tools. The base URL is pre-filled with this server's address.
Claude Code
Claude Code is Anthropic's official CLI tool. It uses the Anthropic API format natively.
Step 1: Set environment variables
Step 2: Run Claude Code
claude
Note: Claude Code will automatically use the configured base URL and API key. All Claude models available on this gateway will work.
OpenCode
OpenCode is an open-source AI coding assistant that supports OpenAI-compatible APIs.
Step 1: Set environment variables
Step 2: Configure in opencode.json
Step 3: Run OpenCode
opencode
OpenClaw
OpenClaw is a lightweight CLI tool for interacting with OpenAI-compatible APIs.
Step 1: Set environment variables
Step 2: Run OpenClaw
openclaw
PicoClaw
PicoClaw is a minimal AI coding assistant with OpenAI-compatible API support.
Step 1: Set environment variables
Step 2: Run PicoClaw
picoclaw
Hermes Agent
Hermes Agent is an AI coding agent that supports the Anthropic API format.
Step 1: Set environment variables
Step 2: Run Hermes
hermes
Qwen Code
Qwen Code is an AI coding assistant that supports OpenAI-compatible APIs.
Step 1: Set environment variables
Step 2: Run Qwen Code
qwen-code
Available Models
Use any of these model IDs in your CLI tool configuration:
autoclaude-opus-4-7claude-opus-4-6claude-opus-4-5claude-sonnet-4-6claude-sonnet-4-5claude-sonnet-4claude-haiku-4-5deepseek-3-2minimax-m2-5minimax-m2-1glm-5qwen3-coder-nextcommandcode/claude-fable-5commandcode/claude-haiku-4-5commandcode/claude-opus-4-6commandcode/claude-opus-4-7commandcode/claude-sonnet-4-6commandcode/deepseek-v4-flashcommandcode/deepseek-v4-procommandcode/gemini-3.1-flash-litecommandcode/gemini-3.5-flashcommandcode/glm-5commandcode/glm-5.1commandcode/gpt-5.3-codexcommandcode/gpt-5.4commandcode/gpt-5.4-minicommandcode/gpt-5.5commandcode/kimi-k2.5commandcode/kimi-k2.6commandcode/kimi-k2.7-codecommandcode/mimo-v2.5commandcode/mimo-v2.5-procommandcode/minimax-m2.5commandcode/minimax-m2.7commandcode/minimax-m3commandcode/nemotron-3-ultracommandcode/qwen-3.6-max-previewcommandcode/qwen-3.6-pluscommandcode/qwen-3.7-maxcommandcode/qwen-3.7-pluscommandcode/step-3.5-flashcommandcode/step-3.7-flashcommandcode/taste-1
Available Models
autoclaude-opus-4-7claude-opus-4-6claude-opus-4-5claude-sonnet-4-6claude-sonnet-4-5claude-sonnet-4claude-haiku-4-5deepseek-3-2minimax-m2-5minimax-m2-1glm-5qwen3-coder-nextcommandcode/claude-fable-5commandcode/claude-haiku-4-5commandcode/claude-opus-4-6commandcode/claude-opus-4-7commandcode/claude-sonnet-4-6commandcode/deepseek-v4-flashcommandcode/deepseek-v4-procommandcode/gemini-3.1-flash-litecommandcode/gemini-3.5-flashcommandcode/glm-5commandcode/glm-5.1commandcode/gpt-5.3-codexcommandcode/gpt-5.4commandcode/gpt-5.4-minicommandcode/gpt-5.5commandcode/kimi-k2.5commandcode/kimi-k2.6commandcode/kimi-k2.7-codecommandcode/mimo-v2.5commandcode/mimo-v2.5-procommandcode/minimax-m2.5commandcode/minimax-m2.7commandcode/minimax-m3commandcode/nemotron-3-ultracommandcode/qwen-3.6-max-previewcommandcode/qwen-3.6-pluscommandcode/qwen-3.7-maxcommandcode/qwen-3.7-pluscommandcode/step-3.5-flashcommandcode/step-3.7-flashcommandcode/taste-1