# 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.

Source: https://oneaiapikey.com/docs/quickstart

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](https://oneaiapikey.com/console/sign-up) with your email. New accounts start at $0; add at least **$3** of prepaid credit on the [billing page](https://oneaiapikey.com/console/billing) 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](https://oneaiapikey.com/pricing)).

## 2. Create and store a key

1. Open [API keys](https://oneaiapikey.com/console/keys) in the console.
2. 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.
3. 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`.

macOS / Linux:

```bash
export RELAYKIT_API_KEY="sk-your-key"
```

PowerShell:

```powershell
# 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"
```

Git Bash:

```bash
echo 'export RELAYKIT_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrc
```

> **Keep keys server-side:** Anyone with your key can spend your balance. Never ship it inside a browser bundle or mobile app, never commit it to Git, and revoke it under [API keys](https://oneaiapikey.com/console/keys) straight away if it leaks.

## 3. 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:

```bash
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."}]
  }'
```

Python:

```python
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)
```

Node:

```js
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);
```

Anthropic SDK:

```python
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)
```

PowerShell:

```powershell
$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.content
```

A 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:

```bash
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."}]
  }'
```

Python:

```python
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)
```

Node:

```js
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 ?? "");
}
```

Anthropic SDK:

```python
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)
```

> **Rule of thumb:** Use `stream: true` for anything that may produce more than a few hundred tokens, for reasoning models and for agent loops. With `stream_options.include_usage` the final chunk carries the token usage.

## 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](https://oneaiapikey.com/models).

curl:

```bash
curl https://api.oneaiapikey.com/v1/models \
  -H "Authorization: Bearer $RELAYKIT_API_KEY"
```

Python:

```python
for model in client.models.list():
    print(model.id)
```

Node:

```js
for await (const model of client.models.list()) {
  console.log(model.id);
}
```

Response (shortened):

```json
{
  "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](https://oneaiapikey.com/docs/guides/claude-code)
- [Codex CLICLI · OpenAI format](https://oneaiapikey.com/docs/guides/codex-cli)
- [CursorIDE · OpenAI format](https://oneaiapikey.com/docs/guides/cursor)
- [ClineExtension · OpenAI format](https://oneaiapikey.com/docs/guides/cline)
- [Kilo CodeExtension · OpenAI format](https://oneaiapikey.com/docs/guides/kilo-code)
- [OpenCodeCLI · OpenAI format](https://oneaiapikey.com/docs/guides/opencode)
- [AiderCLI · OpenAI format](https://oneaiapikey.com/docs/guides/aider)
- [ZedIDE · OpenAI format](https://oneaiapikey.com/docs/guides/zed)

## 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](https://oneaiapikey.com/console/billing) or raise the cap under [API keys](https://oneaiapikey.com/console/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](https://oneaiapikey.com/docs/errors).

## Next steps

- [API reference](https://oneaiapikey.com/docs/api-reference): every endpoint, header and field the gateway supports.
- [Tool guides](https://oneaiapikey.com/docs/guides): exact settings for each coding tool.
- [Models & rates](https://oneaiapikey.com/models): compare price and strengths before choosing a default model.
