GateRouter API Reference

Call text, image, video, speech and music models with one API key. Text uses the standard Chat Completions format; media runs as async tasks.

Getting started

An API is how a program sends a question to an AI and gets the answer back. Follow the five steps below and you'll get your first answer in about ten minutes, even with little coding experience.

Create an account

Sign up and confirm your email with the link we send. Verified accounts get $5 in trial credits, so you can test without topping up.

Try it without code

Open Playground in the console, pick a model, and send a message. Find a model you like there, then move to code.

Create an API key

Create a key under API Keys in the console. The full key (starting with sk_) is shown only once, so copy it somewhere safe right away. Treat it like a password.

Make your first call

Pick whichever is easiest for you. In every example, replace sk_YOUR_KEY with the key you copied in step 3.

Option A. Python (recommended)

  1. Install Python from python.org (it may already be on your Mac).
  2. In a terminal (Command Prompt on Windows), run: pip install openai
  3. Save the code below as hello.py and paste in your key.
  4. Run python hello.py and the AI's answer is printed.
hello.py
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gaterouter.net/v1",
    api_key="sk_YOUR_KEY",  # ← replace with the key from the console
)

resp = client.chat.completions.create(
    model="glm-5.3",
    messages=[{"role": "user", "content": "Hi! Introduce yourself in one line"}],
)
print(resp.choices[0].message.content)

Option B. Mac or Linux terminal

Nothing to install: paste this into Terminal and press Enter.

Terminal
curl https://api.gaterouter.net/v1/chat/completions \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.3", "messages": [{"role": "user", "content": "Hi!"}]}'

Option C. Windows PowerShell

The curl command above doesn't work as-is on Windows. Open PowerShell from the Start menu and paste this instead.

PowerShell
$headers = @{ Authorization = "Bearer sk_YOUR_KEY" }
$body = @{
  model    = "glm-5.3"
  messages = @(@{ role = "user"; content = "Hi!" })
} | ConvertTo-Json -Depth 5
$res = Invoke-RestMethod -Uri "https://api.gaterouter.net/v1/chat/completions" -Method Post `
  -Headers $headers -ContentType "application/json; charset=utf-8" `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$res.choices[0].message.content

Read the result

The response comes back as JSON. Two places matter: choices[0].message.content is the AI's answer, and usage is how much you used (tokens). See what it cost under Usage in the console.

Example response (annotated)
{
  "model": "glm-5.3",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hi! I'm an AI assistant that answers your questions."   ← the AI's answer
      },
      "finish_reason": "stop"   ← the answer finished normally
    }
  ],
  "usage": {
    "prompt_tokens": 12,        ← size of what you sent
    "completion_tokens": 18,    ← size of the answer
    "total_tokens": 30          ← what you're billed on
  }
}
Next: change the model value to use another model (see Supported models below). Images, video and audio work a little differently; see Media tasks. Stuck? Check Troubleshooting below.

Key terms

API
An agreed way for programs to talk. Here, it's how your program sends a question to GateRouter and gets the answer.
API key
A secret that proves a request comes from your account. Charges go to the key's account.
Base URL
The address every request starts with: https://api.gaterouter.net
Endpoint
The feature-specific path after the Base URL, e.g. /v1/chat/completions for chat.
Model
The AI that produces the answer. Choose it by putting a model ID (e.g. glm-5.3) in the model field.
Token
The unit AI uses to count text (roughly ¾ of an English word). You pay by the tokens you send and receive.
JSON
A data format shaped like {"key": "value"}. Both requests and responses use it.
Streaming
With "stream": true, the answer arrives piece by piece as it is written instead of all at once.
Async task
Slow jobs like video are submitted first to get a task ID; you then check that ID until it's done.
Status code
The response's result number: 200 is success, 4xx means a problem with the request, 5xx a problem on the server.

Prompt guide

How to write prompts for each kind of model. The console Playground shows the guide for whichever model you pick, with examples you can insert.

Images · Seedream

Say what to draw, where, and in what style, in that order. The more specific, the closer the result.

Write it in this order: Subject (what) + Details (look, clothing, materials) + Background and place + Style (photo, illustration, 3D…) + Lighting and color + Framing (close-up, full body, top-down…)
  1. For text in the image, put the exact words in double quotes: a cafe sign that reads "SEASIDE CAFE"
  2. Be explicit about style: product photo, watercolor illustration, 3D render, film photo, flat vector.
  3. Match the aspect ratio to the use: 1:1 for feeds, 9:16 for stories, 16:9 for banners and thumbnails.
  4. Say what you want rather than what you don't: 'empty street' instead of 'no people'.
Seedream 5.0
2K, 3K or 4K, priced per image.
Seedream 5.0 Pro
1K or 2K, priced by output pixel count. Draft at 1K, then redo the keeper at 2K.
Note
A reference image URL makes the result follow its subject, product or mood.
Product shot
Product photo of a matte black ceramic coffee mug on a light oak table, soft morning window light, shallow depth of field, minimal Scandinavian kitchen background, high detail
Poster with text
Minimal concert poster, bold sans-serif title that reads "SUMMER NIGHTS", neon pink and deep blue gradient sky, silhouette of a crowd with raised hands, grainy print texture
Character illustration
Watercolor illustration of a small fox wearing a yellow raincoat, standing under a red umbrella on a rainy village street, warm lamp light, children's book style

Video · Seedance

For video, describe how things move, not just what's there.

Write it in this order: Subject (who or what) + Action (how it moves) + Camera (how it's filmed) + Setting and mood + Style and lighting
  1. Describe motion with concrete verbs: not 'the sea' but 'waves crash against the rocks and burst into white foam'.
  2. Name the camera move: slow push-in, tracking shot, aerial drone shot, static shot, orbit.
  3. Keep a 5-second clip to one or two actions; several scenes in one prompt blend awkwardly.
  4. With a start image, don't re-describe what's in it; describe only what moves and how.
  5. English prompts are often the most reliable.
Seedance 2.0 Mini Special
720p only and the cheapest. Use it to iterate on a prompt.
Seedance 2.0 Special
720p up to 2K and 4K. Once a draft works, render the same prompt at high resolution.
Seedance 2.5 models
720p or 1080p (Discount and Official Relay also 480p), billed per second, so longer clips cost more.
Seedance 2.5 Flash Special
720p only and the cheapest 2.5 model per second; good for trying 2.5 quality cheaply. (Flash Discount: 480p or 720p.)
Note
A start image (first frame) pins the opening shot exactly.
Drone landscape
Aerial drone shot slowly flying forward over a turquoise coastline at sunrise, waves rolling onto white sand, gentle mist, cinematic, golden light
Product spin
A sleek silver wristwatch slowly rotates on a black reflective pedestal, a thin light streak sweeps across the dial, static camera, studio lighting, dark background
Person in motion
A young woman in a red coat walks through a snowy city street at night and turns to smile at the camera, tracking shot, warm shop lights, falling snow

Video · Kling

Same formula as other video models; add camera direction plus emotion and expression.

Write it in this order: Subject (who or what) + Action (how it moves) + Camera (how it's filmed) + Setting and mood + Style and lighting
  1. Describe motion with concrete verbs: not 'the sea' but 'waves crash against the rocks and burst into white foam'.
  2. Name the camera move: slow push-in, tracking shot, aerial drone shot, static shot, orbit.
  3. Keep a 5-second clip to one or two actions; several scenes in one prompt blend awkwardly.
  4. For people, add expression and emotion: 'smiles softly, eyes full of relief'.
Kling O3
a fixed price per clip, so length (3–15 s) doesn't change the price. 720p or 1080p.
Kling V3 Omni
720p, 1080p or 4K, billed per second.
Emotional moment
Close-up of an elderly man reading a handwritten letter by a window, his hands tremble slightly and he smiles softly with tears in his eyes, slow push-in, soft afternoon light
Action
A skateboarder kicks off down a sunlit concrete ramp and lands a jump, low-angle tracking shot, dust particles in the air, energetic, shallow depth of field

Video · Wan · HappyHorse · MiniMax · Videos

Use the common video formula: subject + action + camera + mood.

Write it in this order: Subject (who or what) + Action (how it moves) + Camera (how it's filmed) + Setting and mood + Style and lighting
  1. Describe motion with concrete verbs: not 'the sea' but 'waves crash against the rocks and burst into white foam'.
  2. Name the camera move: slow push-in, tracking shot, aerial drone shot, static shot, orbit.
  3. Keep a 5-second clip to one or two actions; several scenes in one prompt blend awkwardly.
  4. With a start image, don't re-describe what's in it; describe only what moves and how.
  5. English prompts are often the most reliable.
Note
HappyHorse Text to Video works from text alone; Image to Video needs a start image, so describe only the motion.
Wan 3.0
billed per second, 480p to 1080p depending on the model. Draft at a lower resolution to save cost.
MiniMax H3 and Videos 900 720p
a fixed price per clip.
City time-lapse
Time-lapse of a busy Seoul intersection at dusk, car light trails streaking through the frame, clouds moving fast overhead, static wide shot
Animate a photo
The person slowly turns their head toward the camera and blinks, hair moves gently in the breeze, subtle camera push-in

Text · chat models

Brief the model like a colleague: role, task, context and the format you want.

Write it in this order: Role (who should answer) + Task (what to do) + Context (situation, audience, material) + Output format (table, list, length, JSON) + Example (what a good answer looks like)
  1. Put role and tone in the system message so it holds across the conversation.
  2. Specify the format exactly: 'three-line summary', 'as a table', 'reply with JSON only'.
  3. One example of the answer you want stabilizes format and quality.
  4. For complex work, ask it to think step by step, or split the job into several requests.
Note
Flash models (GLM 5.3 Flash, DeepSeek Flash): cheapest and fastest. Try them first for high-volume work like classification, summaries and drafts.
Note
Pro and Max models (Kimi K3.1 Pro, Qwen 3.8 Max…): pricier; try them for harder writing and reasoning. Compare against a cheaper model on the same prompt.
Meeting summary
You are a meticulous assistant. Read the meeting notes below and organize them into a table: (1) decisions, (2) action items with owner and due date, (3) open questions.

[paste notes here]
Product copy
You are an e-commerce copywriter. For women in their 20s and 30s, write three friendly versions of a product blurb, two sentences each.

Product: gentle vegan moisturizing cream, 50 ml
Extract JSON
Extract the name, phone and ordered items from the sentence below. Reply only with JSON shaped {"name":"","phone":"","items":[]}.

Sentence: Hi, this is Jamie Lee, 555-0142, I'd like two white T-shirts and one pair of jeans.

Introduction

GateRouter puts many AI models behind one gateway. Text models use the OpenAI Chat Completions format, so existing OpenAI SDKs work by changing the base URL. Image, video, speech, music and digital-human models use an async submit-then-poll flow (Model Center).

Base URL

https://api.gaterouter.net
PurposeEndpoint
Text chatPOST /v1/chat/completions
List modelsGET /v1/models
Submit media taskPOST /v2/model-center/tasks
Query media taskGET /v2/model-center/tasks/{id}

Authentication

Send your API key in the Authorization header on every request. Create keys in the console under API Keys; the full value is shown only once, right after creation.

Authorization: Bearer sk_YOUR_KEY
Content-Type: application/json
Use keys only on your server — never in browser/app code or public repos. If a key leaks, revoke it in the console and create a new one.

Quick start

One API key covers text, images and video. Follow these four steps to make your first requests.

Get an API key

  1. Sign up and verify your email; trial credits are added once verified.
  2. Create a key under API Keys in the console.
  3. The key is shown only once, so save it somewhere safe right away.

Choose a model

Put a model ID below in the model field of your request. If you're new, start with the picks in this table. The full list and prices are in the Models section below and on the Models page of the console.

TypeSuggested model IDsNotes
Textdeepseek-v4.1-flash, glm-5.3, kimi-k3.1-pro, qwen3.8-maxChat, writing, code. deepseek-v4.1-flash is fast and cheap
Imageseedream-5.0, seedream_5.0ProText-to-image, editing from reference images
Videosd_2.0_mini_special, sd_2.5_flash_special, kling-v3-omni, wan3.0-video-c2Short clips from text or an image. sd_2.0_mini_special is the cheapest

Send requests

Text generation

Text answers come back right away. The OpenAI SDKs work by changing the base URL.

cURL
curl https://api.gaterouter.net/v1/chat/completions \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  }'
Python (openai)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gaterouter.net/v1",
    api_key="sk_YOUR_KEY",
)

resp = client.chat.completions.create(
    model="glm-5.3",
    messages=[{"role": "user", "content": "Introduce yourself in one line"}],
)
print(resp.choices[0].message.content)
Node.js (openai) — stream
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.gaterouter.net/v1",
  apiKey: process.env.GATEROUTER_API_KEY,
});

const stream = await client.chat.completions.create({
  model: "deepseek-v4.1-flash",
  messages: [{ role: "user", content: "Streaming test" }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Image generation

Images and video are jobs: you submit one, get a task id back, and fetch the result in step 4.

cURL
curl https://api.gaterouter.net/v2/model-center/tasks \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream_5.0Pro",
    "prompt": "A cute panda eating bamboo, soft sunlight",
    "aspect_ratio": "1:1",
    "resolution": "2K"
  }'
Submit response (200 OK)
{
  "id": "task_9f3c…",
  "object": "model_center.task",
  "created": 1795086000,
  "model": "seedream_5.0Pro",
  "status": "queued",
  "error": null,
  "amount": 0.048653,
  "currency": "USD",
  "amount_is_final": false
}

Video generation

cURL
curl https://api.gaterouter.net/v2/model-center/tasks \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sd_2.0_mini_special",
    "prompt": "Waves crashing on the shore, the camera slowly moves forward",
    "duration": 5,
    "aspect_ratio": "16:9",
    "resolution": "720p"
  }'

Get the result

Fetch the task with the id from the submit response. When status is completed, the result is in image_url or video_url. Images usually take tens of seconds and video a few minutes, so poll about every 5 seconds.

cURL
curl https://api.gaterouter.net/v2/model-center/tasks/task_9f3c… \
  -H "Authorization: Bearer sk_YOUR_KEY"
200 OK
{
  "id": "task_9f3c…",
  "model": "seedream_5.0Pro",
  "status": "completed",
  "result_url": "https://…/result.png",
  "image_url": "https://…/result.png",
  "error": null,
  "amount": 0.048653,
  "currency": "USD",
  "amount_is_final": true
}
  1. queued / processing: still working — check again shortly.
  2. completed: done. Download the result URL — GateRouter doesn't keep results.
  3. failed: the job failed and the held amount is returned in full.
Python — submit and wait
import time, requests

BASE = "https://api.gaterouter.net"
HEADERS = {"Authorization": "Bearer sk_YOUR_KEY"}

task = requests.post(f"{BASE}/v2/model-center/tasks", headers=HEADERS, json={
    "model": "sd_2.0_fast_special",
    "prompt": "Slow drone flight over waves breaking on a beach",
    "duration": 5,
    "aspect_ratio": "16:9",
}).json()

while True:
    t = requests.get(f"{BASE}/v2/model-center/tasks/{task['id']}", headers=HEADERS).json()
    if t["status"] in ("completed", "failed", "delivery_exception", "manual_required"):
        break
    time.sleep(5)

print(t["status"], t.get("video_url") or t.get("result_url"), t.get("error"))
Next: see the Image and Video sections for each model's inputs (start image, reference video, length, resolution) and Billing & credits for how charges work. You can also try everything without code in the console Playground.

Chat completions

POST/v1/chat/completions

Same format as OpenAI Chat Completions. Text models only — a media model ID returns a wrong_endpoint error.

Request body

FieldTypeRequiredDescription
modelstring✓Text model ID (e.g. kimi-k3.1-pro)
messagesarray✓Conversation of {role: system|user|assistant, content}
streambooleantrue streams tokens as server-sent events
temperaturenumber0–2; higher is more varied
top_pnumberNucleus sampling
max_tokens / max_completion_tokensintegerMax output tokens (either name)
stopstring | string[]Stop generation at these strings
The kimi family accepts OpenAI-style image input (image_url parts in the content array).

Response

200 OK
{
  "id": "req_1636920867e8cbdddb45c709",
  "object": "chat.completion",
  "created": 1795085914,
  "model": "glm-5.3-flash",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "OK" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 24, "completion_tokens": 3, "total_tokens": 27 },
  "billing": { "source": "token_fallback", "cost_micro_usd": 7 }
}

billing.cost_micro_usd is what this request deducted (1,000,000 = US$1).

Streaming

text/event-stream
data: {"id":"req_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hel"}}]}

data: {"id":"req_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"lo"}}]}

data: [DONE]

List models

GET/v1/models

Returns every available model ID in OpenAI format (a data array). The full list is also under Supported models below.

cURL
curl https://api.gaterouter.net/v1/models \
  -H "Authorization: Bearer sk_YOUR_KEY"

Media tasks (Model Center)

Image, video, speech, music and digital human all use ① submit a task → ② poll it by ID. Every model shares the same two endpoints; only model and the per-model parameters differ.

① Submit

POST/v2/model-center/tasks
cURL
curl https://api.gaterouter.net/v2/model-center/tasks \
  -H "Authorization: Bearer sk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream_5.0Pro",
    "prompt": "A small cabin in a snowy forest, warm lights",
    "aspect_ratio": "16:9",
    "resolution": "2K"
  }'
200 OK
{
  "id": "task_9f3c…",
  "object": "model_center.task",
  "created": 1795086000,
  "model": "seedream_5.0Pro",
  "status": "queued",
  "error": null,
  "amount": 0.048653,
  "currency": "USD",
  "amount_is_final": false
}

Speech, music and digital human also return a task_ids array (music yields 2 songs per request); id is the first task ID.

② Query

GET/v2/model-center/tasks/{id}
cURL
curl https://api.gaterouter.net/v2/model-center/tasks/task_9f3c… \
  -H "Authorization: Bearer sk_YOUR_KEY"
200 OK
{
  "id": "task_9f3c…",
  "model": "seedream_5.0Pro",
  "status": "completed",
  "result_url": "https://…/result.png",
  "image_url": "https://…/result.png",
  "error": null,
  "amount": 0.048653,
  "currency": "USD",
  "amount_is_final": true
}
statusMeaning
queuedWaiting in queue
processingGenerating
completedDone — use the result URL
failedFailed — read error
delivery_exception / manual_requiredStop polling and contact support (do not resubmit)
Result fieldUsed by
result_urlImage and video
image_urlImage
video_urlVideo, digital human
audio_url, cover_image_urlSpeech, music
amount, currencyWhat this task is billed, in USD
amount_is_finaltrue = final charge; false = estimated maximum before completion
error / error_message / error_codeFailure reason
Poll every 5–10 s for images and video, 3–5 s for speech and music. Result URLs expire — download them promptly. If a submit times out, query the existing task before resubmitting.
Python — submit and wait
import time, requests

BASE = "https://api.gaterouter.net"
HEADERS = {"Authorization": "Bearer sk_YOUR_KEY"}

task = requests.post(f"{BASE}/v2/model-center/tasks", headers=HEADERS, json={
    "model": "sd_2.0_fast_special",
    "prompt": "Slow drone flight over waves breaking on a beach",
    "duration": 5,
    "aspect_ratio": "16:9",
}).json()

while True:
    t = requests.get(f"{BASE}/v2/model-center/tasks/{task['id']}", headers=HEADERS).json()
    if t["status"] in ("completed", "failed", "delivery_exception", "manual_required"):
        break
    time.sleep(5)

print(t["status"], t.get("video_url") or t.get("result_url"), t.get("error"))

Image parameters

Models: seedream_5.0Pro, seedream-5.0

FieldTypeDefault / allowed
prompt *stringrequired
reference_imagesstring[]0–10 public URLs
aspect_ratiostring"1:1" · 3:4 · 4:3 · 16:9 · 9:16 · 3:2 · 2:3 · 21:9
resolutionstring"1K" · 2K
watermarkbooleanfalse

Video parameters

Based on the Seedance 2.x family (sd_2.0_*, sd_2.5_*). Kling, Wan, HappyHorse and MiniMax take prompt, duration, aspect_ratio and resolution under the same names, with model-specific ranges.

FieldTypeDefault / allowed
prompt *stringrequired — describe how the scene moves
duration *integerSeedance 2.0: 4–15 s · 2.5: 4–30 s
aspect_ratiostring"16:9" · 9:16 · 1:1 · 3:4 · 4:3 · 21:9 · adaptive
resolutionstringper model (e.g. fast_special: "720p" only)
first_image / last_imagestring[]First / last frame image URL array (0–1 each), e.g. ["https://…/start.png"]
reference_imagesstring[]0–9
reference_videos / reference_audiosstring[]0–3 each
generate_audiobooleantrue
seedinteger-1 (random)
watermarkbooleanfalse

KlingO3

FieldTypeDefault / allowed
prompt *stringrequired
durationinteger3–15 s, default 6
aspect_ratiostring"16:9" · 9:16 · 1:1
resolutionstring"720p" · 1080p
reference_imagesstring[]0–3
reference_modestring"image" · frame
generate_audiobooleanfalse
Image, video and audio inputs must be publicly reachable URLs; base64 is not supported.

Speech · Music · Digital human

Text to speech — minimax-tts

FieldTypeDescription
text *string1–9,999 characters
voice_setting *objectvoice_id (required), vol (1, max 10), pitch (-12–12), speed (0.5–2), emotion
upstream_model *stringspeech-2.8-hd · speech-2.8-turbo · speech-2.6-hd · speech-2.6-turbo · speech-02-hd · …
language_booststringLanguage hint
text_normalization_modestringbasic · quality

Music — suno_music

FieldTypeDescription
mv *stringchirp-hawk · chirp-hawk-wild · chirp-goose
gpt_description_promptstringDescription mode (don't combine with prompt)
promptstringLyrics (max 3,000 chars)
tagsstringStyle tags (max 200)
titlestringTitle (max 80)
make_instrumentalbooleanInstrumental only
negative_tagsstringStyles to avoid

Digital human — digital_human

FieldTypeDescription
audioUrl *stringmp3/wav/m4a/mp4 (no CJK characters in the URL)
videoUrl *stringSource person video URL
sideFace / tiltedFace0 | 1Side / tilted face handling
modelVersionstring"v3" · "v3-bigface"

Tools & frameworks

Text models follow the widely used Chat Completions format, so most tools only need three settings: the base URL, your API key and a model ID.

SettingValue
Base URLhttps://api.gaterouter.net/v1
API keyYour sk_… key from API Keys in the console
Model IDe.g. deepseek-v4.1-flash, kimi-k3.1-pro, glm-5.3 (see Supported models below)
Reasoning models spend tokens thinking before they answer. A very small max_tokens (e.g. under 50) can leave the answer empty, so use 256 or more. Tool (function) calling and JSON output (response_format) are supported.

n8n

  1. Text (AI Agent, Basic LLM Chain): add an OpenAI Chat Model node and create a new OpenAI credential. Put your sk_… key in API Key and the base URL above in Base URL.
  2. In the node's Model field choose 'By ID' and type the model ID (e.g. deepseek-v4.1-flash). AI Agent tool calls work.
  3. Images and video: submit the task with an HTTP Request node, wait 30 s with a Wait node, then poll with another HTTP Request. Loop back through an IF node until status is completed.
NodeSettings
① HTTP Request (name: Submit)POST https://api.gaterouter.net/v2/model-center/tasks · Header Authorization: Bearer sk_… · Body JSON (below)
② Wait30 seconds
③ HTTP Request (poll)GET https://api.gaterouter.net/v2/model-center/tasks/{{ $('Submit').item.json.id }}
④ IF{{ $json.status }} is completed → continue (use result_url), failed → handle error, otherwise → back to ②
① Submit body (JSON)
{
  "model": "sd_2.0_mini_special",
  "prompt": "{{ $json.prompt }}",
  "duration": 5,
  "aspect_ratio": "9:16",
  "resolution": "720p"
}

LangChain

Python
# pip install langchain-openai
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-v4.1-flash",
    base_url="https://api.gaterouter.net/v1",
    api_key="sk_YOUR_KEY",
    max_tokens=1024,
)
print(llm.invoke("Introduce yourself in one sentence.").content)

# Tool calling works too
from langchain_core.tools import tool

@tool
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    return "3C, clear"

msg = llm.bind_tools([get_weather]).invoke("What's the weather in Seoul?")
print(msg.tool_calls)
JavaScript / TypeScript
// npm i @langchain/openai
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "deepseek-v4.1-flash",
  apiKey: "sk_YOUR_KEY",
  configuration: { baseURL: "https://api.gaterouter.net/v1" },
});
const res = await llm.invoke("Hello!");
console.log(res.content);

LiteLLM

Prefix the model with openai/ and set api_base to GateRouter. For the LiteLLM proxy, put the same values in config.yaml.

Python
# pip install litellm
import litellm

res = litellm.completion(
    model="openai/kimi-k3.1-pro",        # openai/ + GateRouter model ID
    api_base="https://api.gaterouter.net/v1",
    api_key="sk_YOUR_KEY",
    messages=[{"role": "user", "content": "Hello!"}],
    max_tokens=1024,
)
print(res.choices[0].message.content)
config.yaml
# LiteLLM proxy config.yaml
model_list:
  - model_name: kimi
    litellm_params:
      model: openai/kimi-k3.1-pro
      api_base: https://api.gaterouter.net/v1
      api_key: os.environ/GATEROUTER_API_KEY
  - model_name: deepseek
    litellm_params:
      model: openai/deepseek-v4.1-flash
      api_base: https://api.gaterouter.net/v1
      api_key: os.environ/GATEROUTER_API_KEY

Vercel AI SDK

Connect with the @ai-sdk/openai-compatible provider. generateText, streamText and tools all work.

TypeScript
// npm i ai @ai-sdk/openai-compatible zod
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText, streamText, tool, stepCountIs } from "ai";
import { z } from "zod";

const gaterouter = createOpenAICompatible({
  name: "gaterouter",
  baseURL: "https://api.gaterouter.net/v1",
  apiKey: process.env.GATEROUTER_API_KEY,
  includeUsage: true,
});

// Text
const { text } = await generateText({
  model: gaterouter("deepseek-v4.1-flash"),
  prompt: "Introduce yourself in one sentence.",
});

// Streaming (e.g. a Next.js route handler)
const result = streamText({ model: gaterouter("kimi-k3.1-pro"), prompt: "Write a short poem." });
for await (const part of result.textStream) process.stdout.write(part);

// Tools
const withTools = await generateText({
  model: gaterouter("deepseek-v4.1-flash"),
  prompt: "Check the weather in Seoul with the tool, then answer in one sentence.",
  tools: {
    getWeather: tool({
      description: "Get the weather for a city",
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => ({ city, tempC: 3, sky: "clear" }),
    }),
  },
  stopWhen: stepCountIs(3),
});

Cline · Continue (VS Code)

  1. Cline: in settings set API Provider to 'OpenAI Compatible' (Cline's menu name), then fill Base URL with the address above, API Key with your sk_… key and Model ID with a model ID (e.g. kimi-k3.1-pro).
  2. Continue: add models to ~/.continue/config.yaml with provider: openai and apiBase as below, for chat and edit. GateRouter has no dedicated tab-autocomplete model.
  3. Coding tools send a lot of context, so usage can climb quickly. Turn on balance alerts in the console.
config.yaml (Continue)
# ~/.continue/config.yaml
name: GateRouter
version: 1.0.0
schema: v1
models:
  - name: Kimi K3.1 Pro (GateRouter)
    provider: openai
    model: kimi-k3.1-pro
    apiBase: https://api.gaterouter.net/v1
    apiKey: sk_YOUR_KEY
    roles: [chat, edit, apply]
  - name: DeepSeek V4.1 Flash (GateRouter)
    provider: openai
    model: deepseek-v4.1-flash
    apiBase: https://api.gaterouter.net/v1
    apiKey: sk_YOUR_KEY
    roles: [chat, edit, apply]

Open WebUI

  1. Admin Settings → Connections → OpenAI API: add a connection with the base URL above as URL and your sk_… key as Key.
  2. GateRouter models appear in the model list. Pick a text model (DeepSeek, GLM, Kimi, Qwen) for chat; image and video models do not work in the chat screen.

Billing & credits

  1. Every call deducts from your credit balance (USD). Top up with crypto under Credits (minimum US$12; whole dollars).
  2. Text: each request first holds its maximum cost (input + max_tokens, or 8,192 output tokens if you set none); when the answer finishes it is settled to the real token count and the rest is returned at once. The final amount is in the response's billing field (for streams, from the final usage chunk).
  3. If your balance can't cover a full-length answer, the answer is capped to what the balance pays for instead of being refused: the x-gaterouter-max-tokens response header shows the cap, and a cut-off answer ends with finish_reason length. Below 256 tokens' worth the request is refused with 402 insufficient_credits.
  4. If the request fails upstream before any output, the hold is returned in full.
  5. Media: on submit, the estimated maximum cost (from model, duration, resolution, …) is held from your balance first. If the balance is short, the task is not submitted and you get 402 insufficient_credits with required_usd and balance_usd.
  6. On completion the hold is settled to the final amount and any difference is refunded immediately; a failed task refunds the whole hold. Before completion amount is the estimated maximum (amount_is_final: false).
  7. Polling existing tasks (GET) always works, whatever your balance.
  8. See daily usage and spend under Usage in the console.

Paying with crypto

GateRouter takes crypto only. If you are new to it, use USDT on TRC20: it is pegged to the dollar, cheap to send and arrives in minutes.

USDT and USDC also work on cheaper networks: BSC (BEP20), Polygon, Arbitrum, Base (USDC), Solana and TON (USDT). Withdrawing from Binance or a similar exchange? BSC is easiest. Using a Telegram wallet? Pick TON. Whatever you choose, send on the same network you picked on the payment page.

There are two ways to pay. Pick the one that fits where your coins are.

MethodBest whenCoins · amount
1. Send to a payment addressYou send from an exchange (Binance…) or a mobile walletUSDT, USDC, BTC, ETH, SOL on 16 coin/network options · from $12
2. Pay with walletYou have USDC in a browser wallet like MetaMask: one signature, no address copyingUSDC on Base only · $1–$500 · no gas

Method 1. Send to a payment address: what you need

  1. An exchange account where you can buy USDT, or a personal wallet that holds USDT (e.g. TronLink, Trust Wallet, OKX Wallet).
  2. Korean exchanges (Upbit, Bithumb, …) may block withdrawals to payment addresses under the Travel Rule; an international exchange or a personal wallet is more reliable.
  3. Sending TRC20 from a personal wallet needs a little TRX for the network fee.

Step by step

Start the payment in the console

Under Credits, pick the coin (e.g. USDT (TRC20)) and an amount ($12 and up); you are taken to the payment page. To save on network fees, pick a low-fee network such as BSC, Polygon or TON.

Copy the address and amount

The page shows a deposit address (TRC20 addresses start with T), the exact amount and a QR code. Press the continue button if there is one. The address is valid for a limited time.

Send

In your exchange's withdrawal screen or your wallet's Send, choose the same coin and network (TRC20), paste the address, enter the amount and send.

Wait for the credit

Once the blockchain confirms it, the payment page shows finished and your credits arrive automatically — usually 1–5 minutes on TRC20.

Getting the amount right

  1. Round decimals up: for 20.288473 USDT send 20.289 or 20.29. Rounding down leaves you short.
  2. Exchanges usually deduct their withdrawal fee from the amount; add it so the amount that arrives is at least the payment amount.
  3. Up to $0.10 short still counts as paid in full; if more is missing, only what arrived is credited.
Sending on the wrong network (e.g. ERC20 to a TRC20 address) can lose the funds. Unused credit can be refunded to your wallet within 7 days of the top-up from the Credits page (minus the network fee). If a payment does not arrive, contact Support with the payment page link and the transaction hash (TXID).

Method 2. Pay with wallet (USDC on Base)

If you hold USDC on Base in a browser wallet such as MetaMask, Coinbase Wallet or Rabby, one signature tops you up, with no address to copy. Network fees (gas) are covered, so you do not need ETH.

Enter an amount

On the Credits page, under Pay with wallet, enter an amount ($1–$500) and press Pay with wallet.

Connect and switch to Base

Approve the connection in your wallet. If you are not on Base, approve switching to it (or adding it the first time).

Sign once

Your wallet asks you to sign a USDC transfer authorization. Check the recipient and amount, then sign. Signing alone moves nothing; exactly that amount moves when GateRouter settles the payment.

Done

It usually confirms on-chain within 10 seconds and the credit appears. You get a BaseScan link, and the history keeps the on-chain proof.

  1. Only USDC on Base works here. For USDC on Ethereum or USDT, use method 1.
  2. If you lack USDC or cancel the signature, nothing is charged.
  3. On a phone, open gaterouter.net inside your wallet app's browser so the wallet can connect.
  4. To top up from code (agents, servers), see the x402 section below.
On-chain proof: once a top-up completes, the history on the Credits page shows the deposit transaction hash with a block-explorer link (On-chain proof ↗), so anyone can check the payment on the blockchain.

x402: agent top-ups

x402 is an open standard for paying over HTTP 402 (Payment Required). An AI agent or server can top up its own API key's balance with USDC on Base, with no human in the loop. Top-ups are $1 to $500, and credit is added only after the payment is confirmed on-chain.

To top up by hand, use Pay with wallet on the console's Credits page: one signature in a wallet like MetaMask, same x402 flow, no gas (ETH) needed.
GET/v1/x402

Returns the receiving wallet, network and amount range. No auth needed.

POST/v1/x402/topup?amount=5
  1. Authorization: Bearer <API key> picks the account to credit.
  2. Without payment you get 402 and a PAYMENT-REQUIRED header (the payment requirements).
  3. Retry with the signed payment in PAYMENT-SIGNATURE: after settlement you get 200 with the new balance, the transaction hash and an explorer link.
  4. Insufficient-credit errors (402 insufficient_credits) include x402_topup_url, so an agent can top up and retry right away.
Node.js (@x402/fetch)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const wallet = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY);
const client = x402Client.fromConfig({
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(wallet) }],
  // The client caps each payment at $1 by default; raise it for larger top-ups.
  spendControls: { maxAmountPerPayment: "$20" },
});
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://api.gaterouter.net/v1/x402/topup?amount=10", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.GATEROUTER_API_KEY },
});
console.log(await res.json()); // { credited_usd, balance_usd, transaction, explorer_url }
See the requirements (curl)
curl -i -X POST "https://api.gaterouter.net/v1/x402/topup?amount=5" \
  -H "Authorization: Bearer $GATEROUTER_API_KEY"
# HTTP/2 402  +  PAYMENT-REQUIRED: <base64 JSON>
x402 top-ups accept USDC on Base only. If a payment is refused (e.g. not enough USDC) nothing is charged and you get payment_refused. Keep only what the agent needs in its wallet.

Crypto developer tools

In the console, open AI Creative Tools → Crypto developer tools. Each run is charged at the chosen text model's price; failed requests cost nothing.

  1. Security review: finds vulnerabilities in a smart contract, ranked by severity, with fixes. It does not replace a professional audit.
  2. Explain contract: what each function does, who can call it and how money moves.
  3. Explain transaction: paste a hash from Ethereum, Base, BNB Smart Chain, Polygon or Arbitrum to see token movements, the fee and risk signals.

Errors

Errors use the same shape as OpenAI's.

402 Payment Required
{
  "error": {
    "message": "Insufficient credits. This request can cost up to $1.3623; your balance is $1.0000. Top up at https://gaterouter.net/credits",
    "top_up_url": "https://gaterouter.net/credits",
    "type": "insufficient_quota",
    "code": "insufficient_credits",
    "required_usd": 1.36227,
    "balance_usd": 1
  }
}
HTTPcodeCause · fix
400invalid_bodyMalformed body — check required fields and types
400wrong_endpointMedia model sent to chat — use /v2/model-center/tasks
401invalid_api_keyMissing, mistyped or revoked key — check the Authorization header
402insufficient_creditsOut of credits — top up
404model_not_foundUnknown model ID — get the exact ID from /v1/models
429rate_limit_exceededToo many requests (300 per minute per key) — wait the Retry-After seconds, then retry
4xx / 502upstream_errorModel provider error — read message, retry later
503upstream_not_configuredService maintenance — retry later

Troubleshooting

I get 401 invalid_api_key

Check that you replaced sk_YOUR_KEY with your real key, with no extra spaces, right after 'Bearer '. If you revoked the key, create a new one.

I get 402 insufficient_credits

Your balance ran out. Top up under Credits. Trial credits arrive only after you verify your email.

I get 404 model_not_found

Check the model value; case and hyphens must match. Copy the ID from Supported models below or from Models in the console.

It says 'python' or 'pip' is not found

Python isn't installed or isn't on your PATH. On Mac, try python3 and pip3. On Windows, reinstall Python with 'Add python.exe to PATH' checked.

The curl example fails on Windows

Windows handles quotes differently. Use Option C (PowerShell) from Getting started.

I want to make images or video

Images, video and audio don't use the chat address. Submit a task to /v2/model-center/tasks, then check its result with the task ID. See Media tasks below.

Can I put my API key in website or app code?

No. Anyone can read a key shipped in a browser or app and spend your credits. Keep the key on your server and have the server call GateRouter.

Supported models

Put the exact model ID below in the request's model field. Display names will not resolve.

Text · 11

  • DeepSeek · Strong value for money, good at coding and reasoning. A fit for general chat and high-volume work.
  • GLM · Balanced general-purpose models. Flash is the cheapest, good for simple tasks like summaries and classification.
  • Kimi · Strong with long documents and high-quality answers. A fit for long-document analysis.
  • Qwen · Strong in many languages and follows complex instructions well. A fit for translation and multilingual apps.
Model IDNameFamily
deepseek-v4.1-flashDeepSeek V4.1 FlashDeepSeek
deepseek-v4.1-flash-1017DeepSeek V4.1 Flash (1017)DeepSeek
glm-5.3GLM 5.3GLM
glm-5.3-flashGLM 5.3 FlashGLM
glm-5.2GLM 5.2GLM
kimi-k3.1-proKimi K3.1 ProKimi
kimi-k3.1-pro-highspeedKimi K3.1 Pro HighspeedKimi
kimi-k3.1-pro-TJKimi K3.1 Pro TJKimi
kimi-k3Kimi K3Kimi
kimi-k3-TJKimi K3 TJKimi
qwen3.8-maxQwen 3.8 MaxQwen

Image · 2

  • Seedream · Photorealistic images with good in-image text. Pro gives higher quality.
Model IDNameFamily
seedream_5.0ProSeedream 5.0 ProSeedream
seedream-5.0Seedream 5.0Seedream

Video · 26

  • Seedance 2.5 · Natural motion and multi-shot scenes. Flash is faster and cheaper.
  • Seedance 2.0 · Video with natural motion. Fast and Mini are quicker and cheaper.
  • MiniMax · Cinematic shots, up to 1080p.
  • HappyHorse · Separate models for text-to-video, image-to-video and reference-to-video.
  • Wan · Works from text, images or reference video, at a relatively low price.
  • Kling · Good at human motion and expressions. Omni can also use reference images and video.
Model IDNameFamily
sd_2.5_discount_v1Seedance 2.5 DiscountSeedance 2.5
sd_2.5_special_v1Seedance 2.5 SpecialSeedance 2.5
sd_2.5_ORelaySeedance 2.5 Official RelaySeedance 2.5
sd_2.5_ORelay_specialSeedance 2.5 Official Relay SpecialSeedance 2.5
sd_2.5_flash_specialSeedance 2.5 Flash SpecialSeedance 2.5
sd_2.5_flash_discountSeedance 2.5 Flash DiscountSeedance 2.5
sd_2.0_specialSeedance 2.0 SpecialSeedance 2.0
sd_2.0_fast_specialSeedance 2.0 Fast SpecialSeedance 2.0
sd_2.0_mini_specialSeedance 2.0 Mini SpecialSeedance 2.0
sd_2.0_discountSeedance 2.0 DiscountSeedance 2.0
sd_2.0_fast_discountSeedance 2.0 Fast DiscountSeedance 2.0
sd_2.0_mini_discountSeedance 2.0 Mini DiscountSeedance 2.0
videos_30_10_10_c3Videos 30/10/10 C3Videos
videos_900_720pVideos 900 720pVideos
MiniMax-H3-768pMiniMax H3 768pMiniMax
MiniMax-H3-768p-c2MiniMax H3 768p C2MiniMax
MiniMax-H3_933_1080pMiniMax H3 1080pMiniMax
hh-1.1-t2v-oHappyHorse 1.1 Text to VideoHappyHorse
hh-1.1-i2v-oHappyHorse 1.1 Image to VideoHappyHorse
hh-1.1-r2v-oHappyHorse 1.1 Reference to VideoHappyHorse
wan3.0-prime-c2Wan 3.0 Prime C2Wan
wan3.0-video-c2Wan 3.0 Video C2Wan
wan3.0-video-c3Wan 3.0 Video C3Wan
wan3.0-video-r2v-c4Wan 3.0 Reference to Video C4Wan
KlingO3Kling O3Kling
kling-v3-omniKling V3 OmniKling

Speech · 2

  • MiniMax · Natural text-to-speech. Voice Clone copies a voice.
Model IDNameFamily
minimax-ttsMiniMax TTSMiniMax
minimax_voice_cloneMiniMax Voice CloneMiniMax

Music · 1

  • Suno · Makes songs from lyrics and a style.
Model IDNameFamily
suno_musicSuno MusicSuno

Digital human · 1

  • Digital Human · Makes talking avatar videos.
Model IDNameFamily
digital_humanDigital HumanDigital Human
GateRouter API Reference | GateRouter