Quick Start

Make your first API call in minutes.

Prerequisites

  • An API Key from the dashboard
  • curl or any HTTP client

Step 1: Get Your API Key

  1. Visit the Portal
  2. Register or log in to your account
  3. Go to the API page
  4. Click Create API Key

Step 2: Make Your First Request

Use the OpenAI-compatible Chat Completions endpoint:

bash
curl https://tokencode.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Step 3: Use Streaming

Add "stream": true to the request body to enable streaming output:

bash
curl https://tokencode.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

Using the OpenAI SDK

The API is fully compatible with the OpenAI protocol — just change the base_url:

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://tokencode.dev/v1"
)

response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-your-api-key",
  baseURL: "https://tokencode.dev/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);

Using the Anthropic SDK

Call Claude models directly through the Anthropic protocol:

python
import anthropic

client = anthropic.Anthropic(
    api_key="sk-your-api-key",
    base_url="https://tokencode.dev"
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)

Next Steps