ModelRouterUpdateBillingRule

更新时间:
复制 MD 格式

Billing management/Update billing rules

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

PUT /api/v1/modelRouter/open/billing/rules/{id} HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

id

integer

No

The ID of the billing rule.

1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body for updating a billing rule.

billingType

string

No

The billing type. Must be configurable.

configurable

pricingConfig

any

No

The billing configuration, specified as a JSON object.

  1. Token-based tiered pricing (token_tiered)
    Applies to Chat models. Billing is tiered based on the token count, with separate rates for standard mode, thinking mode, and cache hits. The JSON format is as follows:
    json { "tiers": [ { "min_tokens": 0, "max_tokens": 32000, "input_price": 2.5, "output_price": 10, "thinking_input_price": 2.5, "thinking_output_price": 10, "cached_input_price": 2.5 }, { "min_tokens": 32000, "max_tokens": 128000, "input_price": 4, "output_price": 16, "thinking_input_price": 4, "thinking_output_price": 16, "cached_input_price": 4 } ] } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    tiers | array | Yes | A required array of tiered pricing objects. | -
    tiers[].min_tokens | integer | Yes | The lower bound (inclusive) of the token count for the current tier. | token
    tiers[].max_tokens | integer | Yes | The upper bound (exclusive) of the token count for the current tier. A value of 0 indicates no upper limit. | token
    tiers[].input_price | number | Yes | The unit price for input tokens in standard mode. | CNY / million tokens
    tiers[].output_price | number | Yes | The unit price for output tokens in standard mode. | CNY / million tokens
    tiers[].thinking_input_price | number | No | The unit price for input tokens in thinking mode. | CNY / million tokens
    tiers[].thinking_output_price | number | No | The unit price for output tokens in thinking mode. | CNY / million tokens
    tiers[].cached_input_price | number | No | The unit price for input tokens on a cache hit. | CNY / million tokens
    thinking_mode_tiers | array | No | Dedicated tiers for thinking mode. The structure is the same as tiers. If a request includes a reasoning_tokens field and this array is not empty, this array overrides the default tiers. | -
    Constraints:













  2. Per-image billing (per_image)
    Applies to ImageGeneration and ImageEdit models. Billing is based on the number of images generated or processed. The JSON format is as follows:
    json { "price_per_image": 0.2 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    price_per_image | number | Yes | The unit price per image. | CNY / image




  3. Video matrix billing (video_matrix)
    Applies to VideoGeneration and VideoImageGeneration models. Pricing is based on a combination of video resolution and the presence of audio.
    Note: The server automatically converts the matrix field, used by the frontend UI, to the tiers field required by the API.
    The JSON format is as follows:
    json { "tiers": [ { "resolution": 480, "has_audio": 0, "price_per_second": 0.24 }, { "resolution": 480, "has_audio": 1, "price_per_second": 0.24 }, { "resolution": 720, "has_audio": 0, "price_per_second": 0.24 }, { "resolution": 720, "has_audio": 1, "price_per_second": 0.24 } ], "default_price_per_second": 0.24 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    tiers | array | Yes | An array of video matrix pricing objects. | -
    tiers[].resolution | integer | Yes | The video resolution. Valid values: 480, 720, and 1080. | Pixel height (p)
    tiers[].has_audio | integer | Yes | Indicates whether audio is included. Valid values: 0 (no audio) and 1 (with audio). | -
    tiers[].price_per_second | number | Yes | The unit price per second for this combination. | CNY / second
    default_price_per_second | number | No | The default unit price per second, applied if the request's parameters do not match any item in the tiers array. | CNY / second
    Constraints:











  4. Per-duration billing (per_duration)
    Applies to speech recognition (ASR) models. Billing is based on the duration of the audio. The JSON format is as follows:
    json { "price_per_unit": 0.00022 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    price_per_unit | number | Yes | The unit price per second of audio. | CNY / second




  5. Per-character billing (per_character)
    Applies to speech synthesis (TTS) models. Billing is based on the number of characters in the synthesized text. The JSON format is as follows:
    json { "price_per_unit": 0.8 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    price_per_unit | number | Yes | The unit price per 10,000 characters. | CNY / 10,000 characters




  6. Flat-rate token billing (token_flat)
    Applies to Embedding, Rerank, MultimodalEmbedding, and MultimodalRerank models. This method uses a single unit price without tiers. The JSON format is as follows:
    json { "input_price": 0.5, "multimodal_input_price": 0.5 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    input_price | number | Yes | The unit price for text-only input tokens. | CNY / million tokens
    multimodal_input_price | number | No | The unit price for multimodal input tokens. | CNY / million tokens





  7. Omni-modal multi-dimension billing (omni_multimodal)
    Applies to omni-modal models, such as ChatFullmodal (for example, qwen3.5-omni-plus). Prices are set separately for different input and output modalities, such as text, audio, images, and videos. The JSON format is as follows:
    json { "text_input_price": 7, "audio_input_price": 53, "image_input_price": 7, "video_input_price": 7, "text_output_price": 40, "audio_output_price": 213, "multi_text_output_price": 0 } Field descriptions:
    Field | Type | Required | Description | Unit
    ---|---|---|---|---
    text_input_price | number | Yes | The unit price for text input tokens. | CNY / million tokens
    audio_input_price | number | Yes | The unit price for audio input tokens. | CNY / million tokens
    image_input_price | number | No | The unit price for image input tokens. | CNY / million tokens
    video_input_price | number | No | The unit price for video input tokens. | CNY / million tokens
    text_output_price | number | Yes | The unit price for text output tokens. | CNY / million tokens
    audio_output_price | number | No | The unit price for audio output tokens. | CNY / million tokens
    multi_text_output_price | number | No | The unit price for text output tokens when the input is multimodal (contains images, audio, or video). | CNY / million tokens

    Automatic billing type mapping
    Model type (model_type) | Auto-detected billing type | Key identifying field in pricingConfig
    ---|---|---
    Chat | token_tiered | The tiers field is present.
    ChatFullmodal | omni_multimodal | The text_input_price or audio_input_price field is present.
    ImageGeneration / ImageEdit | per_image | The price_per_image field is present.
    VideoGeneration / VideoImageGeneration | video_matrix | The tiers field is present, and its elements contain resolution.
    ASR | per_duration | The price_per_unit field is present (ASR scenario).
    TTS | per_character | The price_per_unit field is present (TTS scenario).
    Embedding / Rerank / MultimodalEmbedding / MultimodalRerank | token_flat | The input_price field is present.





















{ "tiers": [ { "min_tokens": 0, "max_tokens": 32000, "input_price": 2.5, "output_price": 2.5, "thinking_output_price": 10, "cached_input_price": 1.25 }, { "min_tokens": 32000, "max_tokens": 0, "input_price": 1.25, "output_price": 1.25, "thinking_output_price": 5, "cached_input_price": 0.625 } ] }

effectiveTime

string

No

The effective time, in RFC3339 format.

2024-01-01T00:00:00Z

expireTime

string

No

The expiration time, in RFC3339 format.

2025-01-01T00:00:00Z

status

integer

No

The status of the billing rule. Use this field to enable or disable the rule.

1

version

integer

No

The version number of the billing rule.

1

Response elements

Element

Type

Description

Example

object

The response object.

{ "success": true, "data": {"id": 1, "billing_type": "token_tiered"}, "requestId": "592A27EF-26D3-1434-98C1-97AD63337852" }

requestId

string

The request ID.

xxxx-xxxx-xxxx-xxxxxxxx

success

boolean

Indicates whether the request is successful.

true

errCode

string

The error code.

UNKNOWN_ERROR

errMessage

string

The error message.

未知错误

httpStatusCode

integer

The HTTP status code.

200

data

object

The returned data.

id

integer

The rule ID.

1

modelId

integer

The model ID.

1

modelCode

string

The model ID.

qwen-plus

modelName

string

The model name.

通义千问Plus

modelType

string

The model type.

chat

symbol

string

The vendor ID.

alibaba

billingType

string

The billing type.

token_tiered

pricingConfig

any

The billing configuration.

{}

effectiveTime

string

The time when the rule takes effect.

2024-01-01T00:00:00Z

expireTime

string

The expiration time.

2025-01-01T00:00:00Z

version

integer

The version number.

1

deleteTag

integer

The deletion tag.

0

gmtCreate

string

The creation time.

2024-01-01T00:00:00Z

gmtModified

string

The modification time.

2024-01-01T00:00:00Z

Examples

Success response

JSON format

{
  "requestId": "xxxx-xxxx-xxxx-xxxxxxxx",
  "success": true,
  "errCode": "UNKNOWN_ERROR",
  "errMessage": "未知错误",
  "httpStatusCode": 200,
  "data": {
    "id": 1,
    "modelId": 1,
    "modelCode": "qwen-plus",
    "modelName": "通义千问Plus",
    "modelType": "chat",
    "symbol": "alibaba",
    "billingType": "token_tiered",
    "pricingConfig": "{}",
    "effectiveTime": "2024-01-01T00:00:00Z",
    "expireTime": "2025-01-01T00:00:00Z",
    "version": 1,
    "deleteTag": 0,
    "gmtCreate": "2024-01-01T00:00:00Z",
    "gmtModified": "2024-01-01T00:00:00Z"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

200 B.Resource.NotFoundException B.Resource.NotFoundException.
200 B.Billing.RuleNotFoundException B.Billing.RuleNotFoundException.
500 Server.Internal.UnknownError The request processing has failed due to some unknown error.
403 B.Permission.OrgNoExistException B.Permission .OrgNoExistException. Authentication failed-Organization does not exist

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.