Quickstart
Get connected to tokgate.io in five minutes — create an API key, call your first AI model and connect your tools.
On this page
Before you start: choose the right protocol
tokgate.io is a unified AI model gateway. You manage one API key, but must select the request format by model vendor: Anthropic models use Anthropic Messages, Google models use the native Gemini format, and other LLMs use the OpenAI-compatible format. Image and video capabilities use dedicated endpoints; video APIs use asynchronous tasks.
Whether you call the API directly or use a client, the model vendor, request format and SDK must match. One request body cannot be used for every chat model.
Get connected in three steps
Step 1 — Get your API key
1.1 Sign in to the tokgate.io console
Open console.tokgate.io and sign in with email + password or a Google account. If you don't have an account yet, click "Sign up free"; the registration method is determined by the platform's current policy:
- Open registration: enter your email → click "Get verification code" → enter the code from the email → set a password.
- Invite registration: an invite code is required.
- Registration requires agreeing to the Terms of Service and the Privacy Policy.
1.2 Create an API key
After signing in, go to "Keys & Resources › API Keys" in the left navigation and click "Create key" in the upper right. The dialog lets you configure:
| Field | Required | Description |
|---|---|---|
| Name | Required | Naming by environment is recommended, e.g. production or local-dev. |
| Billing mode | Optional | All calls use Credits billing and deduct from the Credits balance; there is no choice between plan Credits and a cash balance. When the console hides this field, the default Credits mode applies. |
| Spending quota ($) | Optional | The maximum cumulative amount this key may spend; the key is automatically deactivated once reached, without affecting other keys. Leave blank for no limit. |
| Rate limit (RPM) | Optional | Maximum requests per minute. Leave blank for no limit. |
| Model whitelist | Optional | Restrict which models this key may call (multi-select). Leave blank for no restriction. |
| Expiry | Optional | Automatically deactivated after expiry; a past time cannot be selected. Leave blank for permanent validity. |
1.3 Save your API key
After submitting, a "Key created" dialog appears. The plaintext key starts with sk- — click the copy button next to it to copy it.
Plaintext is shown only onceYou cannot view the plaintext again after closing the dialog; the list shows only the prefix plus a mask. Save it immediately to a password manager or a secrets hosting service. If lost, the key can only be deleted and recreated.
Isolate keys by environmentUse separate keys for production, staging and local development, each with its own spending quota and RPM. If any key leaks, delete it in the console and the other environments stay unaffected. Never commit keys to a code repository or expose them in the frontend.
Step 2 — Make your first API call
Choose the protocol by model vendor first. This section uses a DeepSeek model to demonstrate the OpenAI-compatible format. For Anthropic and Google models, use Anthropic Messages and the native Gemini format respectively; do not reuse the request body below.
2.1 List available models
Browse all models in the Model Catalog, or filter by vendor, check context lengths and USD unit prices, and copy model IDs with one click on the console's "Models › Model Catalog" page. To fetch them dynamically in code, call the models endpoint directly:
curl https://api.tokgate.io/v1/models \
-H "Authorization: Bearer sk-***"
The id field in the response is the model name to pass when calling.
2.2 Make your first request
curl https://api.tokgate.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello, introduce yourself"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.tokgate.io/v1",
)
response = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[{"role": "user", "content": "Hello, introduce yourself"}],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TOKGATE_API_KEY,
baseURL: "https://api.tokgate.io/v1",
});
const response = await client.chat.completions.create({
model: "deepseek-v4-pro",
messages: [{ role: "user", content: "Hello, introduce yourself" }],
});
console.log(response.choices[0].message.content);
package main
import (
"context"
"fmt"
openai "github.com/sashabaranov/go-openai"
)
func main() {
cfg := openai.DefaultConfig("sk-***")
cfg.BaseURL = "https://api.tokgate.io/v1"
client := openai.NewClientWithConfig(cfg)
resp, err := client.CreateChatCompletion(context.Background(),
openai.ChatCompletionRequest{
Model: "deepseek-v4-pro",
Messages: []openai.ChatCompletionMessage{
{Role: "user", Content: "Hello, introduce yourself"},
},
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}
Try it in the browser firstIf you don't want to write code, use the console's "Models › Playground": pick a model and a key, tune temperature and max output tokens, and see streaming responses instantly.
Step 3 — Connect your tools
Your client or SDK must support the protocol required by the target model. All three protocols share one API key, but their base URLs, paths and request bodies differ:
| Parameter | Value |
|---|---|
| API endpoint (by protocol) | OpenAI: https://api.tokgate.io/v1Anthropic: https://api.tokgate.ioGemini: https://api.tokgate.io/v1beta |
| API Key | A key starting with sk-, created on the console's "API Keys" page |
| Model name | Query via GET /v1/models, or copy a model ID from the Model Catalog |
Claude Code / Codex CLI
Configure these command-line coding assistants using environment variables. Claude Code uses the Anthropic protocol, while Codex CLI uses the OpenAI protocol.
# Claude Code (Anthropic protocol)
export ANTHROPIC_BASE_URL="https://api.tokgate.io"
export ANTHROPIC_AUTH_TOKEN="sk-***"
# Codex CLI (OpenAI protocol)
export OPENAI_BASE_URL="https://api.tokgate.io/v1"
export OPENAI_API_KEY="sk-***"
Desktop clients such as Cherry Studio
- Open "Settings › Model Providers › Add Provider".
- The provider type must match the model vendor: Anthropic for Anthropic models, Gemini for Google models, and OpenAI-compatible for other LLMs.
- Use the matching base URL from the table above and the same API key created in the console.
- Add the model IDs you want to use (from
GET /v1/modelsor the Model Catalog).
Other clients and SDKs
Whether LangChain, LlamaIndex, Vercel AI SDK, Dify, FastGPT, NextChat or LobeChat can connect depends on support for the target model protocol and a custom base URL. Use the matching OpenAI, Anthropic or Google Gen AI SDK; do not call Anthropic or Google models with an OpenAI request body. With the Google Gen AI SDK you must also override the x-goog-api-key header it sends by default with Authorization: Bearer, otherwise the request returns 401.
Account & billing
The platform uses a single Credits-based billing mode. Fixed USD top-ups are converted at 1 USD = 200 Credits, and Credits are deducted for each call at the model’s published rate.
| Mode | Fund form | How to get it | Best for |
|---|---|---|---|
| Credits billing | Credits balance | Choose a fixed USD amount; 1 USD = 200 Credits | All model calls, deducted at published unit prices |
- Top up Credits: open "Billing Center › Credits & Orders", choose one of the fixed USD amounts shown and complete payment. Credits arrive at 1 USD = 200 Credits.
- No bonus ratio: Credits use only the fixed conversion rate; larger top-up tiers do not add bonus Credits.
- Transactions & orders: Credits transactions record top-ups, call deductions, fees, holds, settlements and releases; the orders page shows order number, amount, platform fee, channel and payment status.
- Unit price basis: the Model Catalog lists four unit prices per model — input, output, cache read and cache write — in "USD / per million tokens". Prices differ by model; actual deductions follow the console details.
Usage & Reports
In the console's "Billing Center › Usage & Reports" you can see:
- Summary cards: total requests, total tokens, total Credits consumed and the current Credits balance.
- Reports use UTC and cover the last 30 days by default. Group results by date to view trend charts, or by model or key to view sortable tables.
- Call details (in local time): time, model, key prefix, input tokens, output tokens, Credits consumed, latency (ms) and success/failure status, filterable by time range and model.
- CSV export: export usage data under the current filters with one click for your own reconciliation.
Data settlement delayWhen a "current usage information may be incomplete" notice appears at the top of the page, part of the usage is still being settled and the figures shown may differ from the final bill — refresh again later.
Console feature map
| Group | Page | Purpose |
|---|---|---|
| Workspace | Overview | Available quota, active key count, requests in the last 24h, 7-day usage trend and model consumption breakdown |
| Models | Model Catalog | Filter by vendor, search models, view context lengths, capability tags and the four unit prices, and copy model IDs |
| Playground | Chat online with adjustable system prompt, Temperature, Top P, frequency penalty and max output tokens, and choose which key to use | |
| Keys & Resources | API Keys | Create / edit / enable / disable / delete keys, and view spending quota progress and expiry |
| Billing Center | Credits & Orders | Top up Credits and view transactions and orders |
| Usage & Reports | Usage summary, multi-dimensional reports, call details and CSV export | |
| Notifications | Announcements | Platform changes, model launches/retirements and maintenance notices |
API capabilities at a glance
| Capability | Endpoint | Description |
|---|---|---|
| Chat completions (OpenAI format) | POST /v1/chat/completions | Multi-turn conversation with streaming, tool calling and structured output |
| Messages (Anthropic format) | POST /v1/messages | For Anthropic models only; supports system prompts, tool use and streaming events |
| Content generation (Gemini format) | POST /v1beta/models/{model}:generateContent | For Google models only; uses Gemini-native contents / parts structures |
| Gemini image generation / editing | POST /v1beta/models/{model}:generateContent | Native Gemini contents / parts and generationConfig |
| GPT Image text-to-image | POST /v1/images/generations | Native OpenAI GPT Image request body |
| GPT Image editing | POST /v1/images/edits | multipart/form-data with source images and an optional mask |
| Seedream | POST /api/v3/images/generations | Native Volcano Engine parameters for text-to-image, image-to-image and interactive editing |
| Qwen Image | POST /api/v1/services/aigc/multimodal-generation/generation | Native Alibaba Cloud Model Studio input.messages + parameters structure |
| Seedance | POST /api/v3/contents/generations/tasksGET /api/v3/contents/generations/tasks/{provider_task_id} | Submit through the vendor-native path, then poll task status and output by task ID |
| HappyHorse | POST /api/v1/services/aigc/video-generation/video-synthesisGET /api/v1/tasks/{task_id} | Submit with the required async header and query task status and output by task ID |
| Model list | GET /v1/models | Query the models callable by the current key |
For full parameters, response structures and error codes, see the API Reference.
FAQ
How do I know which models are available to me?
Three ways: call GET /v1/models (which returns the models actually available to the current key); browse and copy model IDs in the console's "Model Catalog"; or check the Model Catalog on the website. If you set a model whitelist when creating the key, models outside the whitelist will not appear in that key's available list.
How to troubleshoot a 401 Unauthorized?
- Does the auth header match the protocol? OpenAI and Gemini use
Authorization: Bearer ..., while Anthropic usesx-api-key. - Was the key copied in full (the plaintext is shown only once — a truncated key keeps returning 401)?
- Has the key been deleted, disabled or expired?
- Did you mistake the console login session for API authentication? Model endpoints only accept API keys, not login cookies.
- When calling Gemini native endpoints, did you accidentally send
x-goog-api-key? Its presence alone returns401, even alongside a validAuthorization: Bearerheader. Google's official Gen AI SDK sends it by default and must be overridden.
How to troubleshoot a 403 Forbidden?
This is usually a scope issue: the key has a model whitelist and the requested model is not in it, or the model is not enabled for your account. Edit the whitelist on the console's "API Keys" page, or switch to a key without model restrictions.
Getting a 402 / insufficient quota message?
Your Credits balance is insufficient, or this key's spending quota has been used up. For the former, top up Credits under "Credits & Orders"; for the latter, edit the key to raise the quota. A key running out of quota affects only that key, not other keys on the account.
Getting a 429 Too Many Requests?
You hit the key's RPM rate limit or an upstream concurrency cap. Implement exponential backoff retries on the client (e.g. 1s, 2s, 4s with a maximum retry count) and raise the key's RPM as needed. For sustained high concurrency, contact our business team for an assessment.
Seeing "key invalid or does not match the current gateway environment"?
Keys are bound to a gateway environment. Production uses api.tokgate.io; protocol roots are OpenAI /v1, the Anthropic SDK root without /v1, and Gemini /v1beta.
How to set timeouts for long-running generations?
Image generation takes significantly longer than chat. For chat, enable streaming (stream: true) to improve time-to-first-token; images return synchronously, so don't set the client timeout too short. Video APIs use asynchronous tasks: save the task ID after submission and poll for status instead of waiting on a long-lived connection. See the image and video docs for details.
Where can I find the full parameter documentation?
The API Reference provides field-by-field request/response documentation with runnable examples, split into chat, image and video. Still have questions? Reach us via the contact page.