API 对接文档
快速开始
TokenGet 完全兼容 OpenAI API 协议。只需将已有应用的 base_url 指向本站,并使用本站签发的 API Key 即可。
- 1. 注册账号(用户名密码或微信扫码),在控制台创建 API Key(
sk-tg-...)。 - 2. Base URL:
http://<服务器地址>/v1 - 3. 通过 GET/v1/models?category=llm 按类别拉取模型列表;一个模型可以同时属于多个分类(如
["llm","image"]),支持?category=llm&category=image取交集。
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-tg-你的密钥",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"你好"}]}'
认证方式
所有 /v1/* 接口通过 HTTP Header 携带 API Key:
Authorization: Bearer sk-tg-你的密钥
网页端管理接口(/api/*)使用登录后签发的 JWT,同样放在 Authorization: Bearer 中。
大语言模型(LLM)
POST/v1/chat/completions — 支持流式(stream:true)与非流式。
{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "你好"}],
"stream": true
}
同时支持 POST/v1/completions 与 POST/v1/embeddings。
参数与限制
model(必填):通过 GET/v1/models?category=llm 拉取当前可用模型列表;平台自动路由到优先级最高的可用上游messages(必填):OpenAI 兼容消息数组,role支持system/user/assistant/tool;content支持纯文本或[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"..."}}]多模态数组(具体取决于模型是否支持视觉)stream:布尔值,默认false;开启后按 SSE 流式返回temperature:默认1,范围 0–2;采样温度top_p:默认1,范围 0–1;核采样max_tokens/max_completion_tokens:最大生成 token 数(模型上下文限制不同,详见模型列表)frequency_penalty/presence_penalty:默认0,范围 -2–2stop:停止序列,字符串或字符串数组tools/tool_choice:函数调用(模型支持时透传)response_format:JSON Schema / JSON mode(模型支持时透传)seed:固定随机种子(上游支持时生效)- 单条消息大小与总上下文长度受具体模型限制;请求体大小受 nginx 限制(1000MB)
图片生成
图片能力统一入口为 POST/v1/cap/image/{path}。调用方只需指定 model,平台根据模型自动路由到对应上游(SnapGen 原生生图接口,或 OpenRouter 多模态 LLM 的 chat.completions)。
- POST/v1/cap/image/generate_image — 文生图 / 图生图 / 图片编辑(form-data)
- GET/v1/cap/image/history/{uuid} — 查询单条生成结果(
status == 2即完成) - GET/v1/cap/image/histories — 历史列表
模型可选项
已接入的图片生成模型包括 SnapGen 原生模型(nano-banana-pro / nano-banana-2 / nano-banana-2-lite / grok-image / gpt-image-2)以及 OpenRouter 多模态 LLM(grok / gemini / inkling 等)。完整、实时列表请通过 GET/v1/models?category=image 拉取;支持多分类交集查询,如 ?category=image&category=llm。未在列表中的模型无法通过本能力路由调用。
不同上游的返回格式不同:SnapGen 原生模型返回 {"uuid": "..."} 需轮询;OpenRouter 多模态 LLM 返回 chat.completion 格式(assistant message 中携带图片 URL)。
文生图
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "prompt=a cute cat on a windowsill" \ -F "model=nano-banana-2-lite" \ -F "aspect_ratio=1:1"
图生图 / 图片编辑
增加 image 参数传入参考图 URL,即可图生图或风格迁移:
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "prompt=turn this into a watercolor painting" \ -F "model=nano-banana-2-lite" \ -F "image=https://example.com/photo.jpg" \ -F "aspect_ratio=1:1"
本地图片直接上传(multipart/form-data)
参考图也可以本地文件随请求直接上传——image 字段值用 @文件路径,与表单字段同一请求发出,平台不设大小限制(仅网关本身的请求体上限):
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "prompt=把这张照片变成水彩画" \ -F "model=nano-banana-2-lite" \ -F "image=@/Users/me/photo.jpg"
URL 与本地文件可混用;多张参考图重复传 image 字段即可。
多图参考
form-data 支持同名字段重复传参——多图参考时重复传多个 image 字段(是否生效取决于所选模型):
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "prompt=把图1的人物放进图2的场景,保持图3的画风" \ -F "model=nano-banana-2-lite" \ -F "image=https://example.com/person.jpg" \ -F "image=https://example.com/scene.jpg" \ -F "image=https://example.com/style.jpg"
参数说明
prompt(必填):画面描述 / 编辑指令model(必填):生图模型;当前可选项为nano-banana-2-lite,实时完整列表通过 GET/v1/models?category=image 获取aspect_ratio:宽高比,如1:1/16:9/9:16image:参考图,支持公网 URL 或@本地文件路径直接上传,可重复传多张(数量受所选模型限制)image_width/image_height:输出尺寸(可选)quality:hd提升质量(可选)seed:固定随机种子(可选)
轮询结果
curl http://localhost:8000/v1/cap/image/history/9f8e7d6c-xxxx \ -H "Authorization: Bearer sk-tg-你的密钥"
status == 2 表示完成,从响应中取结果图 URL;建议每 5–10 秒轮询一次。
视频生成
视频能力统一入口为 POST/v1/cap/video/{path}。调用方只需指定 model,平台根据模型自动路由到对应上游(SnapGen / MiniMax 原生视频接口,或 OpenRouter 多模态 LLM 的 chat.completions)。
- POST/v1/cap/video/v2/video_generation — 提交视频生成任务
- GET/v1/cap/video/v2/query/video_generation/{task_id} — 查询任务状态
模型可选项
已接入的视频生成模型包括:
- SnapGen 原生视频:
flux-3/veo-3 - MiniMax 原生视频:
MiniMax-H3(全功能,768P/2K,4–15s)/MiniMax-H3-Max(更快,480P/768P,5–15s) - OpenRouter 多模态 LLM:grok / gemini / inkling 等
完整、实时的 model 列表请通过 GET/v1/models?category=video 拉取;支持多分类交集查询,如 ?category=video&category=llm。未在列表中的模型无法通过本能力路由调用。
不同上游的返回格式不同:SnapGen / MiniMax 原生模型返回任务 ID 需轮询;OpenRouter 多模态 LLM 返回 chat.completion 格式(assistant message 中携带视频 URL)。
1. 文生视频
content 仅含文本;ratio 必填(不能为 adaptive)。提示词支持运镜指令如 [推进]:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [{"type": "text", "text": "一只橘猫在窗台上伸懒腰,阳光洒进房间,[推进]"}],
"resolution": "768P",
"duration": 6,
"ratio": "16:9"
}'
2. 图生视频(首帧)
图片作为视频起始画面;ratio 由图片决定(恒为 adaptive,可不传):
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "一只橘猫在窗台上伸懒腰,[推进]"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}, "role": "first_frame"}
],
"resolution": "768P",
"duration": 6
}'
3. 首尾帧视频
同时指定开始与结束画面(first_frame + last_frame),模型生成中间过渡:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "猫咪从窗台轻盈跳到沙发上"},
{"type": "image_url", "image_url": {"url": "https://example.com/start.jpg"}, "role": "first_frame"},
{"type": "image_url", "image_url": {"url": "https://example.com/end.jpg"}, "role": "last_frame"}
],
"resolution": "768P",
"duration": 6
}'
4. 多参视频(图片 + 声音 + 视频参数)
多模态参考生视频:参考图定角色/风格(最多 9 张)+ 参考视频定动作(最多 3 段)+ 参考音频定声音(最多 3 段),按需组合:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "宇航员在月球表面漫步,背景是浩瀚星空"},
{"type": "image_url", "image_url": {"url": "https://example.com/astronaut.jpg"}, "role": "reference_image"},
{"type": "image_url", "image_url": {"url": "https://example.com/style.jpg"}, "role": "reference_image"},
{"type": "video_url", "video_url": {"url": "https://example.com/walk.mp4"}, "role": "reference_video"},
{"type": "audio_url", "audio_url": {"url": "https://example.com/space.mp3"}, "role": "reference_audio"}
],
"resolution": "2K",
"duration": 8,
"ratio": "16:9"
}'
5. 视频编辑
把待编辑视频作为 reference_video 传入,用文本描述修改需求(换风格、换背景、改动作、加特效等);可同时传 reference_image 指定新形象、reference_audio 指定配音:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "把画面变成赛博朋克风格,霓虹灯光,雨夜氛围"},
{"type": "video_url", "video_url": {"url": "https://example.com/source.mp4"}, "role": "reference_video"}
],
"resolution": "768P",
"duration": 6
}'
6. 本地文件直接上传(multipart/form-data)
除 JSON 外,视频接口也接受 multipart/form-data:表单字段与文件同一请求发出,文件值用 @本地路径,平台自动转存并生成 URL 发给上游,平台不设文件大小限制(仅网关本身的请求体上限)。字段名与 JSON content 角色的对应关系:
prompt或text→ 文本项first_frame/last_frame→ 首帧 / 尾帧图片image(或reference_image)→ 参考图,可重复传多张video(或reference_video)→ 参考视频,可重复传多段audio(或reference_audio)→ 参考音频,可重复传多段- 其余字段(
model/resolution/duration/ratio等)原样作为顶层参数
图生视频(本地首帧图):
curl http://localhost:8000/v1/cap/video/v2/video_generation \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "model=MiniMax-H3" \ -F "prompt=一只橘猫在窗台上伸懒腰,[推进]" \ -F "first_frame=@/Users/me/cat.jpg" \ -F "resolution=768P" \ -F "duration=6"
多参视频(本地参考图 + 参考视频 + 参考音频混合,也可与 URL 混用):
curl http://localhost:8000/v1/cap/video/v2/video_generation \ -H "Authorization: Bearer sk-tg-你的密钥" \ -F "model=MiniMax-H3" \ -F "prompt=宇航员在月球表面漫步,背景是浩瀚星空" \ -F "image=@/Users/me/astronaut.jpg" \ -F "image=https://example.com/style.jpg" \ -F "video=@/Users/me/walk.mp4" \ -F "audio=@/Users/me/space.mp3" \ -F "resolution=2K" \ -F "duration=8" \ -F "ratio=16:9"
7. 轮询任务
curl http://localhost:8000/v1/cap/video/v2/query/video_generation/424010985738629 \ -H "Authorization: Bearer sk-tg-你的密钥"
建议每 10 秒轮询一次。task.status 为 succeeded 时,task.content.url 即为成片下载地址。
参数与限制速查
model(必填):视频生成模型;可选项见上方“模型可选项”,实时完整列表通过 GET/v1/models?category=video 获取content[].type:text/image_url/video_url/audio_urlcontent[].role:first_frame/last_frame/reference_image/reference_video/reference_audioresolution:480P/768P/2K(视模型而定);duration:秒数ratio:文生必填(21:9/16:9/4:3/1:1/3:4/9:16);图生由图片决定;多参可选默认 adaptive- 参考数量上限按所选模型配置并由平台强制校验(超限返回 400):如 MiniMax-H3 为图片 ≤ 9 张、视频 ≤ 3 段(每段 2–15s、总 ≤ 15s)、音频 ≤ 3 段;本地文件上传仅受网关请求体上限约束(大文件建议走 multipart 直传或公网 URL,勿用 Base64)
- 图生与多参互斥:content 中出现
reference_*就不能再用first_frame/last_frame - 素材要求:图片 JPG/PNG/WEBP ≤ 30MB(256–5760px,宽高比 0.4–2.5);视频 MP4/MOV(H.264/H.265)≤ 50MB;音频 WAV/MP3 ≤ 15MB
callback_url:可选,任务状态变更时回调通知
语音合成
本平台通过统一的能力路由 POST/v1/cap/speech/{上游路径} 接入两家语音供应商,按 model(MiniMax 系列)或 model_id(ElevenLabs 系列)前缀自动分派。返回为音频二进制流或 JSON 包装音频,直接透传上游。
1. MiniMax TTS
POST/v1/cap/speech/v1/t2a_v2 — 返回 JSON,音频在 data.audio(hex 编码),字符用量在 extra_info.usage_characters。
curl http://localhost:8000/v1/cap/speech/v1/t2a_v2 \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "speech-2.8-hd",
"text": "你好,欢迎使用 TokenGet。",
"voice_setting": {
"voice_id": "female-shaonv",
"speed": 1,
"vol": 1,
"pitch": 0,
"emotion": "happy"
},
"audio_setting": {
"sample_rate": 32000,
"bitrate": 128000,
"format": "mp3",
"channel": 1
}
}'
MiniMax 模型可选项
speech-2.8-hd/speech-2.8-turbospeech-2.6-hd/speech-2.6-turbospeech-02-hd/speech-02-turbospeech-01-hd/speech-01-turbo
MiniMax 参数说明
model(必填):从上方可选项中选择text(必填):要合成的文本,单条长度受模型限制(通常 ≤ 10000 字符)voice_setting(必填):voice_id:音色 ID,如female-shaonv、male-qnqingse等(以 MiniMax 官方更新为准)speed:语速,默认1,建议范围 0.5–2.0vol:音量,默认1,建议范围 0–10pitch:音调,默认0,建议范围 -12–12emotion:情绪,如happy/sad/neutral等(可选,模型支持时生效)
audio_setting(必填):sample_rate:采样率,可选16000/24000/32000/44100/48000bitrate:码率,如64000/128000/192000format:输出格式,mp3/wav/pcm/oggchannel:声道数,1(单声道)或2(立体声)
- 计费:按请求文本字符数 × 1.5 系数扣积分;失败请求不计费
2. ElevenLabs TTS
POST/v1/cap/speech/v1/text-to-speech/{voice_id} — 直接返回 audio/mpeg 二进制音频。
curl http://localhost:8000/v1/cap/speech/v1/text-to-speech/JBFqnCBsd6RMkjVDRZzb \
-H "Authorization: Bearer sk-tg-你的密钥" \
-H "Content-Type: application/json" \
-o speech.mp3 \
-d '{
"model_id": "eleven_multilingual_v2",
"text": "Hello, welcome to TokenGet.",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.75,
"style": 0.0,
"use_speaker_boost": true
}
}'
ElevenLabs 模型可选项
eleven_v3(质量最高,支持多语言)eleven_multilingual_v2/eleven_multilingual_v1eleven_flash_v2_5/eleven_flash_v2(低延迟)eleven_turbo_v2_5/eleven_turbo_v2eleven_monolingual_v1
ElevenLabs 参数说明
model_id(必填):从上方可选项中选择text(必填):要合成的文本voice_id(路径参数):目标音色 ID,如JBFqnCBsd6RMkjVDRZzb;可通过上游官方接口 /v1/voices 获取voice_settings(可选):stability:稳定性,0–1similarity_boost:相似度增强,0–1style:风格强度,0–1(部分模型支持)use_speaker_boost:布尔值
pronunciation_dictionary_locators/seed/previous_text/next_text:可选高级参数(上游支持时透传)- 计费:按请求文本字符数 × 1.5 系数扣积分;失败请求不计费
3. 其他 ElevenLabs 能力
通过 /v1/cap/speech/v1/... 直接透传,参数与官方一致:
- POST/v1/cap/speech/v1/text-to-voice/create-previews — 按文本描述生成预览音色(
text需 ≥ 100 字符) - POST/v1/cap/speech/v1/text-to-voice/create-voice-from-preview — 将预览音色保存为永久音色
- POST/v1/cap/speech/v1/sound-generation — 音效生成
- POST/v1/cap/speech/v1/voice_clone / POST/v1/cap/speech/v1/files/upload / POST/v1/cap/speech/v1/voices/add — 自定义音色相关(按上游官方 API 传参)
语音通用说明
- 当前仅支持语音合成(TTS),暂未接入语音识别(STT)与音乐生成
- 模型可选项以 GET/v1/models?category=speech 实时返回为准;未列出的 model/model_id 会路由失败
- 请求体大小受 nginx 限制(1000MB)
文件接口
用户文件默认保存 2 天(管理员可按用户调整)。文件接口使用登录后的 JWT 认证。
- POST/api/files — multipart 上传,返回
file_id - GET/api/files — 文件列表
- GET/api/files/{file_id} — 下载
- DELETE/api/files/{file_id} — 删除
TOKEN=<登录后的JWT> # 上传 curl http://localhost:8000/api/files -H "Authorization: Bearer $TOKEN" -F "file=@photo.jpg" # 列表 curl http://localhost:8000/api/files -H "Authorization: Bearer $TOKEN" # 下载 curl http://localhost:8000/api/files/<file_id> -H "Authorization: Bearer $TOKEN" -o photo.jpg # 删除 curl -X DELETE http://localhost:8000/api/files/<file_id> -H "Authorization: Bearer $TOKEN"
参数说明
file(上传必填):multipart 文件字段;无格式限制,大小仅受 nginx 限制(1000MB)purpose(可选):文件用途标签,如general/fine-tune/relay;不传默认generalpage/page_size(列表可选):分页,默认第 1 页,每页 20 条,最大 100 条- 文件默认保留 2 天;管理员可通过 PATCH/api/admin/users/{id} 调整
file_retention_days
计费说明
- 按调用量计费:每次成功调用按实际用量扣减积分,明细可在控制台「积分流水 / 调用记录」查询。
- 失败的请求(HTTP ≥ 400)不计费。
- 余额不足(≤ 0)时请求会被拒绝(HTTP 402),充值后立即恢复。
- 新用户注册即送体验额度,可直接开始调用。
记录查询
- GET/api/credits/balance — 当前余额
- GET/api/credits/transactions?type=consume&page=1 — 积分流水(充值/消费/授予)
- GET/api/calls?category=llm&page=1 — API 调用记录(默认保留 2 天)
TOKEN=<登录后的JWT> curl http://localhost:8000/api/credits/balance -H "Authorization: Bearer $TOKEN" curl "http://localhost:8000/api/credits/transactions?type=consume&page=1" -H "Authorization: Bearer $TOKEN" curl "http://localhost:8000/api/calls?category=llm&page=1" -H "Authorization: Bearer $TOKEN"
Quick Start
TokenGet is fully compatible with the OpenAI API. Point your base_url to this gateway and use a TokenGet API key.
- 1. Sign up (username/password or WeChat), then create an API key (
sk-tg-...) in the console. - 2. Base URL:
http://<your-server>/v1 - 3. List models by category: GET/v1/models?category=llm. A model can belong to multiple categories (e.g.
["llm","image"]); use?category=llm&category=imageto get the intersection.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-tg-your-key",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'
Authentication
All /v1/* endpoints accept your API key in the header:
Authorization: Bearer sk-tg-your-key
Web management APIs (/api/*) use the JWT issued after sign-in, also as a Bearer token.
LLM
POST/v1/chat/completions — streaming (stream:true) and non-streaming.
{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}
Also available: POST/v1/completions and POST/v1/embeddings.
Parameters & Limits
model(required): fetch the available list via GET/v1/models?category=llm; the platform routes to the highest-priority active upstream automaticallymessages(required): OpenAI-compatible array;rolesupportssystem/user/assistant/tool;contentsupports plain text or a multimodal array[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"..."}}](vision support depends on the model)stream: boolean, defaultfalse; enables SSE streamingtemperature: default1, range 0–2top_p: default1, range 0–1max_tokens/max_completion_tokens: max generated tokens (context limits vary by model)frequency_penalty/presence_penalty: default0, range -2–2stop: stop sequence(s), string or array of stringstools/tool_choice: function calling (passed through when the model supports it)response_format: JSON Schema / JSON mode (passed through when supported)seed: deterministic seed (when the upstream supports it)- Single-message size and total context length are constrained by the chosen model; request body size is limited by nginx (1000MB)
Completions & Embeddings
curl http://localhost:8000/v1/completions \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","prompt":"Introduce TokenGet in one sentence","max_tokens":64}'
curl http://localhost:8000/v1/embeddings \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"text-embedding-3-small","input":"Hello world"}'
Image Generation
The unified image endpoint is POST/v1/cap/image/{path}. Just specify the model; the gateway routes to the correct upstream automatically (SnapGen native image endpoints, or OpenRouter multi-modal LLM chat.completions).
- POST/v1/cap/image/generate_image — text-to-image / image-to-image / image editing (form-data)
- GET/v1/cap/image/history/{uuid} — query a single result (done when
status == 2) - GET/v1/cap/image/histories — history list
Model Options
Connected image models include SnapGen native models (nano-banana-pro, nano-banana-2, nano-banana-2-lite, grok-image, gpt-image-2) and OpenRouter multi-modal LLMs (grok, gemini, inkling, etc.). For the full, real-time list, call GET/v1/models?category=image; supports multi-category intersection queries such as ?category=image&category=llm. Models not in this list cannot be used through this capability route.
Return formats differ by upstream: SnapGen native models return {"uuid": "..."} and require polling; OpenRouter multi-modal LLMs return a chat.completion with the image URL in the assistant message.
Text-to-Image
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-your-key" \ -F "prompt=a cute cat on a windowsill" \ -F "model=nano-banana-2-lite" \ -F "aspect_ratio=1:1"
Image-to-Image / Image Editing
Add the image parameter with a reference image URL for image-to-image or style transfer:
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-your-key" \ -F "prompt=turn this into a watercolor painting" \ -F "model=nano-banana-2-lite" \ -F "image=https://example.com/photo.jpg" \ -F "aspect_ratio=1:1"
Upload Local Images Directly (multipart/form-data)
Reference images can also be uploaded as local files in the same request — use @/path/to/file as the image field value. The platform imposes no size limit of its own (only the gateway request-body limit applies):
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-your-key" \ -F "prompt=turn this photo into a watercolor painting" \ -F "model=nano-banana-2-lite" \ -F "image=@/Users/me/photo.jpg"
URLs and local files can be mixed; repeat the image field for multiple references.
Multi-Image Reference
form-data allows repeated fields with the same name — pass multiple image fields for multi-image reference (support depends on the model):
curl http://localhost:8000/v1/cap/image/generate_image \ -H "Authorization: Bearer sk-tg-your-key" \ -F "prompt=put the person from image 1 into the scene of image 2, keep the style of image 3" \ -F "model=nano-banana-2-lite" \ -F "image=https://example.com/person.jpg" \ -F "image=https://example.com/scene.jpg" \ -F "image=https://example.com/style.jpg"
Parameters
prompt(required): description / edit instructionmodel(required): generation model; current option isnano-banana-2-lite, full real-time list via GET/v1/models?category=imageaspect_ratio: e.g.1:1/16:9/9:16image: reference image — public URL or@/local/fileupload, repeatable (count limited by the selected model)image_width/image_height: output size (optional)quality:hdfor higher quality (optional)seed: pin the random seed (optional)
Polling the Result
curl http://localhost:8000/v1/cap/image/history/9f8e7d6c-xxxx \ -H "Authorization: Bearer sk-tg-your-key"
status == 2 means done — take the result image URL from the response. Poll every 5–10 seconds.
Video Generation
The unified video endpoint is POST/v1/cap/video/{path}. Just specify the model; the gateway routes to the correct upstream automatically (SnapGen / MiniMax native video endpoints, or OpenRouter multi-modal LLM chat.completions).
- POST/v1/cap/video/v2/video_generation — submit a video task
- GET/v1/cap/video/v2/query/video_generation/{task_id} — query task status
Model Options
Connected video models include:
- SnapGen native video:
flux-3/veo-3 - MiniMax native video:
MiniMax-H3(full features, 768P/2K, 4–15s) /MiniMax-H3-Max(faster, 480P/768P, 5–15s) - OpenRouter multi-modal LLMs: grok, gemini, inkling, etc.
For the full, real-time list, call GET/v1/models?category=video; supports multi-category intersection queries such as ?category=video&category=llm. Models not in this list cannot be used through this capability route.
Return formats differ by upstream: native video models return a task ID and require polling; OpenRouter multi-modal LLMs return a chat.completion with the video URL in the assistant message.
1. Text-to-Video
content contains text only; ratio is required (cannot be adaptive). Camera-movement commands like [push in] are supported in the prompt:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [{"type": "text", "text": "An orange cat stretches on the windowsill, sunlight pours in, [push in]"}],
"resolution": "768P",
"duration": 6,
"ratio": "16:9"
}'
2. Image-to-Video (First Frame)
The image becomes the opening frame; ratio follows the image (always adaptive, can be omitted):
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "An orange cat stretches on the windowsill, [push in]"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}, "role": "first_frame"}
],
"resolution": "768P",
"duration": 6
}'
3. First + Last Frame Video
Specify both the start and end frames (first_frame + last_frame); the model generates the in-between transition:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "The cat leaps gracefully from the windowsill onto the sofa"},
{"type": "image_url", "image_url": {"url": "https://example.com/start.jpg"}, "role": "first_frame"},
{"type": "image_url", "image_url": {"url": "https://example.com/end.jpg"}, "role": "last_frame"}
],
"resolution": "768P",
"duration": 6
}'
4. Multi-Reference Video (image + audio + video inputs)
Multi-modal reference generation: reference images set subject/style (up to 9), reference videos set motion (up to 3), reference audios set voice/sound (up to 3) — combine as needed:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "An astronaut walks on the moon under a vast starry sky"},
{"type": "image_url", "image_url": {"url": "https://example.com/astronaut.jpg"}, "role": "reference_image"},
{"type": "image_url", "image_url": {"url": "https://example.com/style.jpg"}, "role": "reference_image"},
{"type": "video_url", "video_url": {"url": "https://example.com/walk.mp4"}, "role": "reference_video"},
{"type": "audio_url", "audio_url": {"url": "https://example.com/space.mp3"}, "role": "reference_audio"}
],
"resolution": "2K",
"duration": 8,
"ratio": "16:9"
}'
5. Video Editing
Pass the video to edit as reference_video and describe the changes in text (restyle, swap background, change motion, add effects). Optionally add reference_image for a new look and reference_audio for the soundtrack:
curl http://localhost:8000/v1/cap/video/v2/video_generation \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-H3",
"content": [
{"type": "text", "text": "Turn the footage into cyberpunk style, neon lights, rainy night"},
{"type": "video_url", "video_url": {"url": "https://example.com/source.mp4"}, "role": "reference_video"}
],
"resolution": "768P",
"duration": 6
}'
6. Upload Local Files Directly (multipart/form-data)
Besides JSON, the video endpoint also accepts multipart/form-data: form fields and files go in the same request; use @/local/path for file values and the platform stores them and hands public URLs to the upstream. No platform-imposed file size limit (only the gateway request-body limit applies). Form fields map to JSON content roles as follows:
promptortext→ text itemfirst_frame/last_frame→ first / last frame imageimage(orreference_image) → reference image, repeatablevideo(orreference_video) → reference video, repeatableaudio(orreference_audio) → reference audio, repeatable- All other fields (
model/resolution/duration/ratio…) become top-level parameters as-is
Image-to-video with a local first-frame image:
curl http://localhost:8000/v1/cap/video/v2/video_generation \ -H "Authorization: Bearer sk-tg-your-key" \ -F "model=MiniMax-H3" \ -F "prompt=An orange cat stretches on the windowsill, [push in]" \ -F "first_frame=@/Users/me/cat.jpg" \ -F "resolution=768P" \ -F "duration=6"
Multi-reference video with mixed local files and URLs:
curl http://localhost:8000/v1/cap/video/v2/video_generation \ -H "Authorization: Bearer sk-tg-your-key" \ -F "model=MiniMax-H3" \ -F "prompt=An astronaut walks on the moon under a vast starry sky" \ -F "image=@/Users/me/astronaut.jpg" \ -F "image=https://example.com/style.jpg" \ -F "video=@/Users/me/walk.mp4" \ -F "audio=@/Users/me/space.mp3" \ -F "resolution=2K" \ -F "duration=8" \ -F "ratio=16:9"
7. Polling the Task
curl http://localhost:8000/v1/cap/video/v2/query/video_generation/424010985738629 \ -H "Authorization: Bearer sk-tg-your-key"
Poll every ~10 seconds. When task.status becomes succeeded, task.content.url is the downloadable video.
Parameter & Limit Cheat Sheet
model(required): video generation model; see "Model Options" above for current choices, full real-time list via GET/v1/models?category=videocontent[].type:text/image_url/video_url/audio_urlcontent[].role:first_frame/last_frame/reference_image/reference_video/reference_audioresolution:480P/768P/2K(model dependent);duration: secondsratio: required for text-to-video (21:9/16:9/4:3/1:1/3:4/9:16); follows the image for image-to-video; optional for multi-reference (default adaptive)- Reference limits are configured per model and enforced by the platform (exceeding them returns 400) — e.g. MiniMax-H3: ≤ 9 images, ≤ 3 videos (each 2–15s, total ≤ 15s), ≤ 3 audios; local uploads are bounded only by the gateway request-body limit (prefer multipart upload or public URLs for large files, not Base64)
- Image-to-video and multi-reference are mutually exclusive: once any
reference_*appears,first_frame/last_framecannot be used - Media requirements: images JPG/PNG/WEBP ≤ 30MB (256–5760px, aspect 0.4–2.5); videos MP4/MOV (H.264/H.265) ≤ 50MB; audio WAV/MP3 ≤ 15MB
callback_url: optional webhook notified on task status changes
Speech Synthesis
Speech is exposed through the unified capability route POST/v1/cap/speech/{upstream-path}. Requests are routed automatically by model (MiniMax series) or model_id (ElevenLabs series) prefix. Responses are passed through directly as binary audio or JSON-wrapped audio.
1. MiniMax TTS
POST/v1/cap/speech/v1/t2a_v2 — returns JSON; audio is hex-encoded in data.audio, character usage is in extra_info.usage_characters.
curl http://localhost:8000/v1/cap/speech/v1/t2a_v2 \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "speech-2.8-hd",
"text": "Hello, welcome to TokenGet.",
"voice_setting": {
"voice_id": "female-shaonv",
"speed": 1,
"vol": 1,
"pitch": 0,
"emotion": "happy"
},
"audio_setting": {
"sample_rate": 32000,
"bitrate": 128000,
"format": "mp3",
"channel": 1
}
}'
MiniMax Model Options
speech-2.8-hd/speech-2.8-turbospeech-2.6-hd/speech-2.6-turbospeech-02-hd/speech-02-turbospeech-01-hd/speech-01-turbo
MiniMax Parameters
model(required): choose from the list abovetext(required): text to synthesize; max length depends on the model (commonly ≤ 10,000 chars)voice_setting(required):voice_id: voice ID, e.g.female-shaonv,male-qnqingse(refer to MiniMax official docs for the latest list)speed: default1, recommended 0.5–2.0vol: default1, recommended 0–10pitch: default0, recommended -12–12emotion: e.g.happy/sad/neutral(optional, when the model supports it)
audio_setting(required):sample_rate:16000/24000/32000/44100/48000bitrate: e.g.64000/128000/192000format:mp3/wav/pcm/oggchannel:1(mono) or2(stereo)
- Billing: credits = request text char count × 1.5; failed requests are free
2. ElevenLabs TTS
POST/v1/cap/speech/v1/text-to-speech/{voice_id} — returns audio/mpeg binary directly.
curl http://localhost:8000/v1/cap/speech/v1/text-to-speech/JBFqnCBsd6RMkjVDRZzb \
-H "Authorization: Bearer sk-tg-your-key" \
-H "Content-Type: application/json" \
-o speech.mp3 \
-d '{
"model_id": "eleven_multilingual_v2",
"text": "Hello, welcome to TokenGet.",
"voice_settings": {
"stability": 0.5,
"similarity_boost": 0.75,
"style": 0.0,
"use_speaker_boost": true
}
}'
ElevenLabs Model Options
eleven_v3(highest quality, multilingual)eleven_multilingual_v2/eleven_multilingual_v1eleven_flash_v2_5/eleven_flash_v2(low latency)eleven_turbo_v2_5/eleven_turbo_v2eleven_monolingual_v1
ElevenLabs Parameters
model_id(required): choose from the list abovetext(required): text to synthesizevoice_id(path parameter): target voice ID, e.g.JBFqnCBsd6RMkjVDRZzb; retrieve available voices from the upstream/v1/voicesendpointvoice_settings(optional):stability: 0–1similarity_boost: 0–1style: 0–1 (supported by some models)use_speaker_boost: boolean
pronunciation_dictionary_locators/seed/previous_text/next_text: optional advanced parameters (passed through when supported)- Billing: credits = request text char count × 1.5; failed requests are free
3. Other ElevenLabs Capabilities
Accessed directly through /v1/cap/speech/v1/..., parameters match the official API:
- POST/v1/cap/speech/v1/text-to-voice/create-previews — generate preview voices from a description (
textmust be ≥ 100 chars) - POST/v1/cap/speech/v1/text-to-voice/create-voice-from-preview — save a preview as a permanent voice
- POST/v1/cap/speech/v1/sound-generation — sound-effect generation
- POST/v1/cap/speech/v1/voice_clone / POST/v1/cap/speech/v1/files/upload / POST/v1/cap/speech/v1/voices/add — voice-cloning related endpoints (follow the upstream API)
General Notes
- Only text-to-speech (TTS) is supported; speech-to-text (STT) and music generation are not yet connected
- Model options are returned live by GET/v1/models?category=speech; unlisted model/model_id values will fail to route
- Request body size is limited by nginx (1000MB)
Files API
Files are kept for 2 days by default (adjustable per user by admins). These endpoints use the JWT issued after sign-in.
- POST/api/files — multipart upload, returns
file_id - GET/api/files — list files
- GET/api/files/{file_id} — download
- DELETE/api/files/{file_id} — delete
TOKEN=<JWT after sign-in> # Upload curl http://localhost:8000/api/files -H "Authorization: Bearer $TOKEN" -F "file=@photo.jpg" # List curl http://localhost:8000/api/files -H "Authorization: Bearer $TOKEN" # Download curl http://localhost:8000/api/files/<file_id> -H "Authorization: Bearer $TOKEN" -o photo.jpg # Delete curl -X DELETE http://localhost:8000/api/files/<file_id> -H "Authorization: Bearer $TOKEN"
Parameters
file(upload, required): multipart file field; no format restriction, size limited only by nginx (1000MB)purpose(optional): file-purpose tag, e.g.general/fine-tune/relay; defaults togeneralpage/page_size(list, optional): pagination, default page 1, 20 per page, max 100- Files are kept for 2 days by default; admins can adjust
file_retention_daysvia PATCH/api/admin/users/{id}
Billing
- Pay-as-you-go: each successful call deducts credits based on actual usage; details are available in the console (Credit Transactions / API Call Logs).
- Failed requests (HTTP ≥ 400) are free.
- Requests are rejected with HTTP 402 when your balance is ≤ 0; top up to resume immediately.
- New accounts receive free trial credits on sign-up.
Records
- GET/api/credits/balance — current balance
- GET/api/credits/transactions?type=consume&page=1 — credit transactions
- GET/api/calls?category=llm&page=1 — API call logs (kept 2 days by default)
TOKEN=<JWT after sign-in> curl http://localhost:8000/api/credits/balance -H "Authorization: Bearer $TOKEN" curl "http://localhost:8000/api/credits/transactions?type=consume&page=1" -H "Authorization: Bearer $TOKEN" curl "http://localhost:8000/api/calls?category=llm&page=1" -H "Authorization: Bearer $TOKEN"