Documentation

Quickstart

Tokenly speaks the OpenAI wire format — both chat/completions and the newer responses API. Anything that accepts a custom base URL — SDKs, IDE agents, CLIs — works out of the box.

1 · Base URL and auth

Create a key in the dashboard and send it as a Bearer token. Keys are stored as hashes and shown only once.

Base URL   https://www.tokenly.llc/api/v1
Header     Authorization: Bearer sk-...

2 · Make a call

curl https://www.tokenly.llc/api/v1/chat/completions \
  -H "Authorization: Bearer $TOKENLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "messages": [{"role": "user", "content": "Hello, Tokenly"}],
    "max_tokens": 512
  }'

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://www.tokenly.llc/api/v1",
    api_key="sk-...",  # your Tokenly key
)

reply = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello, Tokenly"}],
)
print(reply.choices[0].message.content)

Node.js

import OpenAI from "openai";

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

const reply = await client.chat.completions.create({
  model: "deepseek-v3-2",
  messages: [{ role: "user", content: "Hello, Tokenly" }],
  stream: true, // streaming is supported
});

Codex CLI

# ~/.codex/config.toml
[model_providers.tokenly]
name = "Tokenly"
base_url = "https://www.tokenly.llc/api/v1"
env_key = "TOKENLY_API_KEY"
wire_api = "responses"

[profiles.tokenly]
model_provider = "tokenly"
model = "deepseek-v3-2"

# then:
#   export TOKENLY_API_KEY=sk-...
#   codex --profile tokenly

3 · Pricing

Every response carries x-tokenly-credits-charged and x-tokenly-credits-remaining headers, plus a tokenly usage block in the JSON body.

ModelCredits / 1M inCredits / 1M out
Claude Sonnet 4.5claude-sonnet-4-53,60018,000
Claude Haiku 4.5claude-haiku-4-51,2006,000
DeepSeek V3.2deepseek-v3-2340500
GLM-4.6glm-4-67202,640
Kimi K2kimi-k27003,000

4 · When credits run out

Calls fail with 402 and a connection-error message pointing at the Earn portal. A request whose estimated cost exceeds your remaining balance fails the same way (code insufficient_credits), so a single call can never overdraw you by more than 25 credits. Complete a survey or watch a sponsored film, and the same key starts working again immediately — nothing to restart. The feed resets daily.

HTTP/1.1 402 Payment Required
{
  "error": {
    "message": "Connection error: your Tokenly credits are used up. Open the portal to earn more — a survey or two tops you back up: https://www.tokenly.llc/earn",
    "type": "insufficient_credits",
    "code": "credits_exhausted",
    "portal": "https://www.tokenly.llc/earn"
  }
}

Errors

StatusCodeMeaning
401missing_api_key / invalid_api_keyNo key, or the key is wrong or revoked.
402credits_exhausted / insufficient_creditsBalance is empty, or the request costs more than what remains — refill at /earn.
403model_not_allowed_for_keyKey is scoped to a different model.
404model_not_foundUnknown model id — see /api/v1/models.
400invalid_bodyMissing `model` or `messages`.