GreenTokens

Search

Search models, guides, docs and the FAQ.

Docs

Build with GreenTokens

GreenTokens speaks the OpenAI and Anthropic API formats. Point your SDK or tool at our base URL, use a GreenTokens key, and your existing code keeps working.

Quickstart

  1. Sign in with your email and add funds to your wallet.
  2. Create an API key on the API Keys page. It starts with sk-gt- and is shown once.
  3. Set the base URL to https://api.greentokens.io/v1 for OpenAI SDKs, or https://api.greentokens.io for Anthropic SDKs.
  4. Use a model ID from the models page. Responses echo the same ID.

Authentication

Send your key in either header. Sending both with different keys is rejected with 401.

  • Authorization: Bearer sk-gt-… (OpenAI style)
  • x-api-key: sk-gt-… (Anthropic style)

Every response carries an x-request-id header. Include it when you contact support.

SDK examples

Python · OpenAI SDK
from openai import OpenAI

client = OpenAI(base_url="https://api.greentokens.io/v1", api_key="sk-gt-…")

response = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
TypeScript · OpenAI SDK
import OpenAI from "openai"

const client = new OpenAI({ baseURL: "https://api.greentokens.io/v1", apiKey: "sk-gt-…" })

const response = await client.chat.completions.create({
  model: "claude-sonnet-5",
  messages: [{ role: "user", content: "Hello" }],
})
console.log(response.choices[0].message.content)
Python · Anthropic SDK
from anthropic import Anthropic

client = Anthropic(base_url="https://api.greentokens.io", api_key="sk-gt-…")

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
curl
curl https://api.greentokens.io/v1/chat/completions \
  -H "Authorization: Bearer sk-gt-…" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-sonnet-5", "messages": [{"role": "user", "content": "Hello"}]}'

Coding tools

Tools that read the standard environment variables work without other changes.

Claude Code
export ANTHROPIC_BASE_URL="https://api.greentokens.io"
export ANTHROPIC_AUTH_TOKEN="sk-gt-…"
claude
Codex CLI, opencode and other OpenAI-compatible tools
export OPENAI_BASE_URL="https://api.greentokens.io/v1"
export OPENAI_API_KEY="sk-gt-…"

Endpoints

Every route also works without the /v1 prefix, except video, which is /v1 only.

Text

MethodPathNotes
POST/v1/chat/completionsOpenAI Chat Completions: streaming, tools, vision
POST/v1/responsesOpenAI Responses, with streaming
POST/v1/messagesAnthropic Messages: streaming, tools, prompt caching, thinking
POST/v1/messages/count_tokensAnthropic token counting. Free, never billed

Images

MethodPathNotes
POST/v1/images/generationsSync, streamed (stream: true) or async (Prefer: respond-async)
POST/v1/images/editsMultipart image edits
GET/v1/images/jobs/{id}Async job status; /content for the finished image

Video

MethodPathNotes
POST/v1/videosCreate a video job (202). Accepts Idempotency-Key
GET/v1/videos/{id}Job status; /content streams the MP4 (kept 7 days)
DELETE/v1/videos/{id}Cancel a job

Public (no key)

MethodPathNotes
GET/v1/modelsModel list (OpenAI shape; Anthropic shape with an anthropic-version header)
GET/v1/models/pricingPrices per SKU, with the official price and savings
GET/v1/statusPer-model status and 90 days of uptime

Errors

OpenAI routes return {"error": {"message", "type", "code"}}; Anthropic routes return {"type": "error", "error": {"type", "message"}}.

StatusMeaning
400Invalid request
401Missing, invalid, paused or revoked key
402Insufficient balance, or the key's daily or monthly spend limit is reached
403Model not allowed for this key, or account suspended
404Unknown model or route
409Idempotency conflict
413Request too large
502 · 503 · 504Upstream failure or timeout

Slow responses may start with 200 and keepalives. A failure after that arrives as an error body (or an SSE error event) under the 200.