Skip to main content

Overview

Crazyrouter is fully compatible with the OpenAI API format. Migrating from OpenAI or other providers requires changing just two parameters:
  1. Base URLhttps://crazyrouter.com/v1
  2. API Key → Your Crazyrouter sk-xxx key

Get an API Key

1

Register an Account

Visit crazyrouter.com to register
2

Top Up Balance

Go to the Top Up page and select a top-up amount
3

Create a Token

Go to the Tokens page, click Create Token, and get an sk-xxx format API Key

Migrating from OpenAI

Before

from openai import OpenAI

client = OpenAI(
    api_key="sk-openai-xxx"
    # Default base_url: https://api.openai.com/v1
)

After

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxx",  # Crazyrouter API Key
    base_url="https://crazyrouter.com/v1"  # Crazyrouter URL
)
No other code changes needed.

Migrating from Anthropic

Using OpenAI-Compatible Format

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxx",
    base_url="https://crazyrouter.com/v1"
)

# Call Claude models via OpenAI format
response = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Hello"}]
)

Using Anthropic Native Format

import anthropic

client = anthropic.Anthropic(
    api_key="sk-xxx",
    base_url="https://crazyrouter.com"  # Note: no /v1
)

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)

Migrating from Google Gemini

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxx",
    base_url="https://crazyrouter.com/v1"
)

response = client.chat.completions.create(
    model="gemini-2.5-pro",
    messages=[{"role": "user", "content": "Hello"}]
)

Environment Variables

It’s recommended to configure via environment variables to avoid hardcoding keys in your code:
export OPENAI_API_KEY=sk-xxx
export OPENAI_BASE_URL=https://crazyrouter.com/v1
Then no parameters needed in your code:
from openai import OpenAI
client = OpenAI()  # Automatically reads environment variables

Compatibility

FeatureCompatibility
Chat CompletionsFully compatible
StreamingFully compatible
Function CallingFully compatible
VisionFully compatible
EmbeddingsFully compatible
TTS / STTFully compatible
Images (DALL-E)Fully compatible
Anthropic Messages APIFully compatible
Gemini Native APIFully compatible
Crazyrouter supports OpenAI, Anthropic, and Gemini API formats simultaneously. Choose whichever format you’re most familiar with.