Getting started
Quickstart
Create an API key, then send your first request with curl, Python or Node, stream tokens as they arrive and list every model your key can call.
On this page
This page takes you from zero to a working response. You will use the same key for every model, through either the OpenAI-compatible or the Anthropic-compatible endpoint. Pick whichever SDK you already know.
1. Create an account#
Sign up with your email. New accounts start at $0; add at least $3 of prepaid credit on the billing page before your first request (top-ups are $3 or more). Pay as you go needs no subscription and nothing renews automatically;optional plans are opening soon (see pricing).
2. Create and store a key#
- Open API keys in the console.
- Create a key. Give it a name per app or machine so you can revoke one without breaking the others. You can also set a spending cap per key.
- Copy the key. It starts with
sk-.
Store it in an environment variable instead of pasting it into code. The examples below read RELAYKIT_API_KEY.
export RELAYKIT_API_KEY="sk-your-key"# Current window only
$env:RELAYKIT_API_KEY = "sk-your-key"
# Persist for new terminals (then open a new window)
setx RELAYKIT_API_KEY "sk-your-key"echo 'export RELAYKIT_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrc3. Send your first request#
The OpenAI-format base URL is https://api.oneaiapikey.com/v1. The Anthropic-format base URL is https://api.oneaiapikey.com (no /v1, because the Anthropic SDK adds it). Both accept the same key.
curl https://api.oneaiapikey.com/v1/chat/completions \
-H "Authorization: Bearer $RELAYKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"messages": [{"role": "user", "content": "Explain what an API gateway does in one sentence."}]
}'import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.oneaiapikey.com/v1",
api_key=os.environ["RELAYKIT_API_KEY"],
)
resp = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Explain what an API gateway does in one sentence."}],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.oneaiapikey.com/v1",
apiKey: process.env.RELAYKIT_API_KEY,
});
const resp = await client.chat.completions.create({
model: "gpt-5.6-terra",
messages: [{ role: "user", content: "Explain what an API gateway does in one sentence." }],
});
console.log(resp.choices[0].message.content);import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.oneaiapikey.com", # no /v1 here
api_key=os.environ["RELAYKIT_API_KEY"],
)
msg = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=512,
messages=[{"role": "user", "content": "Explain what an API gateway does in one sentence."}],
)
print(msg.content[0].text)$body = @{
model = "gpt-5.6-terra"
messages = @(@{ role = "user"; content = "Explain what an API gateway does in one sentence." })
} | ConvertTo-Json -Depth 5
$resp = Invoke-RestMethod -Method Post -Uri "https://api.oneaiapikey.com/v1/chat/completions" `
-Headers @{ Authorization = "Bearer $env:RELAYKIT_API_KEY" } `
-ContentType "application/json" -Body $body
$resp.choices[0].message.contentA successful call returns JSON with the model's reply plus a usage object that shows exactly how many tokens you were charged for. To try a different model, change only the model field. Claude models also work through the OpenAI endpoint, so you can compare gpt-5.6-terra and claude-sonnet-5-5 without switching SDKs.
4. Stream the response#
Streaming sends tokens as soon as they are generated, so users see output immediately. It is also the most reliable way to run long generations: idle non-streaming connections can be closed by proxies after about 100 seconds, while a stream keeps the connection active.
curl -N https://api.oneaiapikey.com/v1/chat/completions \
-H "Authorization: Bearer $RELAYKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Write a haiku about latency."}]
}'stream = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Write a haiku about latency."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)const stream = await client.chat.completions.create({
model: "gpt-5.6-terra",
messages: [{ role: "user", content: "Write a haiku about latency." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}with client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about latency."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)5. List available models#
GET /v1/models returns every model id your key can call. Use these exact ids in the model field. Prices per million tokens are on the models page.
curl https://api.oneaiapikey.com/v1/models \
-H "Authorization: Bearer $RELAYKIT_API_KEY"for model in client.models.list():
print(model.id)for await (const model of client.models.list()) {
console.log(model.id);
}{
"object": "list",
"data": [
{
"id": "claude-sonnet-5-5",
"object": "model"
},
{
"id": "gpt-5.6-terra",
"object": "model"
}
]
}Use it in coding tools#
Coding agents and editors only need the base URL and your key. Tools that speak the Anthropic format (like Claude Code) use https://api.oneaiapikey.com; everything else uses https://api.oneaiapikey.com/v1.
- Claude CodeCLI · Anthropic format
- Codex CLICLI · OpenAI format
- CursorIDE · OpenAI format
- ClineExtension · OpenAI format
- Kilo CodeExtension · OpenAI format
- OpenCodeCLI · OpenAI format
- AiderCLI · OpenAI format
- ZedIDE · OpenAI format
If something fails#
- 401 Unauthorized: the key is missing, mistyped or revoked. Check that the environment variable is set in the same terminal.
- 404 Not Found: almost always the base URL. OpenAI SDKs need
/v1; Anthropic SDKs must not have it. - 403 or "insufficient quota": your balance or the key's spending cap is used up. Top up or raise the cap under API keys.
- Model not found: copy the id from
GET /v1/models. Ids are case-sensitive.
The full list, with fixes and a safe retry pattern, is in Errors & limits.
Next steps#
- API reference: every endpoint, header and field the gateway supports.
- Tool guides: exact settings for each coding tool.
- Models & rates: compare price and strengths before choosing a default model.