网关 API 文档

一个 REST API 统一调用 fal.ai、Replicate、WaveSpeedAI、KIE AI、APIMart、EvoLink、AtlasCloud、Vercel AI Gateway、OpenRouter 上的图片、视频、音频与对话模型。

Base URL: https://01router.com/api/v1

鉴权

以 Bearer Token 方式发送 API Key,费用从 Key 所属账户的积分中扣除。 获取 API Key

Authorization: Bearer sk_xxxxxxxxxxxxxxxx

接口列表

MethodPath说明
POST/generations创建生成任务(扣积分)
GET/generations/{id}查询任务;运行中会向上游拉取状态
GET/generations分页查询你的生成记录(page、pageSize)
POST/chat/completions对话补全(兼容 OpenAI,支持流式)
POST/quote对所有供应商报价(不扣费,无需 Key)
GET/models模型列表,含参数与价格(?type=video|image|audio|chat)
GET/models/{slug}查询单个模型
GET/providers供应商及其支持的模型

创建生成任务

传入模型 ID、统一输入参数,可选指定供应商 slug。接口立即返回任务 ID;同步类供应商的图片模型可能直接返回成功结果。

curl https://01router.com/api/v1/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2.5",
    "provider": "fal",            // optional: omit to auto-route
    "input": {
      "prompt": "A red fox running through fresh snow, cinematic",
      "duration": 5,
      "resolution": "720p",
      "aspect_ratio": "16:9",
      "generate_audio": true
    }
  }'
{
  "id": "gen_6f1c…",
  "object": "generation",
  "model": "seedance-2.5",
  "type": "video",
  "provider": "kie",
  "status": "processing",        // queued | processing | succeeded | failed
  "input": { "prompt": "…", "duration": 5, "resolution": "720p", "aspect_ratio": "16:9", "generate_audio": true },
  "outputs": [],
  "error": null,
  "credits": 512,
  "price_usd": 2.0475,
  "created_at": "2026-10-23T08:00:00.000Z",
  "completed_at": null
}

获取结果

每隔几秒轮询,直到 status 为 succeeded 或 failed。输出链接由供应商托管,可能过期,请及时下载保存。

curl https://01router.com/api/v1/generations/gen_6f1c… -H "Authorization: Bearer $API_KEY"

{ "id": "gen_6f1c…", "status": "succeeded", "outputs": ["https://…/video.mp4"], … }

音频模型

音乐(Suno)和语音合成(Gemini TTS)模型与图片、视频一样走 /generations:先创建任务再轮询,输出为音频文件 URL。

curl https://01router.com/api/v1/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.8-flash-tts",
    "input": { "prompt": "Welcome back, let us get started.", "voice": "Kore", "style_instructions": "warm and upbeat" }
  }'

{ "id": "gen_9a2d…", "type": "audio", "status": "succeeded", "outputs": ["https://…/speech.wav"], … }

对话补全

对话模型(GPT、Claude、Gemini、Grok、DeepSeek 等)使用 OpenAI Chat Completions 格式,官方 OpenAI SDK 将 base URL 设为 https://01router.com/api/v1 即可调用。传 "stream": true 获得 SSE 流式输出。调用前按输入 + max_tokens(未传时为 4096)预扣积分,回复结束后按实际 token 用量结算;请求 ID 会出现在 X-Gateway-Request-Id 响应头和任务日志中。

curl https://01router.com/api/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5.5",
    "messages": [{ "role": "user", "content": "Write a haiku about routers" }],
    "max_tokens": 512,
    "stream": true
  }'
from openai import OpenAI

client = OpenAI(base_url="https://01router.com/api/v1", api_key="sk_…")
res = client.chat.completions.create(
    model="gpt-6-sol",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(res.choices[0].message.content, res.usage)

供应商路由

未指定 provider 时,我们会用每个供应商支持的取值校验参数并报价,提交给最便宜的供应商;提交失败会退款并尝试下一个(最多 3 家)。指定 provider 时只会发往该供应商。

报价

请求体与创建任务相同。返回按价格排序的可用供应商,以及无法处理该请求的供应商及原因。

curl https://01router.com/api/v1/quote -H "Content-Type: application/json" \
  -d '{ "model": "nano-banana-pro", "input": { "prompt": "poster", "resolution": "2K" } }'

{
  "model": "nano-banana-pro",
  "providers": [
    { "provider": "kie", "provider_name": "KIE AI", "unit": "image", "quantity": 1, "price_usd": 0.117, "credits": 30 },
    { "provider": "openrouter", … }
  ],
  "unavailable": [{ "provider": "atlascloud", "reason": "resolution must be one of 1K, 2K" }]
}

计费

任务提交时按所选供应商对应参数的价格扣除积分(视频按秒、图片按张或按次)。失败或超时的任务会自动退还积分。

错误码

{ "error": { "message": "Insufficient credits: this request costs 512 credits", "code": "insufficient_credits" } }
400invalid_request请求体或参数取值不合法
401unauthorized缺少或无效的 API Key
402insufficient_credits积分不足
404not_found模型或任务不存在
429rate_limited请求过于频繁,请稍后重试
502upstream_error所有供应商都拒绝了任务(积分已退回)
503no_provider没有供应商支持这些参数

全部模型 ID 与参数: 模型