Get started
Quickstart
In short: The quickstart is a five-minute walkthrough: create a key, send a request with curl, Python or Node, stream tokens and list the models your key can call.
On this page
This quickstart is a walkthrough from zero to a working response. The same key works for every model, through either the OpenAI-compatible or the Anthropic-compatible endpoint. Pick whichever SDK you already know.
How do I create an account (step 1)?#
Sign up with your Google account; that is all it takes to create an account. New accounts receive $10 of sign-up creditonce; it pays for every model, including the paid models in the examples below. To test at no cost, use an id from the free models page. When the balance reaches $0, add a top-up in any amount. Top-ups are prepaid credits from the console; there is no subscription and nothing renews automatically.
How do I create and store a key (step 2)?#
Create a key under Keys in the console, then keep it in an environment variable instead of in your code.
- Open the console and go to Keys.
- 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 ONEAIAPIKEY_API_KEY.
export ONEAIAPIKEY_API_KEY="sk-your-key"# Current window only
$env:ONEAIAPIKEY_API_KEY = "sk-your-key"
# Persist for new terminals (then open a new window)
setx ONEAIAPIKEY_API_KEY "sk-your-key"echo 'export ONEAIAPIKEY_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrcHow do I send my first request (step 3)?#
Send the request to one of two base URLs. 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 $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna:free",
"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["ONEAIAPIKEY_API_KEY"],
)
resp = client.chat.completions.create(
model="gpt-6-luna:free",
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.ONEAIAPIKEY_API_KEY,
});
const resp = await client.chat.completions.create({
model: "gpt-6-luna:free",
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["ONEAIAPIKEY_API_KEY"],
)
msg = client.messages.create(
model="qwen-qwen3.8-27b:free",
max_tokens=512,
messages=[{"role": "user", "content": "Explain what an API gateway does in one sentence."}],
)
print(msg.content[0].text)$body = @{
model = "gpt-6-luna:free"
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:ONEAIAPIKEY_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-6-luna:free and qwen-qwen3.8-27b:free without switching SDKs.
How do I stream the response (step 4)?#
To stream a response, set stream: true; tokens are then sent as soon as they are generated, so users see output immediately. Streaming 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 $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna:free",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Write a haiku about latency."}]
}'stream = client.chat.completions.create(
model="gpt-6-luna:free",
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-6-luna:free",
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="qwen-qwen3.8-27b:free",
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)How do I list available models (step 5)?#
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 $ONEAIAPIKEY_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": "qwen-qwen3.8-27b:free",
"object": "model",
"owned_by": "anthropic"
},
{
"id": "gpt-6-luna:free",
"object": "model",
"owned_by": "openai"
}
]
}How do I 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
What should I do if a request fails?#
Most failures come from the key, the base URL or the balance, so check these first:
- 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 in the console.
- 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.