Download OpenAPI specification:
一个 OpenAI 兼容的模型网关,外加子钥签发与对账接口
完整的说明性文档在 www.jamerly.ai/docs/tare(中英双语)。
⚠️ 2026-11-26.1:新增决策接口 POST /v1/decisions(同一个接口也挂在 Jev 的路径名
POST /v1/systemone 上):一段文本 + 若干个问题,回每个答案的概率(是非 / 单选 / 打分)。
线格式与 TypeSafe Jev、OpenRouter Decisions 相同。都是新增,已有接口不变。
⚠️ 2026-11-23.1:子钥按天的用量。Key 新增 usage_daily(今天)、usage_weekly(本周,
周一起)、usage_monthly(本月,1 号起)三个字段,与 OpenRouter GET /api/v1/key 同名;
按账期时区切天,清零不影响。新增 GET /v1/keys/usage/daily(账号下全部子钥)、
GET /v1/keys/{hash}/usage/daily、GET /v1/keys/external/{externalId}/usage/daily,
每行是一把 key 一天(可再按模型拆)的花费、请求数和 token 数。都是新增,已有字段不变。
⚠️ 2026-11-20.1:新增管理钥(keyType: management,在控制台创建)与 /v1/manage/*:
用一把 key 配渠道(/v1/manage/providers)、路由(/v1/manage/routers)和 DLP
(/v1/manage/dlp),处理器与控制台同一份,响应是 ApiResponse 形状。管理钥只能调这一组,
别的 key 和控制台会话都调不了这一组;渠道试聊(/providers/{id}/chat)对管理钥关闭。
DLP 新增客户自定义规则(/v1/manage/dlp/rules*)与能力目录(/v1/manage/dlp/capabilities),
以及 10 种台湾 / 菲律宾证件号内置类型。已有接口行为不变。
⚠️ 2026-11-10.1:子钥额度可以清零。新增 POST /v1/keys/{hash}/reset 与
POST /v1/keys/external/{externalId}/reset(立刻清零),创建和修改子钥时新增
limit_reset(daily / weekly / monthly,按 UTC 自动清零,与 OpenRouter 同名同义)。
Key 新增 limit_reset、limit_usage、limit_reset_at 三个字段,limit_remaining
改为按 limit_usage 计算。从没清零过的 key,limit_usage 等于 usage,返回值和以前一样。
⚠️ 2026-09-28.1:又是补文档不是补功能——/v1/images、/v1/images/generations
这两个路径此前完全没在这份契约文件里出现过(服务端早就有);顺带把 /v1/embeddings
的请求体补上 models/provider 两个字段(早已生效,只是没写)。接口行为本身
没有任何变化。
⚠️ 2026-09-27.2:补文档,不是补功能——/v1/videos/generations(异步视频生成)
和 /v1/mocks/*(演习失败场景)在服务端已经上线一段时间,这次才第一次写进这份
契约文件。接口行为本身没有任何变化。 顺手修正了下方「两种响应形状」表格里的一处
不准确:/v1/mocks/* 走的是 ApiResponse 信封,不是只有 /v1/integration/* 才用它。
⚠️ 2026-09-27.1:/v1/chat/completions 新增 models(备用模型链)与 provider
(按次路由偏好)两个请求字段,GET /v1/generation 新增 latency/generation_time/
routing_overhead_ms/time_to_first_token_ms 四个耗时字段。都是新增字段,
不改任何已有形状——不传就是今天的行为。
⚠️ 2026-09-01.1:新增「来源 IP 白名单」(见下方鉴权一节与 refusal_reason
的 source_ip_not_allowed)。这是账号侧的开关,不改任何接口形状 —— 没开的
key 行为一个字节都没变。
⚠️ 2026-08-22.4:.3 曾以缺两段的形式发布过(chat 端点与
Generation.upstream_inference_cost 关于「转售不返回上游成本」的说明在发布流程中
丢失)。行为本身从 0.1.13 起就是这样,丢的只是文字。拿过 .3 的话请重新拉一份。
这份文件只描述 接口形状,不重复文档里的那些判断依据(为什么额度用尽是 403、为什么流式末帧 两种方言不一致等等)——接入前请两份一起读。
全部接口都用 Authorization: Bearer <key>。三类 key 权限互不重叠,用错类型返回明确的
拒绝,而不是含糊的 401:
| key | 能做什么 |
|---|---|
| 推理 key | 调模型(/v1/chat/completions、/v1/embeddings、/v1/models、/v1/generation) |
| 母钥 | 管子钥(/v1/keys/*),不能调模型 |
| 对账 key | 读账(/v1/integration/*),不能调模型 |
每一把 key 都可以限定「只许从这些地址调用」(控制台 → API Keys → 编辑那把 key)。
名单外的调用返回 403 + metadata.refusal_reason = source_ip_not_allowed,
key 本身仍然有效 —— 这不是吊销,换一台在名单上的机器就能用。
⚠️ 要填的是你的服务器出网的那个地址,不是内网地址,也不是你打开控制台那台 电脑的地址(两者通常不同)。控制台上会显示「我们看到这台浏览器是 X」,那只是一个 参照,不要直接把它填进去。
⚠️ 名单区分 IPv4 和 IPv6:填了 203.0.113.7 而你的机器某天走 IPv6 出网,同样会被
拒。两种都可能用到的话,两个段都加。
⚠️ 关掉这道闸和清空名单是两件事。开着而名单为空 = 全部拒绝,不是全部放行。
除了 Authorization(和流式的 Accept: text/event-stream),不要求任何请求头。
⚠️ 未识别的请求头一律忽略,不会因此拒绝请求,也不会转发给上游。 发往上游的请求头
由我们重建(凭据、Content-Type、方言要求的那几个),你带的头不会出现在上游那一侧。
OpenRouter 的归因头 HTTP-Referer / X-Title 属于这一类:带上无害,但不会到达任何
地方,也不影响路由、计费和限流。
归因请改用 usage_label(请求体内,原样落进用量记录)和子钥本身。
所有时间戳都是 ISO 8601。⚠️ 不带偏移量的那些(2026-08-21T17:30:00)按
Asia/Shanghai(UTC+8)解释 —— 它们是服务端本地时间。账期也按这个时区切,
/v1/integration/whoami 会返回当时使用的时区,以该字段为准,不要硬编码。
| 接口 | 形状 | 失败时 |
|---|---|---|
/v1/chat/completions、/v1/embeddings、/v1/images*、/v1/keys/*、/v1/models、/v1/generation、/v1/videos/generations* |
OpenAI:{"error":{...}} |
HTTP 非 2xx |
/v1/integration/*、/v1/mocks/* |
ApiResponse:{"code","message","data","success"} |
HTTP 非 2xx,body 仍是 ApiResponse(不是 200 + success:false) |
请求体原样透传:未识别的字段照发给上游,这是 cache_control、reasoning、
plugins 这类字段能工作的原因。我们只改动四处:模型名换成上游认的、stream
固定为本次尝试的模式、流式强制 stream_options.include_usage=true、剥除归因字段。
⚠️ models、provider 是例外——它们被我们消费掉,不转发给上游。
原样转发的话,OpenRouter 自己也认识这两个字段名,会拿我们内部的模型名/渠道名
去做它自己的一轮转移/过滤(2026-09-27 实测过这个事故),所以这两个和
cache_control 那类「未识别就透传」的字段不是一回事。
models**(字符串数组):备用模型链。model 全不可用(没配路由,或配了但
候选全部熔断/耗尽)时依次退到这里的第一个,那个也不行再往下一个。model
仍然必填、永远第一优先级,这个数组只在它失败之后才生效。provider**(对象):按次路由偏好,只影响「这次能打哪几家」,不改
「打不通了怎么办」。字段:order(string[],按这个顺序优先尝试的渠道名)、
only(string[],白名单)、ignore(string[],黑名单)、allow_fallbacks
(boolean,默认 true;false 时只用 order/only 点到的渠道,一个都打不通
就失败)、sort(目前只认 "latency",按实测平均延迟从快到慢重排;
"price"/"throughput" 会被当成没传,不报错)。only/ignore/order
过滤完一条候选都不剩时是 400,不是 404——那是你的偏好写错了,不是模型
没配置。⚠️ usage.cost 是「花了你多少」。 走平台渠道(token 的钱由我们垫)时,回包中
不含 usage.cost_details —— 那一格是上游向我们收取的金额。BYOK 下保留:
那是你自己上游账单上的钱,也正是成本归因需要的数据。
(2026-08-22 之前两种模式都返回了;已修。)
算不出来时 cost 整格不出现,而不是 0 —— 「该模型尚未定价」也算算不出来。
⚠️ 两种上游方言的流式末帧形状不一致(OpenAI 兼容是 choices: [],Anthropic 是
choices 有一项而 delta 为空)。按帧渲染时判据写成「choices 为空 或 delta
无内容 → 跳过渲染,只取 usage」。
| model required | string 平台侧模型名,取自 |
| models | Array of strings 备用模型链,按顺序尝试。 |
object 按次路由偏好,详见上方说明 | |
required | Array of objects |
| stream | boolean Default: false |
| max_tokens | integer |
| temperature | number |
| usage_label | string 你自己的归因标签,会原样落进用量记录,基数不设上限 |
| property name* additional property | any |
{- "model": "GLM 5.1",
- "models": [
- "GLM 5.1",
- "GPT-5.6 Sol"
], - "provider": {
- "order": [
- "string"
], - "allow_fallbacks": true,
- "only": [
- "string"
], - "ignore": [
- "string"
], - "sort": "latency"
}, - "messages": [
- {
- "role": "system",
- "content": null
}
], - "stream": false,
- "max_tokens": 0,
- "temperature": 0,
- "usage_label": "string"
}{- "id": "string",
- "object": "chat.completion",
- "created": 0,
- "model": "string",
- "provider": "string",
- "choices": [
- null
], - "usage": {
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "total_tokens": 0,
- "cost": 0,
- "is_byok": true
}
}请求体原样透传(models、provider 除外,见下),回包是上游原文加一格
usage.cost。
⚠️ 模型名不做映射。 chat 那边写的是我们这边的模型名(取自 GET /models),
这里写的是上游自己的名字(text-embedding-3-small 这一类)——
embeddings 不走模型路由表,所以没有那层映射,回包里的模型名同样不改写。
⚠️ 打到哪条渠道:你自己的渠道优先(显式配的 > 按方言推出来的), 都没有才走平台那条被指定的渠道。 两者的计费不同(自己的渠道只记账,平台渠道按售价扣余额),所以不会在两者 之间自动故障转移 —— 一次静默的回退等于在你没同意的情况下开始花钱。 自己的渠道之间会互相故障转移(计费模式一样,换一条不改变你付多少)。
⚠️ models、provider 也在这里生效,但 models 的含义和 chat 不完全一样。
embeddings 没有路由表可以映射,所以 models 里的名字是另一个上游原始模型名,
不是平台名字——外层按这条链换名字,每换一个都要把你全部自有渠道重新试一轮,
等这一个模型名在所有渠道上都失败了才换下一个。provider 的行为和 chat 完全一样:
只调整/过滤你自己渠道的顺序,不会把平台渠道拉进来。两者都会在转发前被剥掉,
原因见 /chat/completions 上的同一条说明。
没有流式。gen- 编号走响应头,用法和 chat 一致。
| model required | string 上游的模型名(不是 |
| models | Array of strings 备用上游模型名链(不是平台名字,见上方说明)。最多 5 个。 |
object 按次路由偏好,字段和语义与 | |
required | string or Array of strings 字符串或字符串数组 |
| dimensions | integer |
| encoding_format | string Enum: "float" "base64" |
| usage_label | string 你自己的归因标签,会原样落进用量记录 |
| property name* additional property | any |
{- "model": "text-embedding-3-small",
- "models": [
- "text-embedding-3-small",
- "text-embedding-3-large"
], - "provider": {
- "order": [
- "string"
], - "allow_fallbacks": true,
- "only": [
- "string"
], - "ignore": [
- "string"
], - "sort": "latency"
}, - "input": "string",
- "dimensions": 0,
- "encoding_format": "float",
- "usage_label": "string"
}{- "object": "list",
- "model": "string",
- "data": [
- {
- "object": "embedding",
- "index": 0,
- "embedding": [
- 0
]
}
], - "usage": {
- "prompt_tokens": 0,
- "total_tokens": 0,
- "cost": 0
}
}POST /images/generations 是同一个接口——请求和回包完全一样,两个路径都通。
路由按模型名,和 /chat/completions 同一套:故障转移、models 备用链、provider
按次路由偏好都一样生效(三个字段的语义见 /chat/completions 上的说明,models/
provider 同样会被剥掉、不转发给上游)。余额/预算/key 额度三道门禁在每一个候选
上都会查一遍,不只是第一个——两条候选可能计费方式不同(自己的渠道 vs 平台渠道),
静默换到第二条又不重新检查等于在客户没同意的情况下开始花钱。
除具名字段外,其余字段(size、aspect_ratio、n、input_references、供应商私有
参数)原样转发给上游;上游不认的字段会返回上游自己的报错,不是这边的。
⚠️ data 可以是空数组,这不是错误。 模型可能只回文字、或者被上游自己的内容
策略拦下——两种都是 200,原因写在 finish_reason/text 里,不会被重新分类成失败。
⚠️ 不要把 url 存进你自己的数据库。 它 24 小时后失效,在失效之前和永久链接
没有区别。要长期保存请存 b64_json,或者把字节复制到你自己的存储。
无流式。
| model required | string 平台侧模型名,或你在 Routing 页配过的一条 |
| prompt required | string |
| models | Array of strings 备用模型链,语义与 |
object 按次路由偏好,语义与 | |
| size | string |
| aspect_ratio | string |
| n | integer |
| input_references | Array of strings 参考图的公网 HTTPS 地址(图生图/图片编辑) |
| property name* additional property | any |
{- "model": "google/gemini-3-pro-image",
- "prompt": "string",
- "models": [
- "string"
], - "provider": {
- "order": [
- "string"
], - "allow_fallbacks": true,
- "only": [
- "string"
], - "ignore": [
- "string"
], - "sort": "latency"
}, - "size": "string",
- "aspect_ratio": "16:9",
- "n": 0,
- "input_references": [
- "string"
]
}{- "id": "string",
- "created": 0,
- "model": "string",
- "data": [
- {
- "b64_json": "string",
- "media_type": "image/png",
- "url": "string",
- "expires_at": 0
}
], - "text": "string",
- "finish_reason": "string",
- "usage": {
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "total_tokens": 0,
- "cost": 0
}
}| model required | string 平台侧模型名,或你在 Routing 页配过的一条 |
| prompt required | string |
| models | Array of strings 备用模型链,语义与 |
object 按次路由偏好,语义与 | |
| size | string |
| aspect_ratio | string |
| n | integer |
| input_references | Array of strings 参考图的公网 HTTPS 地址(图生图/图片编辑) |
| property name* additional property | any |
{- "model": "google/gemini-3-pro-image",
- "prompt": "string",
- "models": [
- "string"
], - "provider": {
- "order": [
- "string"
], - "allow_fallbacks": true,
- "only": [
- "string"
], - "ignore": [
- "string"
], - "sort": "latency"
}, - "size": "string",
- "aspect_ratio": "16:9",
- "n": 0,
- "input_references": [
- "string"
]
}{- "id": "string",
- "created": 0,
- "model": "string",
- "data": [
- {
- "b64_json": "string",
- "media_type": "image/png",
- "url": "string",
- "expires_at": 0
}
], - "text": "string",
- "finish_reason": "string",
- "usage": {
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "total_tokens": 0,
- "cost": 0
}
}给一段文本(或任意 JSON)和若干个按名字列出的问题,返回每个问题各个答案的概率,不生成文字。
三种题型:noul(是非题,回 P(yes))、choice(单选,回最可能的选项、每个选项的概率和 confidence)、
score(打分,回期望档位、每档概率和 confidence)。同一段文本问多个问题只读一遍。
POST /systemone 是同一个接口(TypeSafe Jev / Microsoft Foundry 的叫法):用 Jev SDK 的代码改一下
base URL 就能用。
路由按模型名,和 /chat/completions 同一套客户路由 → 平台兜底与故障转移;DLP 扫 state 和
每个问题的文本。按 token 计费,价目是这个模型单独的一行(只收输入,输出免费),回包
usage.cost 就是这次的扣费。
不支持 models 备用链和 provider 路由偏好,也不流式(带 stream: true 返回 400)。
⚠️ confidence 低的结果请交给人工,或者换更强的模型复核;概率不是规则引擎的结论——日期比较、
金额相加这类计算请在你自己的代码里做,把结论写进问题里再问。
| model required | string |
required | string or object or Array of arrays 问题针对的文本;也可以是任意 JSON(对象或数组),里面的字符串都会被读到 |
required | object 按名字列的问题,最多 64 个;回包 |
{- "model": "microsoft/microsoft-decision-1",
- "state": "我上周买的芒果酸奶送到的时候盒子是空的,这已经是第二次了!",
- "questions": {
- "complaint": {
- "type": "noul",
- "instructions": "顾客是否在投诉?"
}, - "team": {
- "type": "choice",
- "instructions": "这条消息应该交给哪个组处理?",
- "criteria": {
- "billing": "付款、扣费、退款",
- "shipping": "配送、缺件、送错",
- "product": "商品质量、口味"
}
}, - "anger": {
- "type": "score",
- "instructions": "顾客有多生气?",
- "criteria": [
- "平静",
- "不满",
- "生气",
- "非常愤怒"
]
}
}
}{- "id": "string",
- "model": "string",
- "answers": {
- "property1": {
- "type": "noul",
- "noul": 0,
- "choice": "string",
- "score": 0,
- "legend": {
- "property1": "string",
- "property2": "string"
}, - "probabilities": {
- "property1": 0,
- "property2": 0
}, - "confidence": 0
}, - "property2": {
- "type": "noul",
- "noul": 0,
- "choice": "string",
- "score": 0,
- "legend": {
- "property1": "string",
- "property2": "string"
}, - "probabilities": {
- "property1": 0,
- "property2": 0
}, - "confidence": 0
}
}, - "usage": {
- "input_tokens": 0,
- "output_tokens": 0,
- "cost": 0
}
}| model required | string |
required | string or object or Array of arrays 问题针对的文本;也可以是任意 JSON(对象或数组),里面的字符串都会被读到 |
required | object 按名字列的问题,最多 64 个;回包 |
{- "model": "microsoft/microsoft-decision-1",
- "state": "我上周买的芒果酸奶送到的时候盒子是空的,这已经是第二次了!",
- "questions": {
- "complaint": {
- "type": "noul",
- "instructions": "顾客是否在投诉?"
}, - "team": {
- "type": "choice",
- "instructions": "这条消息应该交给哪个组处理?",
- "criteria": {
- "billing": "付款、扣费、退款",
- "shipping": "配送、缺件、送错",
- "product": "商品质量、口味"
}
}, - "anger": {
- "type": "score",
- "instructions": "顾客有多生气?",
- "criteria": [
- "平静",
- "不满",
- "生气",
- "非常愤怒"
]
}
}
}{- "id": "string",
- "model": "string",
- "answers": {
- "property1": {
- "type": "noul",
- "noul": 0,
- "choice": "string",
- "score": 0,
- "legend": {
- "property1": "string",
- "property2": "string"
}, - "probabilities": {
- "property1": 0,
- "property2": 0
}, - "confidence": 0
}, - "property2": {
- "type": "noul",
- "noul": 0,
- "choice": "string",
- "score": 0,
- "legend": {
- "property1": "string",
- "property2": "string"
}, - "probabilities": {
- "property1": 0,
- "property2": 0
}, - "confidence": 0
}
}, - "usage": {
- "input_tokens": 0,
- "output_tokens": 0,
- "cost": 0
}
}异步:这一步只把任务提交上去,立刻返回 status: pending,真正的生成是分钟级的。
用返回的 id 轮询 GET /v1/videos/generations/{id}。
⚠️ 轮询不会打到上游去。 生成进度由服务端后台统一拉取,客户端查多勤都不影响 对上游的调用频率——这和 chat/embeddings 那种「一次请求就是一次上游调用」不一样, 轮询本身的成本和节奏由我们控制,不是把这个决定权交给调用方的查询习惯。
⚠️ callback_url 目前只接收、不投递。 字段会被原样存下来,但没有任何 webhook
会被真正发出——现在唯一能知道任务完成的办法是轮询。传了它不会报错,也不会在某天
突然开始收到回调;如果你现在的代码是「传了 callback_url 就不轮询」,请改成轮询。
models(备用模型链)和 provider(按次路由偏好,order/only/ignore/
allow_fallbacks/sort)两个字段和 /v1/chat/completions 是同一套解析逻辑,
语义完全一致,见该接口的说明;这里同样不会转发给上游。
不认识的顶层字段原样收进供应商特定参数(比如某些模型要的分辨率、种子数), 原样透传给上游,不做校验。
| model required | string 取自 |
| models | Array of strings 备用模型链,语义同 |
| provider | object 按次路由偏好,语义同 |
| prompt required | string |
| duration_seconds | integer |
| aspect_ratio | string |
| reference_image_url | string |
| reference_video_url | string |
| callback_url | string ⚠️ 目前只存不投递,见上方说明 |
| property name* additional property | any |
{- "model": "string",
- "models": [
- "string"
], - "provider": { },
- "prompt": "string",
- "duration_seconds": 0,
- "aspect_ratio": "16:9",
- "reference_image_url": "string",
- "reference_video_url": "string",
- "callback_url": "string"
}{- "id": "string",
- "status": "pending",
- "model": "string",
- "created": 0,
- "completed": 0,
- "result": {
- "video_url": "string",
- "video_urls": [
- "string"
]
}, - "usage": {
- "video_tokens": 0
}, - "error": {
- "message": "string"
}
}{- "id": "string",
- "status": "pending",
- "model": "string",
- "created": 0,
- "completed": 0,
- "result": {
- "video_url": "string",
- "video_urls": [
- "string"
]
}, - "usage": {
- "video_tokens": 0
}, - "error": {
- "message": "string"
}
}完整明文只在创建时返回一次。带 external_id 时同一个编号重复创建是幂等的:
返回已存在的那把,HTTP 状态码是 200 而不是 201。
⚠️ 幂等重放只在创建后 5 分钟内能拿回明文。超过窗口 key 是 null,
并附 key_unavailable_reason(枚举值)和 key_unavailable_message(文案会变)。
| name required | string 用途说明,由你填写;原样进入账单归因 |
| limit | number or null 消费上限(美元)。不传 = 不限额。设了 |
| limit_reset | string or null Enum: "daily" "weekly" "monthly" null 额度多久自动清零一次。不传 = 不自动清零(花完为止)。 边界按 UTC:每天 00:00、每周一 00:00、每月 1 日 00:00,过了边界一分钟内生效。 |
| external_id | string 你自己的编号,用来做创建幂等;唯一性是 (账号, external_id) |
| include_byok_in_limit | boolean Default: true BYOK 渠道的消耗算不算进这把 key 的上限 |
| expires_at | string 形如 |
{- "name": "string",
- "limit": 0,
- "limit_reset": "daily",
- "external_id": "string",
- "include_byok_in_limit": true,
- "expires_at": "string"
}{- "key": "string",
- "key_unavailable_reason": "plaintext_window_expired",
- "key_unavailable_message": "string",
- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}游标翻页。⚠️ 游标是 id 不是 offset:翻页途中若有新 key 创建,offset 会让某一把被 跳过或重复出现。账号下的子钥总数不设上限,单次返回的行数有上限。
| limit | integer <= 200 Default: 100 单页行数。超过 200 不报错,会被压到 200 |
| after | integer <int64> 上一页返回的 |
{- "data": [
- {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
], - "next_cursor": 0
}| hash required | string 创建时返回的 |
{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}⚠️ 解封用 {"disabled": false},不要用同一个 external_id 再开一把:
external_id 的唯一性包含已停用的 key,一个编号永久对应一把 key。
| hash required | string 创建时返回的 |
| limit | number or null 改上限; |
| limit_reset | string or null Enum: "daily" "weekly" "monthly" null 改自动清零周期;显式 |
| name | string |
| disabled | boolean
|
| include_byok_in_limit | boolean |
| expires_at | string or null <date-time> 改到期时间;显式 |
{- "limit": 0,
- "limit_reset": "daily",
- "name": "string",
- "disabled": true,
- "include_byok_in_limit": true,
- "expires_at": "2019-08-24T14:15:22Z"
}{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}有了它就不必在你那边维护一张 external_id → hash 的映射表。
| externalId required | string 你自己的编号 |
{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}| externalId required | string 你自己的编号 |
| limit | number or null 改上限; |
| limit_reset | string or null Enum: "daily" "weekly" "monthly" null 改自动清零周期;显式 |
| name | string |
| disabled | boolean
|
| include_byok_in_limit | boolean |
| expires_at | string or null <date-time> 改到期时间;显式 |
{- "limit": 0,
- "limit_reset": "daily",
- "name": "string",
- "disabled": true,
- "include_byok_in_limit": true,
- "expires_at": "2019-08-24T14:15:22Z"
}{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}limit_usage 回到 0,limit_remaining 回到 limit,limit_reset_at 记成这一刻。
累计的 usage 不变。没有请求体。
用在你自己的积分节奏和周期对不上的时候,比如用户续费、活动补发额度。
不需要先查用量再把 limit 改成「已用 + 新额度」,那样查和改之间花掉的钱会算错。
设了 limit_reset 的 key 也可以手动清零,不影响下一次自动清零的时间。
| hash required | string 创建时返回的 |
{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}和 POST /v1/keys/{hash}/reset 完全一致。
| externalId required | string 你自己的编号 |
{- "data": {
- "hash": "string",
- "name": "string",
- "label": "string",
- "limit": 0,
- "limit_remaining": 0,
- "limit_reset": "daily",
- "limit_usage": 0,
- "limit_reset_at": "2019-08-24T14:15:22Z",
- "usage": 0,
- "usage_daily": 0,
- "usage_weekly": 0,
- "usage_monthly": 0,
- "disabled": true,
- "include_byok_in_limit": true,
- "external_id": "string",
- "byok_usage": 0,
- "created_at": "2019-08-24T14:15:22Z",
- "updated_at": "2019-08-24T14:15:22Z",
- "expires_at": "2019-08-24T14:15:22Z"
}
}一行是一把 key 一天,带 hash 和 external_id,一次请求拿到所有子钥的数。
那一天没有用量的 key 不出现。单次窗口上限 100 天。
今天那一行是实时计算的,还会变;响应里的 includes_open_day 为 true 时说明结果包含今天。
增量同步时,includes_open_day 为 false 的结果可以直接入库,之后不会再变。
| from | string <date> 含, |
| to | string <date> 含, |
| group_by | string Value: "model" 传 |
{- "data": [
- {
- "date": "2019-08-24",
- "hash": "string",
- "external_id": "string",
- "model": "string",
- "usage": 0,
- "requests": 0,
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "reasoning_tokens": 0,
- "cached_tokens": 0
}
], - "from": "2019-08-24",
- "to": "2019-08-24",
- "timezone": "Asia/Shanghai",
- "includes_open_day": true
}和 GET /v1/keys/usage/daily 同一个形状,只含这一把 key。
| hash required | string 创建时返回的 |
| from | string <date> 含, |
| to | string <date> 含, |
| group_by | string Value: "model" 传 |
{- "data": [
- {
- "date": "2019-08-24",
- "hash": "string",
- "external_id": "string",
- "model": "string",
- "usage": 0,
- "requests": 0,
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "reasoning_tokens": 0,
- "cached_tokens": 0
}
], - "from": "2019-08-24",
- "to": "2019-08-24",
- "timezone": "Asia/Shanghai",
- "includes_open_day": true
}和 GET /v1/keys/{hash}/usage/daily 完全一致。
| externalId required | string 你自己的编号 |
| from | string <date> 含, |
| to | string <date> 含, |
| group_by | string Value: "model" 传 |
{- "data": [
- {
- "date": "2019-08-24",
- "hash": "string",
- "external_id": "string",
- "model": "string",
- "usage": 0,
- "requests": 0,
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "reasoning_tokens": 0,
- "cached_tokens": 0
}
], - "from": "2019-08-24",
- "to": "2019-08-24",
- "timezone": "Asia/Shanghai",
- "includes_open_day": true
}带上推理 key,目录里就包含你自己配的模型:你在自己渠道上配的那些 ∪ 平台的那些, 同名时以你自己那条为准 —— 和真正调用时的路由口径完全一致。
凭据是可选的:不带任何请求头时返回平台目录(客户端确实这么用,这条路一直保留)。
但带了就必须是真的 —— 无效或过期的 key 返回 401,不会静默给你一份
「少了你自己模型」的目录。
推理 key 和母钥都可以。母钥没有绑 Router,它拿到的是账号默认那套路由的目录;
要看某一把绑了别的 Router 的子钥能用什么,就拿那把子钥来调。
对账 key 返回 403(它碰不到模型这一片)。
⚠️ 你自己渠道上的模型,pricing.prompt / completion 是 0:那些 token 你直接付给
上游,不经我们的价目表。真实成本读回包的 usage.cost。
{- "data": [
- {
- "id": "string",
- "name": "string",
- "description": "string",
- "context_length": 0,
- "architecture": {
- "modality": "string",
- "input_modalities": [
- "string"
], - "output_modalities": [
- "string"
]
}, - "reasoning": {
- "mandatory": true,
- "default_enabled": true,
- "supported_efforts": [
- "string"
], - "default_effort": "string"
}, - "pricing": {
- "prompt": "string",
- "completion": "string",
- "input_cache_read": "string",
- "input_cache_write": "string",
- "request": "string",
- "image": "string"
}
}
]
}⚠️ 404 是正常路径,不是错误:用量记录在响应之后才写入。非流式通常 1 秒内可查, 流式以流结束为准;中途断开的流需事后向上游回查,可能到分钟级。 请把 404 当作「稍后再试」,退避几秒后重试。
| id required | string 响应头 |
{- "data": {
- "id": "string",
- "model": "string",
- "provider_name": "string",
- "created_at": "2019-08-24T14:15:22Z",
- "tokens_prompt": 0,
- "tokens_completion": 0,
- "native_tokens_prompt": 0,
- "native_tokens_completion": 0,
- "total_cost": 0,
- "usage": 0,
- "upstream_inference_cost": 0,
- "is_byok": true,
- "cancelled": true,
- "generation_time": 0,
- "latency": 0,
- "routing_overhead_ms": 0,
- "time_to_first_token_ms": 0
}
}这一组是留存开关本身(控制台上叫 Call Traces)。默认不存:关闭时
request_content / response_content 两列为空 —— 是没有存,不是存了不给看。
| productLine | string 指定产品线;不传即账号级。 ⚠️ 只能放在 GET 的 query 上,写操作一律放在 body:前置网关会丢弃 POST/PUT 的 query string,写在 query 上不报错也不生效。 |
{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "enabled": true,
- "retentionDays": 0,
- "productLine": "string",
- "operatorAccess": {
- "granted": true,
- "expiresAt": "2019-08-24T14:15:22Z",
- "reason": "string"
}
}
}| enabled | boolean |
| retentionDays | integer [ 1 .. 365 ] 默认 30;超出 1–365 返回 400 |
| productLine | string |
{- "enabled": true,
- "retentionDays": 1,
- "productLine": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "enabled": true,
- "retentionDays": 0,
- "productLine": "string",
- "operatorAccess": {
- "granted": true,
- "expiresAt": "2019-08-24T14:15:22Z",
- "reason": "string"
}
}
}⚠️ 没有「永久授权」这个选项,时长 1 小时 – 30 天:无时限的授权会在排查结束后 一直留存。授权期内每次读取都会记录审计。
| hours | integer [ 1 .. 720 ] Default: 24 |
| reason | string 给审计看的理由 |
| productLine | string |
{- "hours": 24,
- "reason": "string",
- "productLine": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "granted": true,
- "expiresAt": "2019-08-24T14:15:22Z",
- "reason": "string"
}
}到期的授权自动失效,无需处理。
| productLine | string |
{- "productLine": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "granted": true,
- "expiresAt": "2019-08-24T14:15:22Z",
- "reason": "string"
}
}⚠️ 只能挂在你自己的 key 上——拿 API key 调时挂在别的 key 上返回 404
(不是 403,不向调用方确认「那把 key 存在,只是不是你的」)。
挂上之后,这把 key 接下来的调用(/v1/chat/completions、/v1/embeddings、
视频生成……)不再打上游,直接按这里配的场景返回,立即生效,不需要重启或等待。
只影响这一把 key,账号下别的 key 照常打真实上游。不计费——演习的调用不产生
任何用量记录。
⚠️ 不给 expiresAt 会补一个默认的(4 小时后),不存在「永久演习」这个选项,
避免演习模式在测试结束后被忘记开着,某天突然发现生产 key 一直在返回假数据。
时间戳建议带偏移量(2026-09-27T18:00:00+08:00)——不带的按服务端本地时区
(Asia/Shanghai)解释,和别处的时间戳约定一致,但调用方通常猜不到这一点。
| apiKeyId required | integer <int64> |
| scenario required | string 取自 |
| enabled | boolean |
| responseBody | string 只在 |
| delayMs | integer 人为加的延迟,用来测超时处理逻辑 |
| expiresAt | string 不传则默认 4 小时后过期,见上方说明 |
{- "scenario": "string",
- "enabled": true,
- "responseBody": "string",
- "delayMs": 0,
- "expiresAt": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}读取夜间汇总表,当天部分为实时计算。⚠️ 单次查询窗口上限 100 天,超出返回 明确的错误,不做静默截断。
| from | string <date> 含,默认本期第一天 |
| to | string <date> 含,默认今天 |
| apiKeyId | integer <int64> 只看某一把 key |
{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}⚠️ 账号级:同一账号下所有 key 共享一个钱包。要限制单把 key 的消费用母钥的
limit,那是另一套机制。
{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "currency": "USD",
- "balance": 0,
- "creditLimit": 0,
- "available": 0,
- "lifetimeCharged": 0,
- "lifetimeCredited": 0,
- "periods": [
- {
- "period": "2026-07",
- "charged": 0,
- "credited": 0
}
]
}
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": {
- "content": [
- {
- "id": 0,
- "at": "2019-08-24T14:15:22Z",
- "category": "string",
- "type": "string",
- "direction": "IN",
- "amount": 0
}
], - "total": 0,
- "page": 0,
- "size": 0
}
}| name | string |
| baseUrl | string 上游根地址 |
| apiStyle | string |
| apiKey | string 上游凭据;更新时留空或回传掩码 = 保持原样 |
| paused | boolean |
| property name* additional property | any |
{- "name": "string",
- "baseUrl": "string",
- "apiStyle": "OPENAI",
- "apiKey": "string",
- "paused": true
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| id required | integer <int64> |
| name | string |
| baseUrl | string 上游根地址 |
| apiStyle | string |
| apiKey | string 上游凭据;更新时留空或回传掩码 = 保持原样 |
| paused | boolean |
| property name* additional property | any |
{- "name": "string",
- "baseUrl": "string",
- "apiStyle": "OPENAI",
- "apiKey": "string",
- "paused": true
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| id required | integer <int64> |
| property name* additional property | any |
{ }{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| name | string |
| makeDefault | boolean |
| enablePlatformModels | boolean |
{- "name": "string",
- "makeDefault": true,
- "enablePlatformModels": true
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| id required | integer <int64> |
| modelName | string 客户调用时写的模型名 |
| providerModelName | string 上游那边的模型名 |
| providerId | integer <int64> |
| priority | integer |
| weight | integer |
| enabled | boolean |
{- "modelName": "string",
- "providerModelName": "string",
- "providerId": 0,
- "priority": 0,
- "weight": 0,
- "enabled": true
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}决定 GET /v1/models 里这个模型的 architecture,压过上游目录。两边都传空数组 = 清掉,回到跟上游。
输入能力同时参与路由:没勾 image 的模型,带图的调用不会发给它。
| id required | integer <int64> |
| modelName required | string |
| inputModalities required | Array of strings Items Enum: "text" "image" "file" "audio" "video" |
| outputModalities required | Array of strings Items Enum: "text" "image" "audio" "video" "embeddings" |
{- "modelName": "string",
- "inputModalities": [
- "text"
], - "outputModalities": [
- "text"
]
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| id required | integer <int64> |
| routeId required | integer <int64> |
| modelName | string 客户调用时写的模型名 |
| providerModelName | string 上游那边的模型名 |
| providerId | integer <int64> |
| priority | integer |
| weight | integer |
| enabled | boolean |
{- "modelName": "string",
- "providerModelName": "string",
- "providerId": 0,
- "priority": 0,
- "weight": 0,
- "enabled": true
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| enabled | boolean or null
|
object | |
| packMode | string |
| autoCeiling | string |
{- "enabled": true,
- "types": {
- "TW_NATIONAL_ID": "MASK",
- "EMAIL": null
}, - "packMode": "string",
- "autoCeiling": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| scope | string Default: "TENANT" Enum: "TENANT" "KEY" |
| keyId | integer <int64>
|
| name | string <= 64 characters |
| kind | string Enum: "REGEX" "KEYWORDS" "FORMAT" |
| regex | string <= 500 characters |
object | |
object | |
| checksum | string or null Enum: "LUHN" "IBAN_MOD97" "CN_RESIDENT_ID" "TW_NATIONAL_ID" "TW_RESIDENT_CERT" "TW_UBN" null |
object or null | |
| action | string Enum: "BLOCK" "MASK" "ALERT" |
| enabled | boolean Default: true |
| description | string or null <= 255 characters |
{- "scope": "TENANT",
- "name": "project-codes",
- "kind": "KEYWORDS",
- "keywords": {
- "words": [
- "Project Falcon",
- "猎鹰计划"
], - "wholeWord": true
}, - "action": "BLOCK"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}| id required | integer <int64> |
| scope | string Default: "TENANT" Enum: "TENANT" "KEY" |
| keyId | integer <int64>
|
| name | string <= 64 characters |
| kind | string Enum: "REGEX" "KEYWORDS" "FORMAT" |
| regex | string <= 500 characters |
object | |
object | |
| checksum | string or null Enum: "LUHN" "IBAN_MOD97" "CN_RESIDENT_ID" "TW_NATIONAL_ID" "TW_RESIDENT_CERT" "TW_UBN" null |
object or null | |
| action | string Enum: "BLOCK" "MASK" "ALERT" |
| enabled | boolean Default: true |
| description | string or null <= 255 characters |
{- "scope": "TENANT",
- "keyId": 0,
- "name": "string",
- "kind": "REGEX",
- "regex": "string",
- "keywords": {
- "words": [
- "string"
], - "wholeWord": true
}, - "format": {
- "prefix": "string",
- "charset": "ALNUM",
- "length": {
- "min": 1,
- "max": 512
}, - "boundary": "WORD",
- "suffix": "string"
}, - "checksum": "LUHN",
- "context": {
- "words": [
- "string"
], - "window": 40
}, - "action": "BLOCK",
- "enabled": true,
- "description": "string"
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}带 rule 只跑这条草稿;不带则跑账户(或 keyId 那把 key)当前生效的整份策略。
| text required | string <= 20000 characters |
object (DlpCustomRule) 客户自定义 DLP 规则。 | |
| keyId | integer <int64> |
{- "text": "string",
- "rule": {
- "scope": "TENANT",
- "keyId": 0,
- "name": "string",
- "kind": "REGEX",
- "regex": "string",
- "keywords": {
- "words": [
- "string"
], - "wholeWord": true
}, - "format": {
- "prefix": "string",
- "charset": "ALNUM",
- "length": {
- "min": 1,
- "max": 512
}, - "boundary": "WORD",
- "suffix": "string"
}, - "checksum": "LUHN",
- "context": {
- "words": [
- "string"
], - "window": 40
}, - "action": "BLOCK",
- "enabled": true,
- "description": "string"
}, - "keyId": 0
}{- "code": 0,
- "message": "string",
- "success": true,
- "data": null
}