Developer documentation

Integrate KeyGPT in minutes

KeyGPT exposes an OpenAI-compatible API, so you can plug it into your existing tooling with minimal changes. Use one base URL, one API key, and route requests to multiple providers.

Overview

KeyGPT gives you a unified OpenAI-compatible endpoint for multiple models and providers. You keep your app logic simple while KeyGPT handles routing, quota tracking, metering, and request logging.

Base URL
https://keygpt.net/v1
Protocol
OpenAI-compatible
Auth
Bearer API key

Authentication

Create an API key from your dashboard, then send it as a Bearer token with every request.

Authorization: Bearer keygpt-your-api-key

You can manage API keys at /dashboard/keys. New keys are only shown once when created.

Quickstart

Set your environment variables and make your first request.

export OPENAI_API_KEY="keygpt-your-api-key"
export OPENAI_BASE_URL="https://keygpt.net/v1"

curl $OPENAI_BASE_URL/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "user", "content": "Hello from KeyGPT"}
    ]
  }'

Claude CLI Provider Switch

Want Claude CLI to use KeyGPT as the provider? Copy one command below, replace YOUR_KEYGPT_KEY, and run it in your terminal.

Default Claude model mapping
  • Haiku (Fast)gpt-5.3-codex-xhigh
  • Sonnet (Default)gpt-5.4
  • Opus (Powerful)gpt-5.5
macOS / Linux
curl -fsSL https://keygpt.net/install/claude.sh | bash

One-line installer. It only asks for your API key, then automatically configures all 3 Claude models and creates helper commands: claude-haiku, claude-sonnet, claude-opus.

Windows PowerShell
irm https://keygpt.net/install/claude.ps1 | iex

One-line installer. It only asks for your API key, then automatically configures all 3 Claude models and creates helper commands: claude-haiku, claude-sonnet, claude-opus.

Windows CMD
powershell -ExecutionPolicy Bypass -Command "irm https://keygpt.net/install/claude.ps1 | iex"

For CMD users, this launches the same PowerShell installer in one line.

Uninstall / Reset to default
# macOS / Linux
curl -fsSL https://keygpt.net/install/claude-uninstall.sh | bash

# Windows PowerShell
irm https://keygpt.net/install/claude-uninstall.ps1 | iex

# Windows CMD
powershell -ExecutionPolicy Bypass -Command "irm https://keygpt.net/install/claude-uninstall.ps1 | iex"

Removes all environment variables and helper commands created by the installer, restoring your Claude terminal setup to its previous/default state after reopening terminal or VSCode.

Codex for VSCode

Configure Codex/OpenAI-compatible tools in VSCode to use your keygpt.net API key. This uses a separate installer from Claude.

Default Codex mapping
  • Defaultgpt-5.5
  • Fast helpergpt-5.4
  • Base URLhttps://keygpt.net/v1
macOS / Linux install
curl -fsSL https://keygpt.net/install/codex-vscode.sh | bash

One-line installer for macOS/Linux. It asks for your API key, sets OpenAI-compatible variables for Codex in VSCode, and creates helper commands.

Windows PowerShell install
irm https://keygpt.net/install/codex-vscode.ps1 | iex

One-line installer. It asks for your API key, sets OpenAI-compatible environment variables, and creates helper commands: codex-keygpt and codex-fast.

Windows CMD install
powershell -ExecutionPolicy Bypass -Command "irm https://keygpt.net/install/codex-vscode.ps1 | iex"
Uninstall / Reset Codex config
# macOS / Linux
curl -fsSL https://keygpt.net/install/codex-vscode-uninstall.sh | bash

# Windows PowerShell
irm https://keygpt.net/install/codex-vscode-uninstall.ps1 | iex

# Windows CMD
powershell -ExecutionPolicy Bypass -Command "irm https://keygpt.net/install/codex-vscode-uninstall.ps1 | iex"

Removes Codex/OpenAI environment variables and helper commands created by this installer. Close and reopen VSCode after install/uninstall.

Claude VSCode Integration

If you use Claude CLI/Claude Code inside VSCode integrated terminal, run the Claude installer first, then completely close and reopen VSCode so the terminal picks up the new environment variables.

Recommended flow
  • • macOS/Linux: curl -fsSL https://keygpt.net/install/claude.sh | bash
  • • Windows PowerShell: irm https://keygpt.net/install/claude.ps1 | iex
  • • Then fully close VSCode and open it again.
  • • Open a new integrated terminal and use: claude-haiku, claude-sonnet, or claude-opus.
If VSCode still uses old provider
# Check env inside VSCode terminal
# macOS / Linux
printf "%s
" "$OPENAI_BASE_URL" "$AIGATE_MODEL"

# PowerShell
$env:OPENAI_BASE_URL
$env:ANTHROPIC_BASE_URL
$env:AIGATE_MODEL

Expected base URL for OpenAI and Anthropic envs: https://keygpt.net/v1. If values are empty, restart VSCode completely and open a new terminal tab.

List Models

Query the available models for the current API key.

curl $OPENAI_BASE_URL/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

See the visual catalog on the models page.

SDK Examples

Python
from openai import OpenAI

client = OpenAI(
    api_key="keygpt-your-api-key",
    base_url="https://keygpt.net/v1"
)

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hi!"}]
)

print(resp.choices[0].message.content)
Node.js
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'keygpt-your-api-key',
  baseURL: 'https://keygpt.net/v1',
});

const resp = await client.chat.completions.create({
  model: 'gpt-5.5',
  messages: [{ role: 'user', content: 'Hi!' }],
});

console.log(resp.choices[0].message.content);

Integration Notes

  • • Generate API keys from /dashboard/keys.
  • • Use /v1/models to dynamically discover what is enabled.
  • • Request logs and token usage appear in your dashboard after each call.
  • • Admins can configure upstream providers and model mappings in /admin.