genmux API 现已全面开放。 查看文档 →
genmux API

参考

GET /v1/account

curl -s https://api.genmux.tech/v1/account -H "Authorization: Bearer $API_KEY"
Response · 200 OK
{
  "id": "…",
  "name": "…",
  "balance": 498,
  "inflight": 1,
  "max_inflight": 20,
  "key": {"prefix": "nb_live_AbCdEfGh", "rate_limit_rps": 10}
}

GET /v1/models

返回公开的模型目录——模型 id、每个模型接受的分辨率档位与宽高比、各档位的积分价格,以及可用状态。无需认证。

可用模型

你现在就能调用的模型,直接来自这份目录——把 id 复制进代码或智能体配置即可。

模型 id类型上下文 / 分辨率工具输入输出
Nano Banana
nanobanana
图像1K—
2
积分 / 张
—
Nano Banana Pro
nanobanana-pro
图像1K · 2K · 4K—
4
积分 / 张
—
Qwen-Image 2.0
qwen-image-2
图像1K · 2K—
3
积分 / 张
—
Qwen-Image Max
qwen-image-max
图像1K · 2K—
8
积分 / 张
—
Seedream 5.0
seedream-5
图像2K · 4K—
16
积分 / 张
—
Wan 2.7 Image
wan-2-7-image
图像1K · 2K—
2
积分 / 张
—
Doubao Seed 2.0 Pro
doubao-seed-2-pro
对话256K支持
85
积分 / 100 万 token
408
积分 / 100 万 token
Doubao Seed 2.0 Code
doubao-seed-2-code
对话256K支持
85
积分 / 100 万 token
408
积分 / 100 万 token
Doubao Seed 2.0 Lite
doubao-seed-2-lite
对话256K—
17
积分 / 100 万 token
85
积分 / 100 万 token
Doubao Seed 2.0 Mini
doubao-seed-2-mini
对话256K—
2.146
积分 / 100 万 token
68
积分 / 100 万 token
Kimi K3
kimi-k3
对话1M支持
197.028
积分 / 100 万 token
985.815
积分 / 100 万 token
Claude Opus 5.5
claude-opus-5-5
对话200K支持
146.88
积分 / 100 万 token
734.4
积分 / 100 万 token
Claude Fable 5.1
claude-fable-5-1
对话200K支持
1,700
积分 / 100 万 token
1,700
积分 / 100 万 token
GPT-6 Astra
gpt-6-astra
对话128K支持
68
积分 / 100 万 token
340
积分 / 100 万 token
GPT-5.6 Terra
gpt-5.6-terra
对话128K支持
17
积分 / 100 万 token
170
积分 / 100 万 token
Qwen3.8-Max
qwen3.8-max
对话1M支持
138.718
积分 / 100 万 token
416.161
积分 / 100 万 token

把模型 id 直接复制进代码或智能体配置。实时取自 GET /v1/models——只列出你现在就能调用的模型。

curl -s https://api.genmux.tech/v1/models
Response · 200 OK
{
  "object": "list",
  "data": [
    {
      "id": "nanobanana",
      "object": "model",
      "created": 1756411279,
      "owned_by": "genmux",
      "display_name": "Nano Banana",
      "description": "Fast text-to-image and image-to-image at 1K.",
      "capability": "image.generate",
      "status": "active",
      "params_schema": {
        "resolutions": ["1K"],
        "ratios": ["auto", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5", "21:9"],
        "max_n": 4,
        "seed": true,
        "max_images": 14,
        "negative_prompt": true,
        "max_prompt": 2000
      },
      "default_params": {"resolution": "1K", "ratio": "1:1", "n": 1},
      "prices": {"image:1K": 2},
      "available": true
    },
    {
      "id": "nanobanana-pro",
      "object": "model",
      "created": 1756411279,
      "owned_by": "genmux",
      "display_name": "Nano Banana Pro",
      "description": "Higher fidelity, with 1K, 2K and 4K output.",
      "capability": "image.generate",
      "status": "active",
      "params_schema": {
        "resolutions": ["1K", "2K", "4K"],
        "ratios": ["auto", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5", "21:9"],
        "max_n": 4,
        "seed": true,
        "max_images": 14,
        "negative_prompt": true,
        "max_prompt": 2000
      },
      "default_params": {"resolution": "1K", "ratio": "1:1", "n": 1},
      "prices": {"image:1K": 4, "image:2K": 6, "image:4K": 8},
      "available": true
    },
    {
      "id": "qwen3.8-max",
      "object": "model",
      "created": 1756411279,
      "owned_by": "genmux",
      "display_name": "Qwen3.8-Max",
      "description": "Alibaba Qwen3.8-Max via gateway: flagship Qwen with a 1M-token context.",
      "capability": "text.chat",
      "status": "active",
      "params_schema": {
        "tools": true,
        "context_tokens": 1000000,
        "max_output_tokens": 16384,
        "default_max_tokens": 2048
      },
      "default_params": {
        "max_tokens": 2048,
        "temperature": 0.7
      },
      "prices": {
        "tokens_in:1M": 138.718,
        "tokens_out:1M": 416.161
      },
      "available": true
    }
  ]
}

价格以分辨率档位为键:image:1K, image:2K, image:4K。模型在 params_schema 中声明它接受什么 —— resolutions, ratios, max_images(参考图;没有该字段表示不支持图生图)以及 negative_prompt。目录条目可能仍带有旧版的 sizes 列表和对应的 image:WIDTHxHEIGHT 价格,供仍在发送废弃的 size 字段的客户端使用;除非你就是这种情况,否则两者都可以忽略。

文本模型带有 capability: "text.chat"、一个 params_schema(包含上下文窗口、max_tokens 上限与默认值)以及 thinking, web_search, vision, tools 标志,价格以 tokens_in:1M / tokens_out:1M 为键,单位是每百万 token 的积分。列表的 object 为 list,每一行的 object 为 model,带 created 和 owned_by;GET /v1/models/{id} 返回其中一行。

模型与价格

任务费用 = 每张图片积分(见下)× n。提交时预留,任务失败或被取消时全额退回。

模型
1K
长边约 1024 像素
2K
长边约 2048 像素
4K
长边约 4096 像素
nanobanana
每次请求最多 4 张图片
2积分
≈ $0.025 / 张
——
nanobanana-pro
每次请求最多 4 张图片
4积分
≈ $0.05 / 张
6积分
≈ $0.075 / 张
8积分
≈ $0.10 / 张
qwen-image-2
每次请求最多 4 张图片
3积分
≈ $0.038 / 张
4积分
≈ $0.05 / 张
—
qwen-image-max
每次请求最多 4 张图片
8积分
≈ $0.10 / 张
9积分
≈ $0.113 / 张
—
seedream-5
每次请求最多 4 张图片
—
16积分
≈ $0.20 / 张
18积分
≈ $0.225 / 张
wan-2-7-image
每次请求最多 4 张图片
2积分
≈ $0.025 / 张
3积分
≈ $0.038 / 张
—

用 resolution 选择档位,用 ratio 选择画幅。金额按最划算的套餐折算(每积分 $0.013)。费用 = 积分 × n;失败的任务全额退款。

对话请求费用 = prompt token × 输入费率 + 回复 token(含推理)× 输出费率,单位是每 100 万 token 的积分(见下)。积分是小数:对话请求精确扣费到小数点后三位,余额和流水也会显示小数积分。图像生成仍然是每张整数积分。

模型上下文工具输入 / 100 万输出 / 100 万
doubao-seed-2-pro
256K支持
85积分
$1.063
≈ $0.0011 / 1000
408积分
$5.10
≈ $0.0051 / 1000
doubao-seed-2-code
256K支持
85积分
$1.063
≈ $0.0011 / 1000
408积分
$5.10
≈ $0.0051 / 1000
doubao-seed-2-lite
256K—
17积分
$0.213
≈ $0.0002 / 1000
85积分
$1.063
≈ $0.0011 / 1000
doubao-seed-2-mini
256K—
2.146积分
$0.027
≈ $0.00 / 1000
68积分
$0.85
≈ $0.0009 / 1000
kimi-k3
1M支持
197.028积分
$2.463
≈ $0.0025 / 1000
985.815积分
$12.323
≈ $0.0123 / 1000
claude-opus-5-5
200K支持
146.88积分
$1.836
≈ $0.0018 / 1000
734.4积分
$9.18
≈ $0.0092 / 1000
claude-fable-5-1
200K支持
1,700积分
$21.25
≈ $0.0213 / 1000
1,700积分
$21.25
≈ $0.0213 / 1000
gpt-6-astra
128K支持
68积分
$0.85
≈ $0.0009 / 1000
340积分
$4.25
≈ $0.0043 / 1000
gpt-5.6-terra
128K支持
17积分
$0.213
≈ $0.0002 / 1000
170积分
$2.125
≈ $0.0021 / 1000
qwen3.8-max
1M支持
138.718积分
$1.734
≈ $0.0017 / 1000
416.161积分
$5.202
≈ $0.0052 / 1000

每 100 万 token 消耗的积分;请求里的每条消息都算输入,回复(含推理)算输出。金额按最划算的套餐折算(每积分 $0.013)。没有产生 token 则不扣费。

错误

错误使用 application/problem+json。按 code; request_id 匹配,它同时也会出现在 X-Request-ID 响应头里——联系支持时请一并提供,邮箱 support@genmux.tech。

{"type": "…/errors/insufficient_credits", "title": "Payment Required", "status": 402, "code": "insufficient_credits", "detail": "account balance is too low for this request", "request_id": "…"}

例外:POST /v1/chat/completions(且仅此一条路由)使用 OpenAI 的错误结构 —— {"error": {"message", "type", "code", "param", "request_id"}} —— type 取值为 invalid_request_error、authentication_error、permission_error、insufficient_quota、rate_limit_error、not_found_error、server_error 之一,这样 OpenAI SDK 和编程智能体里的重试逻辑就能识别限流和额度不足。下面的 code 取值在两种路由上是一致的。

Chat route · OpenAI envelope
{"error": {"message": "account balance is too low for this request", "type": "insufficient_quota", "code": "insufficient_credits", "param": null, "request_id": "…"}}
HTTPcode何时出现
400validation_error字段错误或缺失、未知字段、缺少 Idempotency-Key。
400unsupported_parameter对话:接口不支持的字段(n > 1、旧版 functions、logprobs、在无 vision 的模型上使用 image_url、在不支持的模型上使用 enable_thinking / web_search)。
400tools_unsupported对话:向目录条目没有 tools: true 的模型发送了 tools。
400context_length_exceeded对话:消息(加上 max_tokens)超出模型的上下文窗口。不扣费。
401unauthorizedAPI 密钥缺失、已吊销或已过期。
402insufficient_credits余额低于任务费用。请在控制台购买积分,或联系 support@genmux.tech。
403ip_not_allowed密钥设置了 IP 白名单,而你的地址不在其中。
404not_found未知的任务 id(或它属于其他账户)。
404model_not_found未知的模型 id。当前目录见 GET /v1/models。
409conflict任务在当前状态下无法取消。
409idempotency_key_reused对话:可选的 Idempotency-Key 已被另一次补全使用过。
422idempotency_key_mismatch同一个 Idempotency-Key 配了不同的请求体。
429rate_limited超出单密钥请求速率。请遵守 Retry-After。需要更高上限?请联系 support@genmux.tech。
429too_many_inflight排队或执行中的任务超过 max_inflight。请等待部分任务完成。
502upstream_error模型供应商失败或超时。未产生 token 的请求不扣费;请重试。
502json_invalid对话:自动重试后回复仍不满足 response_format。两次尝试都计费。
503model_unavailable该模型暂时被停用——不扣费。请稍后重试或换一个模型。
500internal_error我们这边的问题。用同一个 Idempotency-Key 重试即可——不会重复扣费。

速率限制

每把密钥有每秒请求数限制(默认 10),每个账户有并发任务上限(默认 20)。触发限制的响应是 429,并带有以秒为单位的 Retry-After 响应头。需要更高上限?请联系 support@genmux.tech。

Webhook

创建任务时传 webhook_url(仅限 https,公网主机)。任务完成时我们会 POST 一次,并按退避重试最多 8 次,直到你返回 2xx。

POST <webhook_url>
Content-Type: application/json
X-Webhook-Id: 1042
X-Webhook-Timestamp: 1756411279
X-Webhook-Signature: v1=3f7a…

{"type": "generation.succeeded", "id": "…", "status": "succeeded", "error_code": null, "created_at": "…", "finished_at": "…"}

用你账户的 webhook 密钥(控制台 → 设置)验证签名:HMAC-SHA256(secret, timestamp + "." + raw_body),十六进制编码,与 v1= 后面的值比对。密钥轮换期间会发送两个签名,用逗号分隔——任意一个通过即可。请拒绝超过 5 分钟的时间戳。

Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(secret, headers, rawBody) {
  const ts = headers["x-webhook-timestamp"];
  const expected = createHmac("sha256", secret).update(ts + "." + rawBody).digest("hex");
  return headers["x-webhook-signature"].split(",")
    .some((s) => { const v = s.replace(/^v1=/, ""); return v.length === expected.length && timingSafeEqual(Buffer.from(v), Buffer.from(expected)); });
}