Crescendo Lab Docs Deploy
English
Sign up

Gateway quickstart

Get AI Gateway access, create a key, and point Claude Code, Codex, the OpenAI or Anthropic SDK, or curl at https://api.agentlab.cresclab.com. Copyable steps.

Last updated

Before you start#

  1. Open the Gateway Sign up in the Agent Lab console and open AI Gateway in your workspace. If the Gateway is not on yet, request access on the AI Gateway page and we turn it on for your workspace; the console page says the same.
  2. Create a key On the Get started tab, select Create API key and give it a name. The key is shown once; copy it now.
  3. Pick a client Follow one of the sections below. The console's Get started tab shows the same steps with your key and your workspace's models filled in.

Every example reads the key from the AGENTLAB_API_KEY environment variable:

bash
export AGENTLAB_API_KEY=<your API key>

Model names come from GET /v1/models, which lists auto and every model your workspace allows. The names below are examples.

Claude Code#

Claude Code speaks Anthropic Messages and adds /v1/messages itself, so its base URL has no /v1. It checks the model name before sending, so it keeps a Claude model name and asks for auto with a header.

bash
export ANTHROPIC_BASE_URL=https://api.agentlab.cresclab.com
export ANTHROPIC_AUTH_TOKEN=$AGENTLAB_API_KEY
export ANTHROPIC_MODEL=claude-sonnet-5-5
export ANTHROPIC_CUSTOM_HEADERS="X-AgentLab-Routing: auto"
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5
claude

Leave out the ANTHROPIC_CUSTOM_HEADERS line to always use the model you named. The haiku line sends Claude Code's small background calls to a cheap model.

Codex#

Codex speaks OpenAI Responses. Add a provider to ~/.codex/config.toml:

~/.codex/config.toml
model = "gpt-5.6-luna"
model_provider = "agentlab"

[model_providers.agentlab]
name = "Agent Lab"
base_url = "https://api.agentlab.cresclab.com/v1"
wire_api = "responses"
env_key = "AGENTLAB_API_KEY"
http_headers = { "X-AgentLab-Routing" = "auto" }

Then run it:

bash
codex

Remove the http_headers line to always use the model you named.

OpenAI SDK#

bash
pip install openai
python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.agentlab.cresclab.com/v1", api_key=os.environ["AGENTLAB_API_KEY"])
reply = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Hello"}],
)
print(reply.model, reply.choices[0].message.content)

reply.model is the model that answered.

Anthropic SDK#

bash
pip install anthropic
python
import os
from anthropic import Anthropic

client = Anthropic(base_url="https://api.agentlab.cresclab.com", api_key=os.environ["AGENTLAB_API_KEY"])
reply = client.messages.create(
    model="auto",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(reply.model, reply.content[0].text)

curl#

Chat Completions:

bash
curl https://api.agentlab.cresclab.com/v1/chat/completions \
  -H "Authorization: Bearer $AGENTLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "auto", "messages": [{"role": "user", "content": "Hello"}]}'

Anthropic Messages:

bash
curl https://api.agentlab.cresclab.com/v1/messages \
  -H "Authorization: Bearer $AGENTLAB_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "auto", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

OpenAI Responses:

bash
curl https://api.agentlab.cresclab.com/v1/responses \
  -H "Authorization: Bearer $AGENTLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "auto", "input": "Hello"}'

Tag requests#

To see spend by team, feature or customer, add the X-AgentLab-Metadata header with one JSON object of string values, such as {"team": "support"}. It works with every endpoint above. See tags for the limits and where they show up.

Check it worked#

Open AI Gateway › Usage in the console. The request is listed with its key, the model that answered and its cost. If a request was refused, its code is in Errors.