QuickstartAPI ReferenceTutorials

Public docs for evaluation and integration.

2-minute setup

API Quickstart Guide

Validate the integration path quickly. Most teams only need to change the base URL and API key.

Step 1

Get Your API Key

  1. Sign up for ToksHub and create your account
  2. Go to Dashboard → API Keys → Create New Key
  3. Copy your key (starts with sk-)

Step 2

Make Your First Request

Choose a language below.

cURL

Terminal
curl https://api.tokshub.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-key" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "Hello! What models do you support?"}
    ]
  }'

Python (OpenAI SDK)

Install
pip install openai
main.py
from openai import OpenAI

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

response = client.chat.completions.create(
    model="gpt-4.1",
    messages=[
        {"role": "user", "content": "Hello! What models do you support?"}
    ],
)

print(response.choices[0].message.content)

TypeScript (OpenAI SDK)

Install
npm install openai
index.ts
import OpenAI from "openai";

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

const response = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [
    { role: "user", content: "Hello! What models do you support?" },
  ],
});

console.log(response.choices[0].message.content);

Step 3

Streaming Responses

Enable real-time token streaming.

stream.py
from openai import OpenAI

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

stream = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Write a short poem about APIs"}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Step 4

List Available Models

See the models available to your key.

Terminal
curl https://api.tokshub.com/v1/models \
  -H "Authorization: Bearer sk-your-key"
API Quickstart — ToksHub