Documentation
Connect, pay, read the bill
Everything needed before and after you pay: which route serves which models, how to pass the key, how the bill is computed, and what each error means.
GTokens is a gateway to frontier models, billed per token at published rates. You keep the client library you already use; one key and a base URL change where it sends requests. We forward each request upstream, count the tokens it used and charge them to a prepaid balance. Nothing else about your setup changes.
Before you start
- A key. Keys are created in the account area — as many as you need — and look like
sk-sl-…: the prefix, then 43 random characters. A key is shown once, when it is created; copy the whole thing. - A balance. Prepaid, in dollars, shared by every key on the account. A request the balance cannot cover is refused with
402 payment_requiredand costs nothing. - Spend controls. Keys you can revoke yourself and, on request, a daily and a monthly ceiling in dollars on the account — a new account has none until you ask.
Two shapes, one key
The gateway speaks two API shapes. The OpenAI chat shape serves every model in the catalogue — text and image alike — and the native Messages API shape serves text models for the client libraries and agent runtimes built for it. Pick the route by the library you hold; the key is the same everywhere, passed as Authorization: Bearer sk-sl-….
| Route | Models | Base URL for the library |
|---|---|---|
POST /api/v1/chat/completions | Text and image | https://api.gtokens.io/api/v1 |
POST /api/v1/images | Image | https://api.gtokens.io/api/v1 |
POST /api/v1/messages | Text | https://api.gtokens.io |
Scroll the table horizontally for the base URL.
The model you name is the model that answers. A model listed as coming_soon is refused with 400, and a model whose pool is fully busy is refused with 503 — never served by something else. Refused requests cost nothing.
Everything in this section
Getting started
- Quickstart
- Three ways to send the first request, with code.
- FAQ
- Billing, credits, data, limits — asked and answered.
API Reference
- Overview
- Request and response shape shared by every route.
- Authentication
- One header, one key.
- Parameters
- Every field a request body accepts.
- Streaming
- Server-sent events and how they end.
- Limits
- Balance, ceilings, reserve, throughput.
- Errors
- Status codes, typed codes, bodies.
- Create a chat completion
- POST /api/v1/chat/completions
- Generate an image
- POST /api/v1/images
- Create a message
- POST /api/v1/messages
- List models
- GET /api/v1/models
- Get remaining credits
- GET /api/v1/credits
- Get current API key
- GET /api/v1/key
Guides
- Image generation
- Geometry, tiers, exact pixels and what a frame costs.
- Agent SDK
- Point an agent runtime at the gateway with two variables.
If none of this helped
Use the support form. We keep no record of your request contents, so describe in words what is happening: the route, the model, roughly when, and the error body if there was one.
The gateway address is https://api.gtokens.io — worth quoting if you are not sure the base URL took effect.
