Skip to content

1. Model Price Management (Model Price) ​

Manage per-model token pricing (¥ per million tokens) and per-request pricing. Requires Root.

1.1 List All Model Prices ​

Endpoint: GET /api/model_price/

Auth: Root

Request parameters: None

Response:

json
{
  "success": true,
  "message": "",
  "data": [
    {
      "id": 1,
      "model_name": "gpt-4o",
      "input_price": 2.5,
      "output_price": 10.0,
      "cached_price": 1.25,
      "per_request_price": 0,
      "billing_type": "token",
      "enabled": true,
      "created_at": 1718000000,
      "updated_at": 1718000000
    }
  ]
}

Response fields:

FieldTypeDescription
iduintRecord ID
model_namestringModel name (unique)
input_pricefloatInput price (¥ per million tokens)
output_pricefloatOutput price (¥ per million tokens)
cached_pricefloatCached price (¥ per million tokens), 0 means unsupported
per_request_pricefloatPer-request price (¥ per request)
billing_typestringBilling type: token or per_request
enabledboolWhether enabled
created_atint64Created at (Unix timestamp)
updated_atint64Updated at (Unix timestamp)

1.2 Add a Model Price ​

Endpoint: POST /api/model_price/

Auth: Root

Request body:

json
{
  "model_name": "gpt-4o",
  "input_price": 2.5,
  "output_price": 10.0,
  "cached_price": 1.25,
  "per_request_price": 0,
  "billing_type": "token",
  "enabled": true
}

Request fields:

FieldTypeRequiredDescription
model_namestringyesModel name, must be unique
input_pricefloatnoInput price, default 0
output_pricefloatnoOutput price, default 0
cached_pricefloatnoCached price, default 0
per_request_pricefloatnoPer-request price, default 0
billing_typestringnotoken (default) or per_request
enabledboolnoDefault true

Response:

json
{
  "success": true,
  "message": ""
}

Errors:

  • Empty model_name: {"success": false, "message": "模型名称不能为空"}
  • Duplicate model_name: DB unique-constraint violation.

1.3 Update a Model Price ​

Endpoint: PUT /api/model_price/

Auth: Root

Request body:

json
{
  "id": 1,
  "model_name": "gpt-4o",
  "input_price": 3.0,
  "output_price": 12.0,
  "cached_price": 1.5,
  "per_request_price": 0,
  "billing_type": "token",
  "enabled": true
}

Request fields:

FieldTypeRequiredDescription
iduintyesRecord ID
model_namestringnoModel name (used as the lookup key during update, not changed)
input_pricefloatnoInput price
output_pricefloatnoOutput price
cached_pricefloatnoCached price
per_request_pricefloatnoPer-request price
billing_typestringnoBilling type
enabledboolnoWhether enabled

Response:

json
{
  "success": true,
  "message": ""
}

Errors:

  • id is 0: {"success": false, "message": "ID不能为空"}

1.4 Delete a Model Price ​

Endpoint: DELETE /api/model_price/:id

Auth: Root

Path parameters:

ParameterTypeDescription
idintModel price record ID

Response:

json
{
  "success": true,
  "message": ""
}

Errors:

  • Invalid id: {"success": false, "message": "无效的ID"}