tencent cloud

DocumentationCloud Model RoutingOperation GuideConfiguration Parameter Conversion

Configuration Parameter Conversion

Download
Focus Mode
Font Size
Last updated: 2026-11-17 14:37:07
AI-Translated
This document describes how to configure a parameter transformation file in a CMR instance. Parameter transformation rewrites client request parameters at the gateway entry, normalizes parameters entering the standard protocol chain into a unified format, and enables you to call large models with different protocols through a unified gateway, simplifying development for multi-model access.

Prerequisites

A CMR instance has been created. For details, see Operation Guide.
Associate the models to be called with the instance, and confirm the endpoint used by the client and the model value in the request.
Before configuration, make sure that you understand the parameters and types supported by the upstream model. A policy that passes validation does not guarantee that the upstream model will accept the rewritten parameters.

Configuration Instructions

A CMR instance shares one parameter transformation policy file.
Parameter transformation policies are based on the JSON format. A policy file must be a valid JSON object. JSON comments and unregistered fields are not supported. For details, see JSON POINTER Standard Protocol.
Parameter transformation supports the following policy types: allow, drop, set default value, force overwrite, and field rewrite.
The product provides built-in default allow rules. You cannot edit or delete the built-in rules themselves through this configuration file, but you can change the processing result of a field through user rules. For example, you can use deny to drop a field that is allowed by default. For details, see Global Default Allow Rule List.

Definition

Top-Level Structure

It is recommended that you explicitly fill in the following four fields:
{
"version": "1.0",
"default_effect": "passthrough",
"statement": [],
"enabled": true
}
Field
Type
Required
Definition
version
string
Yes
Policy schema version, currently fixed at "1.0".
default_effect
string
No, explicit specification is recommended.
Defaults to "passthrough"; optional values are "passthrough" and "deny", which determine how fields in the request body not covered by allow rules are processed.
passthrough: Top-level fields not covered by allow rules enter the custom bypass and are then merged back into the request body.
deny: Fields not covered by allow rules are not included in the output request body. This does not mean that the entire request is rejected.
statement
array
No, explicit specification is recommended.
Policy statement array, which is [] when omitted.
enabled
boolean
No, explicit specification is recommended.
Defaults to true when the policy is submitted, controlling whether text protocol conversion is enabled; it is not equivalent to deleting the configuration.
Attention:
The top-level enabled field applies only to the three text endpoints: chat_completions, responses, and anthropic_messages. It does not control parameter rewriting for embeddings, videos_*, or rerank.
To disable an embeddings rule, set enabled: false for that statement or remove it from the full configuration.
It is not recommended to use the top-level enabled: false to infer that all endpoints have stopped transformation.
This setting is instance-level and applies only to the request body. Default dropping is not performed on request headers. It is also not a guarantee of "preserving the original request": explicit rules such as deny, set, and rewrite are still executed.
Attention:
The bypass fallback is bounded by the top-level fields occupied by allow rules. If only /extra/a is allowed, you cannot rely on passthrough to automatically preserve /extra/b. To preserve the entire object, allow /extra, or configure rules separately for the subfields that need to be preserved.

Single Statement Fields

Field
Type
Whether
Required
Description
effect
string
Yes
Operation to perform on the target field. Valid values: allow, deny, set_if_absent, set, and rewrite, where:
allow: Passes existing target fields to the specified pipeline. It does not automatically add fields or set default values.
deny: Drops the specified field from the transformation result. No operation is performed if the field does not exist.
set_if_absent: Sets a default value. The specified value is written only when the target field does not exist.
set: Force overwrites. If the target exists, it is overwritten. If the target does not exist, the specified value is written.
rewrite: Rewrites a field by reading source and, upon a map hit, writing the mapped value to target.
Note:
"Does not exist" is not equal to empty values: null, false, 0, empty strings, empty objects, and empty arrays all indicate that the field already exists and do not trigger set_if_absent. When the parent of a nested object is missing, an object branch can be created, but no value is written when the parent type is incompatible or an existing array index is out of bounds.
rewrite does not automatically delete the source field: source is retained by default upon a successful rewrite. If you do not want the source field to be sent upstream, configure a separate deny rule, or control the output through default_effect: "deny" and an allowlist. When the source does not exist, the type is unsuitable for mapping, or no map entry is matched, the target remains unchanged.
Setting values and allowing fields are two separate stages: Setting or rewriting a non-standard field does not automatically add an allow rule for it. If default_effect: "deny" is used, newly written non-standard fields also require an explicit allow to be retained in the output.
action
string or string[]
Explicit specification is recommended.
Endpoint identifier or a list of endpoints. "*" indicates all supported endpoints. If the field is omitted for compatibility, the meaning is the same as "*". Currently supported values are as follows:
chat_completions: Indicates that the client's request path is POST /v1/chat/completions.
responses: Indicates that the client's request path is POST /v1/responses.
anthropic_messages: Indicates that the client's request path is POST /v1/messages.
embeddings: Indicates that the client's request path is POST /v1/embeddings.
videos_create: Indicates that the client's request path is POST /v1/videos.
videos_list: Indicates that the client's request path is GET /v1/videos.
videos_retrieve: Indicates that the client's request path is GET /v1/videos/{video_id}.
videos_delete: Indicates that the client's request path is DELETE /v1/videos/{video_id}.
rerank: Indicates that the client's request path is POST /v1/rerank, and also supports /v2/rerank and /rerank.
Note:
Enter the endpoint identifier here, not the path or page display name. For example, enter chat_completions, not /v1/chat/completions, chat_completion, or OpenAI/chat.
target
string or string[]
Yes
Target location of the operation. In the body space, use JSON Pointer; in the header space, use the HTTP header name.
resource
string or string[]
No
Original client model name or a list of model names; if omitted or set to "*" alone, it indicates all models.
Note:
resource matches the original model name actually sent by the client, not the upstream model name after route resolution.
Model names are matched by exact value. Partial wildcards such as qwen* are not supported.
The system does not check whether the model already exists.
For all models, directly write "resource": "*", not "*" in a list.
space
string
No
Defaults to "body" and can also be set to "header".
source
string
Required for rewrite
JSON Pointer for reading a value from the original request body
value
Any JSON value
As required by effect
Literal value to be written, not parsed as a kernel expression.
value_from
object
As required by effect
Retrieves a value from the original request body or request header; used only for set and set_if_absent, and must be mutually exclusive with value.
map
array
Required for rewrite
Non-empty mapping table, where each entry is {"key": scalar, "value": any JSON value}
condition
object
No
Condition for a single statement to take effect. See "Condition Definition".

JSON Pointer and Value Types

Path
Reference
/max_tokens
Top-level field max_tokens
/chat_template_kwargs/enable_thinking
Nested field enable_thinking
/messages/0/role
role of the 0th element in the existing array
Note:
JSON literals determine the type: 2048 is a number, "2048" is a string, true is a boolean, and "true" is a string. A map.key can only be a string, number, boolean, or null, and is matched by "type + value". true, "true", and 1 are different keys, while the numeric values 1 and 1.0 are treated as the same key.

Condition Definition

Conditionally reads the original request body, not intermediate results modified by other statements.
Operator
Form
Meaning
exists
{"exists": "/thinking"}
The condition is met if the field exists, even when its value is null or false.
string_equal
{"string_equal": {"/mode": ["fast"]}}
String equality
number_equal
{"number_equal": {"/n": [1]}}
Numbers are equal, and boolean values are not treated as numbers.
bool_equal
{"bool_equal": {"/stream": [true]}}
Boolean equality
null_equal
{"null_equal": {"/metadata": [null]}}
The field exists and its value is null.
Note:
Each statement can have at most one conditional operator. Comparison conditions can contain only one path and one value. The and, or, greater than, less than, and not exists operators are not supported. Do not use /model as a condition path. To differentiate by model, use resource.

Policy Examples

The following examples are all independent, complete policies, not incremental snippets for you to submit in sequence.
Replace the sample model name, merge it into the existing configuration, and then submit.
The request and result show only the parameter transformation stage. Omitting other parameters does not mean they can be omitted from actual model calls.
A successful preview does not mean that upstream call validation has passed.

Example 1: Allowing Private Parameters and Discarding Undeclared Parameters

Allow only the private parameter chat_template_kwargs of qwen3-demo, retain built-in standard fields, and discard other fields that are not allowed.
{
"version": "1.0",
"enabled": true,
"default_effect": "deny",
"statement": [
{
"effect": "allow",
"action": "chat_completions",
"resource": "qwen3-demo",
"target": "/chat_template_kwargs",
"destination": "custom"
}
]
}
Transformation result:
model and messages are allowed by built-in rules. debug_mode is not within the allow scope, so it is dropped.
{
"model": "qwen3-demo",
"messages": [{"role": "user", "content": "Hello"}],
"chat_template_kwargs": {"enable_thinking": true}
}

Example 2: Discarding Unsupported Fields

Two parameters are dropped for both Chat Completions and Responses, and one statement is expanded into four rules.
{
"version": "1.0",
"enabled": true,
"default_effect": "passthrough",
"statement": [
{
"effect": "deny",
"action": ["chat_completions", "responses"],
"target": ["/frequency_penalty", "/presence_penalty"]
}
]
}
Request Field Fragment
Result Field Fragment
{"temperature": 0.7, "frequency_penalty": 0.5, "presence_penalty": 0.2}
{"temperature": 0.7}
Even if frequency_penalty is in the default allowlist for Chat Completions, it will still be explicitly removed by deny.

Example 3: Setting Default Values for Missing Parameters

{
"version": "1.0",
"enabled": true,
"default_effect": "passthrough",
"statement": [
{
"effect": "set_if_absent",
"action": "chat_completions",
"target": "/max_tokens",
"value": 2048
}
]
}
Request Field Fragment
Result Field Fragment
Reason
{}
{"max_tokens": 2048}
Field missing. The default value is supplemented.
{"max_tokens": 512}
{"max_tokens": 512}
The field already exists. Its original value is retained.
{"max_tokens": null}
{"max_tokens": null}
null still indicates that the field exists. Whether the upstream accepts it needs to be verified separately.

Example 4: Rewriting Headers to Normalize Session Identifiers into Request Headers

If the target header does not exist, read /session_id from the request body first. Otherwise, read x-conversation-id.
{
"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"}
]
}
}
]
}
Original Request
Session Header Visible Inside Gateway
body contains "session_id": "session-001" and no target header.
X-CMR-Session-Id: session-001
body does not contain session_id and contains x-conversation-id: session-002.
X-CMR-Session-Id: session-002
Existing x-cmr-session-id: session-original.
Retain the original target header. Letter case does not affect the "already exists" determination.
Neither source exists and no target header is present.
Do not write the target header.
Attention:
The rewritten session header is used for internal session processing within the gateway.
first_available selects the first source that is read successfully, not the first source that passes session ID validation. If session_id: null or an empty string exists in the body, the system does not continue trying the fallback header, and the request fails during session value validation.
The session ID must be 1 to 128 visible ASCII characters and must not contain spaces or Chinese characters. Use a real business ID for preview validation.
This example does not delete session_id from the body. To delete it, configure a deny rule in the body space.

Operation Steps

1. Log in to the CMR console.
2. Select Instance Management in the left sidebar, and click the target instance ID to go to the instance details page.
3. Switch to the Model Scheduling Management tab.
4. Click Configure in the parameter transformation prompt banner at the top of the page to open the parameter transformation configuration panel.

5. Enter the parameters in the JSON editor.
6. Select a protocol and click Preview to view the preview result.
7. After confirming that the information is correct, click Submit Configuration to complete the configuration of the parameter transformation policy file.
Note:
For initial configuration, you can use the skeleton in the top-level structure and add the required rules to the statement.
When editing, do not directly overwrite all content with a single example, as this may delete existing rules. Copy the current configuration first, and then confirm the modifications.

Global Default Allow Rule List

The following list is consistent with the gateway default rule file, and the default configuration of all fields is primary. The names in the list are top-level JSON fields, corresponding to the target /<field name>. These are built-in system rules and do not need to be copied into the statement.

Chat Completions:chat_completions

There are 37 fields in total:
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

Anthropic Messages:anthropic_messages

There are 18 fields in total:
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

Responses:responses

There are 31 fields in total:
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

Embeddings:embeddings

There are 5 fields in total:
model, input, dimensions, encoding_format, user

Creating Videos: videos_create

There are 10 fields in total:
model, contents, task_type, duration, resolution, aspect_ratio,audio, seed, watermark, negative_prompt

Querying Video List: videos_list

There are 4 fields in total:
status, model, offset, limit

Querying Video Tasks: videos_retrieve

There is 1 field in total:
video_id

Deleting Video Tasks: videos_delete

There is 1 field in total:
video_id

Reranking: rerank

There are 6 fields in total:
model, query, documents, top_n, return_documents, instruct

Related Documentation

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback