{
  "openapi": "3.1.0",
  "info": {
    "title": "BigModel.io API",
    "version": "2026-10-18",
    "summary": "OpenAI- and Anthropic-compatible gateway for GLM, DeepSeek, Kimi, MiniMax, Doubao and other models.",
    "description": "One API key for every model your key group serves. OpenAI clients use `https://bigmodel.io/v1`; Anthropic clients use `https://bigmodel.io` and append `/v1/messages`. Which endpoints and models a key can call depends on its group. Guides: https://bigmodel.io/docs",
    "contact": {
      "name": "BigModel.io support",
      "email": "support@bigmodel.io",
      "url": "https://bigmodel.io/docs"
    }
  },
  "servers": [
    {
      "url": "https://bigmodel.io/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Text",
      "description": "Chat Completions, Messages and Responses."
    },
    {
      "name": "Models",
      "description": "Model listing."
    },
    {
      "name": "Account",
      "description": "Key quota, balance and usage."
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "tags": [
          "Text"
        ],
        "summary": "Create a chat completion",
        "description": "OpenAI Chat Completions. Works for every key group that serves text models. Accepts OpenRouter-style `provider/model` names and a `models` fallback list.",
        "requestBody": {
          "required": true,
          "description": "Standard OpenAI Chat Completions body. For GLM, DeepSeek and Qwen groups the body is passed to the provider as is (only `model` is rewritten), so support for each field depends on the model. Other groups convert the request, and `response_format`, `n`, `seed`, `user` and `logprobs` are dropped there.",
          "x-zh": "标准 OpenAI Chat Completions 请求体。GLM、DeepSeek、Qwen 分组会把请求体原样交给服务商（只改写 `model`），各字段是否生效取决于模型。其他分组会转换请求，转换时 `response_format`、`n`、`seed`、`user`、`logprobs` 会被丢弃。",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A chat completion, or an SSE stream when `stream` is true.",
            "x-zh": "对话补全结果；`stream` 为 true 时为 SSE 流。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "description": "With `stream: true` the response is a server-sent event stream of `chat.completion.chunk` objects ending with `data: [DONE]`. The gateway asks the upstream for a final usage chunk.",
                "x-zh": "`stream: true` 时返回 SSE 流，每个事件是一个 `chat.completion.chunk`，以 `data: [DONE]` 结束。网关会要求上游在最后返回用量。",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/KeyLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/messages": {
      "post": {
        "operationId": "createMessage",
        "tags": [
          "Text"
        ],
        "summary": "Create a message (Anthropic)",
        "description": "Anthropic Messages. Anthropic clients set the base URL to `https://bigmodel.io`. Groups that only serve Chat Completions return 404.",
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "2023-06-01"
              ]
            },
            "description": "Anthropic API version header sent by Anthropic SDKs.",
            "x-zh": "Anthropic SDK 发送的 API 版本请求头。"
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Standard Anthropic Messages body.",
          "x-zh": "标准 Anthropic Messages 请求体。",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A message, or Anthropic SSE events when `stream` is true.",
            "x-zh": "消息结果；`stream` 为 true 时为 Anthropic SSE 事件流。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              },
              "text/event-stream": {
                "description": "With `stream: true` the response is the Anthropic event stream: `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, `message_stop`.",
                "x-zh": "`stream: true` 时返回 Anthropic 事件流：`message_start`、`content_block_start`、`content_block_delta`、`content_block_stop`、`message_delta`、`message_stop`。",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ChatOnly"
          },
          "409": {
            "$ref": "#/components/responses/SessionState"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/KeyLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/messages/count_tokens": {
      "post": {
        "operationId": "countMessageTokens",
        "tags": [
          "Text"
        ],
        "summary": "Count tokens for a message",
        "description": "Counts input tokens for an Anthropic Messages body without generating. Not recorded as usage. Not available for OpenAI or Chat-Completions-only groups.",
        "requestBody": {
          "required": true,
          "description": "An Anthropic Messages body; `max_tokens` is not needed.",
          "x-zh": "Anthropic Messages 请求体，不需要 `max_tokens`。",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CountTokensRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token count, as returned by the upstream.",
            "x-zh": "上游返回的 token 计数。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "input_tokens": {
                      "type": "integer",
                      "description": "Input tokens the request would use.",
                      "x-zh": "该请求的输入 token 数。"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Token counting is not supported for this key group.",
            "x-zh": "该 Key 所在分组不支持 token 计数。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/KeyLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/responses": {
      "post": {
        "operationId": "createResponse",
        "tags": [
          "Text"
        ],
        "summary": "Create a response (OpenAI Responses)",
        "description": "OpenAI Responses API, used by Codex CLI. `previous_response_id` is not supported over HTTP; send the full `input` each turn.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponseRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A response object, or Responses SSE events when `stream` is true.",
            "x-zh": "响应对象；`stream` 为 true 时为 Responses SSE 事件流。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "description": "With `stream: true` the response is the Responses event stream (`response.created`, `response.output_text.delta`, …, `response.completed`).",
                "x-zh": "`stream: true` 时返回 Responses 事件流（`response.created`、`response.output_text.delta` …… `response.completed`）。",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/ChatOnly"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/KeyLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/models": {
      "get": {
        "operationId": "listModels",
        "tags": [
          "Models"
        ],
        "summary": "List models",
        "description": "Models your key group serves. Needs a positive balance or an active plan.",
        "parameters": [
          {
            "name": "configured_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Return an empty list instead of built-in defaults when the group has no configured models.",
            "x-zh": "分组未配置模型时返回空列表，而不是内置默认列表。"
          }
        ],
        "responses": {
          "200": {
            "description": "The model list.",
            "x-zh": "模型列表。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/KeyLimited"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "operationId": "getKeyUsage",
        "tags": [
          "Account"
        ],
        "summary": "Get key quota, balance and usage",
        "description": "Balance or quota for the calling key, its rate-limit windows, and token usage. Works even when the key is expired or out of quota, so tools can show why.",
        "parameters": [
          {
            "name": "start_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Start of the `model_stats` range (YYYY-MM-DD). Default: 30 days ago.",
            "x-zh": "`model_stats` 统计起始日期（YYYY-MM-DD），默认 30 天前。"
          },
          {
            "name": "end_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "End of the `model_stats` range (YYYY-MM-DD). Default: today.",
            "x-zh": "`model_stats` 统计结束日期（YYYY-MM-DD），默认今天。"
          }
        ],
        "responses": {
          "200": {
            "description": "Usage for the key. Fields depend on `mode`.",
            "x-zh": "Key 的用量。字段随 `mode` 不同。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/KeyInQuery"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/KeyForbidden"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer sk-...`. Keys in the query string are rejected."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Anthropic-style key header."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": "Your unique id for this task (1–200 characters, no surrounding spaces). Retrying with the same key and body returns the same task.",
        "x-zh": "你为该任务生成的唯一 ID（1–200 字符，首尾无空格）。相同的键和请求体重试会返回同一个任务。"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`api_key_in_query_deprecated` (key sent in the query string), or `invalid_request_error`: empty or invalid JSON, missing `model`, a non-boolean `stream`, or another malformed field.",
        "x-zh": "`api_key_in_query_deprecated`（Key 放在了查询参数里），或 `invalid_request_error`：请求体为空或不是合法 JSON、缺少 `model`、`stream` 不是布尔值等。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/KeyError"
                },
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      },
      "KeyForbidden": {
        "description": "`ACCESS_DENIED` (IP rule) or `permission_error` (key without a group).",
        "x-zh": "`ACCESS_DENIED`（IP 规则）或 `permission_error`（Key 未分配分组）。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/KeyError"
                },
                {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              ]
            }
          }
        }
      },
      "KeyInQuery": {
        "description": "`api_key_in_query_deprecated`: the key was sent as `?key=` or `?api_key=`. Send it in a header.",
        "x-zh": "`api_key_in_query_deprecated`：Key 放在了 `?key=` 或 `?api_key=` 里，请改用请求头。",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/KeyError"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`API_KEY_REQUIRED`, `INVALID_API_KEY`, `API_KEY_DISABLED`, `USER_NOT_FOUND`, `USER_INACTIVE`.",
        "x-zh": "`API_KEY_REQUIRED`、`INVALID_API_KEY`、`API_KEY_DISABLED`、`USER_NOT_FOUND`、`USER_INACTIVE`。",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/KeyError"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`INSUFFICIENT_BALANCE`, `API_KEY_EXPIRED`, `ACCESS_DENIED` (IP rule), `SUBSCRIPTION_NOT_FOUND`, `SUBSCRIPTION_INVALID`, or a `permission_error` (key without a group, endpoint not allowed for the group).",
        "x-zh": "`INSUFFICIENT_BALANCE`、`API_KEY_EXPIRED`、`ACCESS_DENIED`（IP 规则）、`SUBSCRIPTION_NOT_FOUND`、`SUBSCRIPTION_INVALID`，或 `permission_error`（Key 未分配分组、分组不允许该接口）。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/KeyError"
                },
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      },
      "KeyLimited": {
        "description": "`API_KEY_QUOTA_EXHAUSTED`, `USAGE_LIMIT_EXCEEDED` (plan limit), or `rate_limit_exceeded` / `rate_limit_error` (key 5h/1d/7d limit, requests per minute, concurrency, upstream). RPM limits send `Retry-After`.",
        "x-zh": "`API_KEY_QUOTA_EXHAUSTED`、`USAGE_LIMIT_EXCEEDED`（套餐额度），或 `rate_limit_exceeded` / `rate_limit_error`（Key 的 5 小时/1 天/7 天限额、每分钟请求数、并发、上游限流）。每分钟限流会带 `Retry-After`。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/KeyError"
                },
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      },
      "TooLarge": {
        "description": "Request body too large.",
        "x-zh": "请求体过大。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      },
      "ChatOnly": {
        "description": "`not_found_error`: the key group only serves `/v1/chat/completions`.",
        "x-zh": "`not_found_error`：该 Key 所在分组只提供 `/v1/chat/completions`。",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AnthropicError"
            }
          }
        }
      },
      "SessionState": {
        "description": "`malformed_session_state`: the conversation history has thinking blocks or tool ids the model cannot accept. Start a new session.",
        "x-zh": "`malformed_session_state`：对话历史中的思考块或工具 ID 无法被模型接受，请开新会话。",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AnthropicError"
            }
          }
        }
      },
      "Upstream": {
        "description": "`upstream_error`: the model provider failed.",
        "x-zh": "`upstream_error`：模型服务商出错。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      },
      "Unavailable": {
        "description": "`api_error` and similar: no capacity for this model in your group right now, or the model is not served by your group (`No available accounts`).",
        "x-zh": "`api_error` 等：分组暂时没有该模型的可用容量，或分组不提供该模型（`No available accounts`）。",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AnthropicError"
                },
                {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              ]
            }
          }
        }
      }
    },
    "schemas": {
      "KeyError": {
        "type": "object",
        "description": "Errors from key checks, before the request reaches a model.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "examples": [
              "INVALID_API_KEY"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AnthropicError": {
        "type": "object",
        "required": [
          "type",
          "error"
        ],
        "properties": {
          "type": {
            "const": "error"
          },
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "examples": [
                  "not_found_error"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "OpenAIError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "examples": [
                  "rate_limit_error"
                ]
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ],
            "description": "Who wrote the message.",
            "x-zh": "消息的角色。"
          },
          "content": {
            "description": "Text, or an array of content parts (`text`, `image_url`) for models that accept images.",
            "x-zh": "文本，或内容片段数组（`text`、`image_url`，用于支持图片输入的模型）。",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Tool calls made by the assistant in an earlier turn.",
            "x-zh": "之前轮次中助手发起的工具调用。"
          },
          "tool_call_id": {
            "type": "string",
            "description": "For `tool` messages: the call this result answers.",
            "x-zh": "`tool` 消息：对应的工具调用 ID。"
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "additionalProperties": true,
        "properties": {
          "model": {
            "type": "string",
            "description": "Model ID from the catalog, e.g. `glm-5.3`. OpenRouter-style names such as `z-ai/glm-5.3` are resolved too.",
            "x-zh": "模型目录中的模型 ID，例如 `glm-5.3`。也可用 OpenRouter 风格的名称，如 `z-ai/glm-5.3`。"
          },
          "models": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Fallback models tried in order after `model` (at most 5 attempts in total). Removed before forwarding.",
            "x-zh": "在 `model` 之后依次尝试的备用模型（总共最多 5 次尝试）。转发前会被移除。"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "description": "The conversation so far.",
            "x-zh": "对话内容。"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "Stream the reply as server-sent events.",
            "x-zh": "以 SSE 流式返回。"
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            },
            "description": "Stream options. Usage is always requested from the upstream.",
            "x-zh": "流式选项。网关总会向上游请求用量。"
          },
          "max_tokens": {
            "type": "integer",
            "description": "Maximum tokens to generate.",
            "x-zh": "最多生成的 token 数。"
          },
          "max_completion_tokens": {
            "type": "integer",
            "description": "Newer name for `max_tokens`.",
            "x-zh": "`max_tokens` 的新名称。"
          },
          "temperature": {
            "type": "number",
            "description": "Sampling temperature.",
            "x-zh": "采样温度。"
          },
          "top_p": {
            "type": "number",
            "description": "Nucleus sampling.",
            "x-zh": "核采样。"
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "description": "Stop sequences.",
            "x-zh": "停止序列。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Function tools the model may call.",
            "x-zh": "模型可调用的函数工具。"
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object"
              }
            ],
            "description": "`auto`, `none`, `required`, or a specific function.",
            "x-zh": "`auto`、`none`、`required` 或指定函数。"
          },
          "response_format": {
            "type": "object",
            "description": "JSON mode or JSON schema, where the model supports it. Passed through on GLM, DeepSeek and Qwen groups; dropped on groups that convert the request.",
            "x-zh": "JSON 模式或 JSON Schema（取决于模型是否支持）。GLM、DeepSeek、Qwen 分组原样透传；会转换请求的分组会丢弃该字段。"
          },
          "reasoning_effort": {
            "type": "string",
            "description": "Reasoning effort for models that support it.",
            "x-zh": "推理强度（仅支持的模型）。"
          }
        }
      },
      "ChatCompletion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string",
            "description": "The model that answered.",
            "x-zh": "实际回答的模型。"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "$ref": "#/components/schemas/ChatMessage"
                },
                "finish_reason": {
                  "type": "string",
                  "description": "`stop`, `length`, `tool_calls`, …"
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "completion_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "MessageRequest": {
        "type": "object",
        "required": [
          "model",
          "max_tokens",
          "messages"
        ],
        "additionalProperties": true,
        "properties": {
          "model": {
            "type": "string",
            "description": "Model ID, e.g. `glm-5.3`.",
            "x-zh": "模型 ID，例如 `glm-5.3`。"
          },
          "max_tokens": {
            "type": "integer",
            "description": "Maximum tokens to generate.",
            "x-zh": "最多生成的 token 数。"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role",
                "content"
              ],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  ]
                }
              }
            },
            "description": "Alternating user and assistant turns.",
            "x-zh": "交替的 user 和 assistant 消息。"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ],
            "description": "System prompt. Blocks may carry `cache_control`.",
            "x-zh": "系统提示词，内容块可带 `cache_control`。"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "Stream Anthropic SSE events.",
            "x-zh": "以 Anthropic SSE 流式返回。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Tools with `name`, `description` and `input_schema`.",
            "x-zh": "工具定义（`name`、`description`、`input_schema`）。"
          },
          "tool_choice": {
            "type": "object"
          },
          "thinking": {
            "type": "object",
            "description": "Extended thinking settings, for models that support them.",
            "x-zh": "扩展思考设置（仅支持的模型）。"
          },
          "temperature": {
            "type": "number"
          },
          "metadata": {
            "type": "object",
            "properties": {
              "user_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "CountTokensRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "additionalProperties": true,
        "properties": {
          "model": {
            "type": "string",
            "description": "Model ID.",
            "x-zh": "模型 ID。"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "The messages to count.",
            "x-zh": "要计数的消息。"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "const": "message"
          },
          "role": {
            "const": "assistant"
          },
          "model": {
            "type": "string"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "`text`, `thinking` and `tool_use` blocks.",
            "x-zh": "`text`、`thinking`、`tool_use` 内容块。"
          },
          "stop_reason": {
            "type": "string",
            "description": "`end_turn`, `max_tokens`, `tool_use`, …"
          },
          "usage": {
            "type": "object",
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              },
              "cache_creation_input_tokens": {
                "type": "integer"
              },
              "cache_read_input_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ResponseRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "additionalProperties": true,
        "properties": {
          "model": {
            "type": "string",
            "description": "Model ID.",
            "x-zh": "模型 ID。"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ],
            "description": "Text or input items.",
            "x-zh": "文本或输入项数组。"
          },
          "instructions": {
            "type": "string",
            "description": "System instructions.",
            "x-zh": "系统指令。"
          },
          "stream": {
            "type": "boolean",
            "description": "Must be a boolean when present.",
            "x-zh": "如提供必须是布尔值。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "reasoning": {
            "type": "object",
            "properties": {
              "effort": {
                "type": "string"
              }
            }
          },
          "previous_response_id": {
            "type": "string",
            "description": "Not supported over HTTP (returns 400). Send the whole conversation in `input`.",
            "x-zh": "HTTP 方式不支持（返回 400），请在 `input` 中带上完整对话。"
          }
        }
      },
      "ModelList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Model ID to send as `model`.",
                  "x-zh": "作为 `model` 发送的模型 ID。"
                },
                "type": {
                  "type": "string",
                  "examples": [
                    "model"
                  ]
                },
                "display_name": {
                  "type": "string",
                  "description": "Currently the same as `id` for configured models.",
                  "x-zh": "已配置模型目前与 `id` 相同。"
                },
                "created_at": {
                  "type": "string",
                  "description": "Present on Anthropic-style entries; a fixed placeholder date, not a release date.",
                  "x-zh": "Anthropic 风格条目才有；是固定的占位日期，不是发布日期。"
                },
                "object": {
                  "type": "string",
                  "description": "Present on OpenAI-style entries.",
                  "x-zh": "OpenAI 风格条目才有。"
                },
                "owned_by": {
                  "type": "string",
                  "description": "Present on OpenAI-style entries.",
                  "x-zh": "OpenAI 风格条目才有。"
                }
              }
            }
          }
        }
      },
      "KeyUsage": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "quota_limited",
              "unrestricted"
            ],
            "description": "`quota_limited` when the key has its own quota or rate limits; otherwise `unrestricted` (it draws on your balance or plan).",
            "x-zh": "Key 设置了自己的额度或限额时为 `quota_limited`，否则为 `unrestricted`（使用账户余额或套餐）。"
          },
          "isValid": {
            "type": "boolean",
            "description": "True for keys that are active, out of quota or expired. Check `status` to see which.",
            "x-zh": "Key 处于正常、额度用完或已过期时都为 true，具体看 `status`。"
          },
          "status": {
            "type": "string",
            "description": "`quota_limited` only: `active`, `quota_exhausted`, `expired`, …",
            "x-zh": "仅 `quota_limited`：`active`、`quota_exhausted`、`expired` 等。"
          },
          "planName": {
            "type": "string",
            "description": "`unrestricted` only: plan (group) name, or the wallet.",
            "x-zh": "仅 `unrestricted`：套餐（分组）名或钱包余额。"
          },
          "remaining": {
            "type": "number",
            "description": "Remaining USD: key quota, balance, or the smallest plan allowance (`-1` when unlimited).",
            "x-zh": "剩余美元：Key 额度、余额，或套餐各周期中最小的剩余额度（无限制时为 `-1`）。"
          },
          "unit": {
            "const": "USD"
          },
          "balance": {
            "type": "number",
            "description": "Wallet balance in USD, when the key uses the balance.",
            "x-zh": "使用余额时的钱包余额（美元）。"
          },
          "quota": {
            "type": "object",
            "description": "`quota_limited` keys with a quota.",
            "x-zh": "设置了额度的 `quota_limited` Key。",
            "properties": {
              "limit": {
                "type": "number"
              },
              "used": {
                "type": "number"
              },
              "remaining": {
                "type": "number"
              },
              "unit": {
                "const": "USD"
              }
            }
          },
          "rate_limits": {
            "type": "array",
            "description": "Spending windows set on the key.",
            "x-zh": "Key 上设置的消费窗口。",
            "items": {
              "type": "object",
              "properties": {
                "window": {
                  "type": "string",
                  "enum": [
                    "5h",
                    "1d",
                    "7d"
                  ]
                },
                "limit": {
                  "type": "number"
                },
                "used": {
                  "type": "number"
                },
                "remaining": {
                  "type": "number"
                },
                "window_start": {
                  "type": "string"
                },
                "reset_at": {
                  "type": "string"
                }
              }
            }
          },
          "expires_at": {
            "type": "string",
            "description": "Key expiry, if set.",
            "x-zh": "Key 过期时间（如有）。"
          },
          "days_until_expiry": {
            "type": "integer"
          },
          "subscription": {
            "type": "object",
            "description": "Plan allowances and usage, in USD.",
            "x-zh": "套餐的额度与已用（美元）。",
            "properties": {
              "daily_usage_usd": {
                "type": "number"
              },
              "weekly_usage_usd": {
                "type": "number"
              },
              "monthly_usage_usd": {
                "type": "number"
              },
              "daily_limit_usd": {
                "type": "number"
              },
              "weekly_limit_usd": {
                "type": "number"
              },
              "monthly_limit_usd": {
                "type": "number"
              },
              "expires_at": {
                "type": "string"
              }
            }
          },
          "usage": {
            "type": "object",
            "description": "Token usage of this key. Omitted if unavailable.",
            "x-zh": "该 Key 的 token 用量，暂不可用时省略。",
            "properties": {
              "today": {
                "type": "object",
                "properties": {
                  "requests": {
                    "type": "integer"
                  },
                  "input_tokens": {
                    "type": "integer"
                  },
                  "output_tokens": {
                    "type": "integer"
                  },
                  "cache_creation_tokens": {
                    "type": "integer"
                  },
                  "cache_read_tokens": {
                    "type": "integer"
                  },
                  "total_tokens": {
                    "type": "integer"
                  },
                  "cost": {
                    "type": "number",
                    "description": "Cost at list price, USD.",
                    "x-zh": "按标价计算的费用（美元）。"
                  },
                  "actual_cost": {
                    "type": "number",
                    "description": "Amount actually charged, USD.",
                    "x-zh": "实际扣费（美元）。"
                  }
                }
              },
              "total": {
                "type": "object",
                "properties": {
                  "requests": {
                    "type": "integer"
                  },
                  "input_tokens": {
                    "type": "integer"
                  },
                  "output_tokens": {
                    "type": "integer"
                  },
                  "cache_creation_tokens": {
                    "type": "integer"
                  },
                  "cache_read_tokens": {
                    "type": "integer"
                  },
                  "total_tokens": {
                    "type": "integer"
                  },
                  "cost": {
                    "type": "number",
                    "description": "Cost at list price, USD.",
                    "x-zh": "按标价计算的费用（美元）。"
                  },
                  "actual_cost": {
                    "type": "number",
                    "description": "Amount actually charged, USD.",
                    "x-zh": "实际扣费（美元）。"
                  }
                }
              },
              "average_duration_ms": {
                "type": "number"
              },
              "rpm": {
                "type": "number"
              },
              "tpm": {
                "type": "number"
              }
            }
          },
          "model_stats": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Per-model usage for the date range. Omitted if unavailable.",
            "x-zh": "日期范围内的分模型用量，暂不可用时省略。"
          }
        }
      }
    }
  }
}