{"version": "1.0","default_effect": "passthrough","statement": [],"enabled": true}
字段 | 类型 | 是否必填 | 定义 |
version | string | 是 | 策略 schema 版本,当前固定为 "1.0" |
default_effect | string | 否,建议显式填写 | 默认 "passthrough";可选 "passthrough"、"deny",决定请求体中未被放通规则覆盖的字段如何处理。其中: passthrough:未被放通规则覆盖的顶层字段进入 custom 旁路,随后合回请求体 deny:未被放通规则覆盖的字段不进入输出请求体;不表示拒绝整个请求 |
statement | array | 否,建议显式填写 | 策略语句数组,省略时为 [] |
enabled | boolean | 否,建议显式填写 | 提交策略时默认 true,控制文本协议转换是否启用;不等同于删除配置 |
字段 | 类型 | 是否 必填 | 说明 |
effect | string | 是 | 对目标字段执行的操作。取值范围:allow、deny、set_if_absent、set 和 rewrite,其中: allow:放通,将现存目标字段送入指定链路,不会自动补字段或设置默认值。 deny:丢弃,从转换结果中删除指定字段,字段不存在时不操作。 set_if_absent:设置默认值,仅目标字段不存在时写入设置的值。 set:强制覆盖,目标存在时覆盖,目标不存在时写入设置的值。 rewrite:字段改写,读取 source,命中 map 后将映射值写入 target。 说明: “不存在”不等于空值: null、false、0、空字符串、空对象、空数组都表示字段已存在,不触发 set_if_absent。嵌套对象父级缺失时可以创建对象分支,但父级类型不兼容或现有数组索引越界时不写入。 rewrite 不自动删除源字段: 成功改写时默认保留 source。若不希望源字段送往上游,可另配 deny,或通过 default_effect: "deny" 和放通清单控制输出。源不存在、类型不适合映射或没有命中 map 时,目标保持原样。 设值与放通是两个阶段: 向一个非标准字段 set 或 rewrite,并不自动为它增加放通规则。如果使用 default_effect: "deny",新写入的非标准字段也需要显式 allow 才能保留到输出。 |
action | string 或 string[] | 建议显式填写 | 端点标识符或端点列表。"*" 表示全部支持的端点。实现兼容省略该字段,含义同 "*"。当前支持的取值如下: chat_completions:表示客户的请求路径为 POST /v1/chat/completions。responses:表示客户的请求路径为 POST /v1/responses。anthropic_messages:表示客户的请求路径为 POST /v1/messages。embeddings:表示客户的请求路径为 POST /v1/embeddings。videos_create:表示客户的请求路径为 POST /v1/videos。videos_list:表示客户的请求路径为 GET /v1/videos。videos_retrieve:表示客户的请求路径为 GET /v1/videos/{video_id}。videos_delete:表示客户的请求路径为 DELETE /v1/videos/{video_id}。rerank:表示客户的请求路径为 POST /v1/rerank,也支持 /v2/rerank、/rerank。说明: 这里填写的是端点标识符,不填写路径或页面展示名。例如,应填写 chat_completions,不能填写 /v1/chat/completions、chat_completion 或 OpenAI/chat。 |
target | string 或 string[] | 是 | 操作的目标位置。body 空间使用 JSON Pointer;header 空间使用 HTTP 头名 |
resource | string 或 string[] | 否 | 客户端原始 model 名或模型名列表;省略或单独设置为 "*" 表示全部模型 说明: resource 匹配客户端实际发送的原始模型名,不是路由解析后的上游模型名。 模型名按精确值匹配,不支持 qwen* 这样的部分通配; 不校验模型是否已存在。 全部模型请直接写 "resource": "*",不要写成列表中的 "*"。 |
space | string | 否 | 默认 "body",也可设置为 "header" |
source | string | rewrite 必填 | 从原始请求体读取值的 JSON Pointer |
value | 任意 JSON 值 | 按 effect 要求 | 要写入的字面量,不作为内核表达式解析 |
value_from | object | 按 effect 要求 | 从原始请求体或请求头取值;只用于 set、set_if_absent,与 value 必须二选一 |
map | array | rewrite 必填 | 非空映射表,每项为 {"key": 标量, "value": 任意 JSON 值} |
condition | object | 否 | 单条语句的生效条件,见“条件定义” |
写法 | 指向 |
/max_tokens | 顶层字段 max_tokens |
/chat_template_kwargs/enable_thinking | 嵌套字段 enable_thinking |
/messages/0/role | 已存在数组的第 0 个元素的 role |
操作符 | 形态 | 含义 |
exists | {"exists": "/thinking"} | 字段存在即成立,值为 null、false 也成立 |
string_equal | {"string_equal": {"/mode": ["fast"]}} | 字符串相等 |
number_equal | {"number_equal": {"/n": [1]}} | 数字相等,不将布尔值当数字 |
bool_equal | {"bool_equal": {"/stream": [true]}} | 布尔值相等 |
null_equal | {"null_equal": {"/metadata": [null]}} | 字段存在且值为 null |
{"version": "1.0","enabled": true,"default_effect": "deny","statement": [{"effect": "allow","action": "chat_completions","resource": "qwen3-demo","target": "/chat_template_kwargs","destination": "custom"}]}
{"model": "qwen3-demo","messages": [{"role": "user", "content": "Hello"}],"chat_template_kwargs": {"enable_thinking": true}}
{"version": "1.0","enabled": true,"default_effect": "passthrough","statement": [{"effect": "deny","action": ["chat_completions", "responses"],"target": ["/frequency_penalty", "/presence_penalty"]}]}
请求字段片段 | 结果字段片段 |
{"temperature": 0.7, "frequency_penalty": 0.5, "presence_penalty": 0.2} | {"temperature": 0.7} |
{"version": "1.0","enabled": true,"default_effect": "passthrough","statement": [{"effect": "set_if_absent","action": "chat_completions","target": "/max_tokens","value": 2048}]}
请求字段片段 | 结果字段片段 | 原因 |
{} | {"max_tokens": 2048} | 字段缺失,补默认值 |
{"max_tokens": 512} | {"max_tokens": 512} | 已存在,保持原值 |
{"max_tokens": null} | {"max_tokens": null} | null 仍表示字段存在;上游是否接受需另行验证 |
{"version": "1.0","enabled": true,"default_effect": "passthrough","statement": [{"effect": "set_if_absent","action": "chat_completions","space": "header","target": "X-CMR-Session-Id","value_from": {"first_available": [{"from": "body", "path": "/session_id"},{"from": "header", "name": "x-conversation-id"}]}}]}
原始请求 | 网关内部可见的会话头 |
body 含 "session_id": "session-001",无目标头 | X-CMR-Session-Id: session-001 |
body 无 session_id,含 x-conversation-id: session-002 | X-CMR-Session-Id: session-002 |
已有 x-cmr-session-id: session-original | 保留原目标头,大小写不影响“已存在”判断 |
两个来源均不存在,且无目标头 | 不写入目标头 |

messages, model, audio, frequency_penalty, function_call, functions,logit_bias, logprobs, max_completion_tokens, max_tokens, metadata,modalities, moderation, n, parallel_tool_calls, prediction,presence_penalty, prompt_cache_key, prompt_cache_options,prompt_cache_retention, reasoning_effort, response_format,safety_identifier, seed, service_tier, stop, store, stream,stream_options, temperature, tool_choice, tools, top_logprobs,top_p, user, verbosity, web_search_options
max_tokens, messages, model, cache_control, container, inference_geo,metadata, output_config, service_tier, stop_sequences, stream, system,temperature, thinking, tool_choice, tools, top_k, top_p
background, context_management, conversation, include, input,instructions, max_output_tokens, max_tool_calls, metadata, model,moderation, parallel_tool_calls, previous_response_id, prompt,prompt_cache_key, prompt_cache_options, prompt_cache_retention,reasoning, safety_identifier, service_tier, store, stream,stream_options, temperature, text, tool_choice, tools, top_logprobs,top_p, truncation, user
model, input, dimensions, encoding_format, user
model, contents, task_type, duration, resolution, aspect_ratio,audio, seed, watermark, negative_prompt
status, model, offset, limit
video_id
video_id
model, query, documents, top_n, return_documents, instruct
文档反馈