Guides

Quickstart

Get set up in a few minutes: create an API key, set an environment variable, and send your first request in the language you already use.

Before you start

Sign up and add funds

Create an account in the FlyRouter console and add funds on the top-up page. Every model is billed from your balance by actual usage, with no monthly fee.

Create an API key

Open the API keys page and click "Create key". Keys start with sk- and are shown in full only once, so copy it right away.

Set an environment variable

Keep the key in an environment variable rather than in your code. Every example below reads it from there.

Terminal
export FLYROUTER_API_KEY="sk-..."

Send your first request

This example calls gpt-6.1-sol through the OpenAI SDK. The only difference from calling OpenAI directly is the base URL, https://api.flyrouter.ai/v1.

curl https://api.flyrouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $FLYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [{"role": "user", "content": "Introduce yourself in one sentence"}]
  }'

The response has exactly the same shape as OpenAI's: the reply is in choices[0].message.content and token usage is in usage.

Call Claude

For Claude, use the official Anthropic SDK (the native Messages protocol) so prompt caching, reasoning and other Claude features work in full. Note that the Anthropic SDK base URL does not include /v1.

# pip install anthropic
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["FLYROUTER_API_KEY"],
    base_url="https://api.flyrouter.ai",
)

msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(msg.content[0].text)

With or without /v1

The OpenAI SDK takes https://api.flyrouter.ai/v1 (with /v1). The Anthropic and Gemini SDKs take https://api.flyrouter.ai (without /v1) and add the path themselves. Getting this wrong is the most common cause of a 404.

Next steps

FlyRouter

One key, every top AI model