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
- Sign in with your email and add funds to your wallet.
- Create an API key on the API Keys page. It starts with
sk-gt-and is shown once. - Set the base URL to
https://api.greentokens.io/v1for OpenAI SDKs, orhttps://api.greentokens.iofor Anthropic SDKs. - 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
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)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)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 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.
export ANTHROPIC_BASE_URL="https://api.greentokens.io"
export ANTHROPIC_AUTH_TOKEN="sk-gt-…"
claudeexport 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
| Method | Path | Notes |
|---|---|---|
| POST | /v1/chat/completions | OpenAI Chat Completions: streaming, tools, vision |
| POST | /v1/responses | OpenAI Responses, with streaming |
| POST | /v1/messages | Anthropic Messages: streaming, tools, prompt caching, thinking |
| POST | /v1/messages/count_tokens | Anthropic token counting. Free, never billed |
Images
| Method | Path | Notes |
|---|---|---|
| POST | /v1/images/generations | Sync, streamed (stream: true) or async (Prefer: respond-async) |
| POST | /v1/images/edits | Multipart image edits |
| GET | /v1/images/jobs/{id} | Async job status; /content for the finished image |
Video
| Method | Path | Notes |
|---|---|---|
| POST | /v1/videos | Create 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)
| Method | Path | Notes |
|---|---|---|
| GET | /v1/models | Model list (OpenAI shape; Anthropic shape with an anthropic-version header) |
| GET | /v1/models/pricing | Prices per SKU, with the official price and savings |
| GET | /v1/status | Per-model status and 90 days of uptime |
Errors
OpenAI routes return {"error": {"message", "type", "code"}}; Anthropic routes return {"type": "error", "error": {"type", "message"}}.
| Status | Meaning |
|---|---|
| 400 | Invalid request |
| 401 | Missing, invalid, paused or revoked key |
| 402 | Insufficient balance, or the key's daily or monthly spend limit is reached |
| 403 | Model not allowed for this key, or account suspended |
| 404 | Unknown model or route |
| 409 | Idempotency conflict |
| 413 | Request too large |
| 502 · 503 · 504 | Upstream 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.