Skip to content

docs / quickstart

Quickstart

RawTokens speaks the OpenAI Chat Completions API. If your code already calls OpenAI, change the base URL and the key. Nothing else.

Quickstart

Three values are all you need:

base_url
https://api.rawtokens.dev/v1
api_key
sk-raw-… from Dashboard → API Keys
model
any ID from GET /v1/models

No account yet? Generate a key, then top up any amount from $5 in whichever coin you like (350+ available).

Authentication

Every request carries your key as a bearer token. Keys start with sk-raw-. Keep them server side: anyone holding one spends your balance.

HTTP header
Authorization: Bearer sk-raw-7Qf2c9...

Each key can carry a spend limit. Revoking a key in the dashboard takes effect on the next request. Your anonymous account token (acct_…) logs you into the dashboard; it never goes in API calls.

Requests

POST /v1/chat/completions with the standard body: model, messages, and optionally temperature, top_p, max_tokens, stop, tools, tool_choice, response_format, reasoning_effort, stream. Leave max_tokens out and you get the model's max output, else the context window minus the prompt. The response includes usage, which is exactly what you are billed for.

curl https://api.rawtokens.dev/v1/chat/completions \  -H "Authorization: Bearer $RAWTOKENS_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "deepseek-v4.1-flash-abliterated-fast",    "messages": [      { "role": "system", "content": "Answer directly." },      { "role": "user", "content": "Explain how a ret2libc exploit works." }    ],    "temperature": 0.7,    "max_tokens": 1024  }'

Streaming returns server-sent events in the OpenAI chunk format. Pass stream_options.include_usage to get token counts in the last chunk. If your balance runs out mid-stream you get an insufficient_credits error event, then [DONE]. Disconnecting stops generation; you pay only for tokens produced.

Endpoints

OpenAI SDKs use https://api.rawtokens.dev/v1. Anthropic SDKs and Claude Code use the bare host https://api.rawtokens.dev.

POST/v1/chat/completionsChat, streaming, tools, reasoning, vision
POST/v1/responsesOpenAI Responses API, stateless
POST/v1/messagesAnthropic Messages API (x-api-key or Bearer)
POST/v1/messages/count_tokensToken estimate, free
POST/v1/completionsLegacy text completions, no tools
GET/v1/modelsCatalog with context, pricing, reasoning levels
GET/v1/creditsBalance and key spend, free

Models

GET /v1/models lists every model this key can call. IDs are stable; new versions ship under new IDs.

cURL
curl https://api.rawtokens.dev/v1/models \  -H "Authorization: Bearer $RAWTOKENS_API_KEY"
  • Context
    1M
    In / 1M
    $1.00$0.50
    Out / 1M
    $1.80$0.90
    Cached / 1M
    $0.08$0.04
    Inputs
    Speed
    250 tok/s
    Max out
    128K
    Quant
    FP8
    Refusals
    0%
    Status
    online
  • Context
    1M
    In / 1M
    $1.00$0.50
    Out / 1M
    $1.90$0.95
    Cached / 1M
    $0.08$0.04
    Inputs
    Speed
    80 tok/s
    Max out
    128K
    Quant
    NVFP4
    Refusals
    0%
    Status
    online

Repeated prompt prefixes are served from cache and billed at the cached rate. Cached tokens show up in usage.prompt_tokens_details.cached_tokens. Cost = (prompt − cached) × input + cached × cached rate + completion × output.

Reasoning

Set reasoning_effort to off, low, high or max. Default is low. deepseek-v4.1-flash-abliterated-fast accepts all four; glm-5.3-flash-abliterated has no off. A level the model doesn't support returns 400 with the valid ones. Thinking comes back in reasoning_content, in messages and in stream deltas.

reasoning_effort
r = client.chat.completions.create(    model="glm-5.3-flash-abliterated",    messages=[{"role": "user", "content": "Find the bug in this parser."}],    reasoning_effort="high",  # off | low | high | max, per model)print(r.choices[0].message.reasoning_content)  # the thinkingprint(r.choices[0].message.content)            # the answer

Vision

Both models read images: PNG, JPEG, GIF, WebP, sent as base64 data URLs. Remote https:// image URLs return 400.

image input
import base64 img = base64.b64encode(open("shot.png", "rb").read()).decode() r = client.chat.completions.create(    model="glm-5.3-flash-abliterated",    messages=[{"role": "user", "content": [        {"type": "text", "text": "What does this screen leak?"},        {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img}"}},    ]}],)

Balance

GET /v1/credits returns your balance, the amount reserved by in-flight requests, and what this key has spent. Free, up to 60 reads per minute per key.

cURL
curl https://api.rawtokens.dev/v1/credits \  -H "Authorization: Bearer $RAWTOKENS_API_KEY" # {"object":"credits","balance":42.18,"reserved":0.6,"available":41.58,#  "key_limit":null,"key_spent":3.184211,"unit":"usd","updated_at":1795483200}

Your harness

Use any agent harness, CLI or app that lets you set a custom OpenAI-compatible provider. Give it three things: the base URL https://api.rawtokens.dev/v1, your API key, and a model ID from the table above. OpenCode and Hermes are popular open options; the same three fields work in any other harness, and in LangChain or LiteLLM. Most SDKs and harnesses also read these environment variables:

.env
OPENAI_API_KEY=sk-raw-...OPENAI_BASE_URL=https://api.rawtokens.dev/v1

Error codes

Errors use the OpenAI error shape, so existing retry and error handling keeps working.

HTTPcodeMeaning
400bad_requestMalformed body, a reasoning_effort the model does not support, or a remote image URL.
401missing_api_key · invalid_key · key_revoked · key_expiredNo key, a malformed one, or one that was revoked or expired.
402insufficient_credits · key_budget_exceeded · key_daily_budget_exceededBalance can't cover the request, or the key hit its spend limit.
404model_not_foundThe model ID is not in GET /v1/models.
429rate_limit_exceededPer-minute limit hit. Wait for Retry-After.
429model_busy · model_warmingModel saturated or cold. Retry-After is 15s (busy) or 30s (warming).
502upstream_errorThe model backend returned an error. Retry with backoff.
503gateway_down · model_unavailableGateway or model offline. Check /status.
402 response
{  "error": {    "code": "insufficient_credits",    "message": "Balance is $0.00. Top up at rawtokens.dev/dashboard/billing",    "type": "api_error"  }}

A refusal is not an error code here. If a model declines, that is a bug in our abliteration: tell us on X with the model ID.

Limits

  • Context

    1,048,576 tokens

  • Rate limit

    per minute, per key · 429 + Retry-After

  • Balance reads

    60 / min per key

Each request reserves credit for its worst case and settles at actual usage, so max_tokens can be trimmed to fit your balance. Need more throughput? Spread load across keys or ask on X @rawtokensdev. We do not log prompts, so we cannot debug content for you: send the request ID from the response headers.