Documentation renewed! For old docs, visit doc.newapi.pro
New APINew API
User GuideInstallationAPI ReferenceAI ApplicationsHelp & SupportBusiness Cooperation
Console

Channels

Here you can manage NewAPI's upstream channels

Channels

Channel Creation/Editing Page

Channel Management 1

Channel Management 2

Channel Management 3

Parameter Override Settings Documentation

Overview

The parameter override system supports two modes: Simple Override Mode (backward compatible) and Advanced Operation Mode. Complex dynamic parameter adjustments can be achieved through flexible conditional judgments and operation types.

Usage

Simple Override Mode

Backward compatible. Directly specify the fields and values to be overridden, and 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 judgments, array operations, and string concatenation.

Basic Structure

{
  "operations": [
    {
      "path": "temperature",
      "mode": "set",
      "value": 0.8,
      "conditions": [...],
      "logic": "AND"
    }
  ]
}

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: If true, skips setting the value if the target path already exists.

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\n请用中文回答。"
}

Supported Data Types:

  • String: Appends to the end of the original string.
  • Array: Adds elements to the end of the array (supports adding a single element or an array).
  • Object: Merges object properties.

5. prepend - Prepend Content

Adds new content before existing content.

{
  "path": "messages.0.content",
  "mode": "prepend",
  "value": "重要提示:请仔细阅读以下内容。\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 a single element or an array).
  • Object: Merges object properties.

Conditional Judgments

Set conditions for operation execution using the conditions array; operations will only execute if 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 match

  • suffix: Suffix match

  • contains: Contains match

  • gt: 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 can only be used for numeric types.
  • String operations (prefix, suffix, contains) will convert values to strings for comparison.

Condition Parameter Description

  • invert: Invert function, true means to negate the result.
  • pass_missing_key: Behavior when the specified path does not exist.
    • true: Condition passes if the path does not exist.
    • false: Condition fails if the path does not exist (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 field
  • messages.0.content - The content field of the first element in the array
  • messages.-1.content - The content field of the last element in the array
  • metadata.user.name - Nested object field

Practical Examples

1. Dynamically Adjusting Model Parameters

Dynamically adjust the temperature parameter 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. Adding System Prompts

Add a system message at the beginning of the message array:

{
  "operations": [
    {
      "path": "messages",
      "mode": "prepend",
      "value": [
        {
          "role": "system",
          "content": "你是一个专业的AI助手,请始终保持礼貌和专业。"
        }
      ]
    }
  ]
}

3. Adjusting Parameters Based on Model Type

Set different max_tokens based on 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 judgments based on numeric values:

{
  "operations": [
    {
      "path": "temperature",
      "mode": "set",
      "value": 0.1,
      "conditions": [
        {
          "path": "max_tokens",
          "mode": "gt",
          "value": 1000
        }
      ]
    }
  ]
}

6. Inverted Conditions

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. Handling 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 message:

{
  "operations": [
    {
      "path": "messages.-1.content",
      "mode": "append",
      "value": "\n\n请详细解释你的思考过程。"
    }
  ]
}

Important Notes

Execution Order: Operations are executed sequentially in the order they appear in the operations array; earlier operations may affect subsequent ones.

How is this guide?

Last updated on