Channels
Upstream channels must be legally owned or authorized accounts, API Keys, model services, or enterprise contracts of the deployer. Features such as load balancing, automatic failover, weighted random, and multi-key management are used for high availability and enterprise multi-account management. When using them, you should comply with upstream service terms, platform rules, and regulatory requirements.
Here you can manage NewAPI's upstream channels.

Channel Creation/Editing Page



Parameter Override Settings Documentation
Overview
The parameter override system supports two modes: simple override mode (backward compatible) and advanced operation mode. Through flexible conditional logic and operation types, complex dynamic parameter adjustments can be achieved. The parameter override feature can only be used for compatibility with legal upstream interface formats, enterprise network compatibility, and request normalization.
Usage
Simple Override Mode
For backward compatibility, directly specify the fields and values to be overridden. The system will merge these fields into the original request.
{
"temperature": 0.8,
"max_tokens": 2000,
"model": "gpt-4"
}Advanced Operation Mode
Define complex parameter operations using the operations array, supporting advanced features such as conditional logic, array operations, string concatenation, and string normalization.
Basic Structure
{
"operations": [
{
"path": "temperature",
"mode": "set",
"value": 0.8,
"conditions": [...],
"logic": "AND"
}
]
}Field Description (fill as needed):
mode: Requiredpath: Applicable toset/delete/append/prepend/trim_prefix/trim_suffix/ensure_prefix/ensure_suffix/trim_space/to_lower/to_upper/replace/regex_replacevalue: Commonly used withset/append/prepend/trim_prefix/trim_suffix/ensure_prefix/ensure_suffixfrom/to: Applicable tomove/copy/replace/regex_replacekeep_origin: Used forset(skips if value already exists) and forappend/prependduring object merging.
Operation Modes (mode)
1. set - Set Value
Sets the value at the specified path.
{
"path": "temperature",
"mode": "set",
"value": 0.8,
"keep_origin": false
}Parameter Description:
keep_origin: Iftrue, setting is skipped if the target path already has a value.
2. delete - Delete Field
Deletes the field at the specified path.
{
"path": "messages.0",
"mode": "delete"
}3. move - Move Field
Moves the value of one field to another location.
{
"mode": "move",
"from": "messages.0.content",
"to": "system"
}4. append - Append Content
Appends new content after existing content.
{
"path": "messages.0.content",
"mode": "append",
"value": "\n\nPlease answer in Chinese."
}Supported Data Types:
- String: Appends to the end of the original string.
- Array: Adds elements to the end of the array (supports adding single elements or arrays).
- Object: Merges object properties.
5. prepend - Prepend Content
Adds new content before existing content.
{
"path": "messages.0.content",
"mode": "prepend",
"value": "Important Note: Please read the following carefully.\n\n"
}Supported Data Types:
- String: Prepends to the beginning of the original string.
- Array: Adds elements to the beginning of the array (supports adding single elements or arrays).
- Object: Merges object properties.
6. copy - Copy Field
Copies the value from the from path to the to path (does not delete the source field).
{
"mode": "copy",
"from": "model",
"to": "original_model"
}Parameter Requirements:
from/to: Required.- An error will occur if the source path does not exist.
7. trim_prefix - Trim Prefix
Removes the specified prefix from a string field (remains unchanged if no match).
{
"path": "model",
"mode": "trim_prefix",
"value": "openai/"
}Parameter Requirements:
value: Required.
8. trim_suffix - Trim Suffix
Removes the specified suffix from a string field (remains unchanged if no match).
{
"path": "model",
"mode": "trim_suffix",
"value": "-latest"
}Parameter Requirements:
value: Required.
9. ensure_prefix - Ensure Prefix
Ensures a string field starts with the specified prefix (remains unchanged if already present).
{
"path": "model",
"mode": "ensure_prefix",
"value": "openai/"
}Parameter Requirements:
value: Required and cannot be an empty string.
10. ensure_suffix - Ensure Suffix
Ensures a string field ends with the specified suffix (remains unchanged if already present).
{
"path": "model",
"mode": "ensure_suffix",
"value": "-latest"
}Parameter Requirements:
value: Required and cannot be an empty string.
11. trim_space - Trim Whitespace
Performs TrimSpace on a string field (spaces, newlines, tabs, etc., will be removed).
{
"path": "model",
"mode": "trim_space"
}12. to_lower - Convert to Lowercase
Converts a string field to lowercase.
{
"path": "model",
"mode": "to_lower"
}13. to_upper - Convert to Uppercase
Converts a string field to uppercase.
{
"path": "model",
"mode": "to_upper"
}14. replace - String Replace
Performs substring replacement on a string field.
{
"path": "model",
"mode": "replace",
"from": "openai/",
"to": ""
}Parameter Requirements:
from: Required and cannot be an empty string.to: Optional; omitting it is equivalent to an empty string.
15. regex_replace - Regex Replace
Performs regex matching and replacement on a string field.
{
"path": "model",
"mode": "regex_replace",
"from": "^gpt-",
"to": "openai/gpt-"
}Parameter Requirements:
from: Required (regular expression, Go regexp syntax).to: Optional; omitting it is equivalent to an empty string.
Conditional Logic
Set conditions for operation execution using the conditions array. The corresponding operation will only be executed if the conditions are met.
Condition Structure
{
"conditions": [
{
"path": "model",
"mode": "contains",
"value": "gpt-4",
"invert": false,
"pass_missing_key": false
}
],
"logic": "AND"
}Condition Matching Modes
full: Exact match (default)prefix: Prefix matchsuffix: Suffix matchcontains: Contains matchgt: Greater than (numeric types only)gte: Greater than or equal to (numeric types only)lt: Less than (numeric types only)lte: Less than or equal to (numeric types only)
Note:
- Numeric comparisons are only for numeric types.
- String operations (prefix, suffix, contains) convert values to strings for comparison.
Condition Parameter Description
invert: Inverts the condition.truemeans the result is negated.pass_missing_key: Behavior when the specified path does not exist.true: Condition passes if the path is missing.false: Condition fails if the path is missing (default).
Logical Relationship (logic)
AND: All conditions must be met.OR: Any condition can be met (default).
Path Syntax
Use JSON path syntax to access nested fields:
temperature- Root-level fieldmessages.0.content- Content field of the first element in the arraymessages.-1.content- Content field of the last element in the arraymetadata.user.name- Nested object field
Additionally, path supports the following built-in variables (which do not need to be explicitly present in the request body) and can be directly used for conditional logic:
| Variable | Meaning | Typical Use Case |
|---|---|---|
model / upstream_model | Target model after redirection | Conditional matching based on the actual upstream model called |
original_model | Target model before redirection | Conditional matching based on the original model requested by the user |
Practical Examples
1. Dynamically Adjust Model Parameters
Dynamically adjust temperature parameters based on message content:
{
"operations": [
{
"path": "temperature",
"mode": "set",
"value": 0.3,
"conditions": [
{
"path": "messages.0.content",
"mode": "contains",
"value": "代码"
}
]
},
{
"path": "temperature",
"mode": "set",
"value": 0.9,
"conditions": [
{
"path": "messages.0.content",
"mode": "contains",
"value": "创意"
}
]
}
]
}2. Add System Prompt
Add a system message at the beginning of the message array:
{
"operations": [
{
"path": "messages",
"mode": "prepend",
"value": [
{
"role": "system",
"content": "You are a professional AI assistant, please always be polite and professional."
}
]
}
]
}3. Adjust Parameters Based on Model Type
Set different max_tokens for different models:
{
"operations": [
{
"path": "max_tokens",
"mode": "set",
"value": 4000,
"conditions": [
{
"path": "model",
"mode": "prefix",
"value": "gpt-4"
}
]
},
{
"path": "max_tokens",
"mode": "set",
"value": 2000,
"conditions": [
{
"path": "model",
"mode": "prefix",
"value": "gpt-3.5"
}
]
}
]
}4. Multiple Condition Combination (AND Logic)
Execute operations only when multiple conditions are met simultaneously:
{
"operations": [
{
"path": "stream",
"mode": "set",
"value": false,
"conditions": [
{
"path": "model",
"mode": "contains",
"value": "claude"
},
{
"path": "messages.0.content",
"mode": "contains",
"value": "长文"
}
],
"logic": "AND"
}
]
}5. Numeric Comparison Conditions
Perform conditional logic based on numeric values:
{
"operations": [
{
"path": "temperature",
"mode": "set",
"value": 0.1,
"conditions": [
{
"path": "max_tokens",
"mode": "gt",
"value": 1000
}
]
}
]
}6. Invert Condition
Use invert to implement inverse logic:
{
"operations": [
{
"path": "stream",
"mode": "set",
"value": true,
"conditions": [
{
"path": "model",
"mode": "contains",
"value": "gpt-3.5",
"invert": true
}
]
}
]
}7. Handle Missing Fields
Use pass_missing_key to handle potentially missing fields:
{
"operations": [
{
"path": "temperature",
"mode": "set",
"value": 0.7,
"conditions": [
{
"path": "custom_field",
"mode": "full",
"value": "special",
"pass_missing_key": true
}
]
}
]
}8. String Concatenation Example
Append instructions after the user's message:
{
"operations": [
{
"path": "messages.-1.content",
"mode": "append",
"value": "\n\nPlease explain your thought process in detail."
}
]
}Important Notes
Execution Order: Operations are executed sequentially according to their order in the operations array; earlier operations may affect subsequent ones.
How is this guide?
Last updated on