> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# claude-sonnet-5

> 发送结构化输入消息列表，Claude Sonnet 5 将生成对话中的下一条消息。



## OpenAPI

````yaml zh/api-reference/model-api/anthropic/openapi/claude-sonnet-5/openapi.yaml POST /v1/messages
openapi: 3.1.0
info:
  title: Claude Sonnet 5
  description: >-
    通过 Anyfast 调用 Anthropic Claude Sonnet 5。默认启用自适应思维，最大输出为 128K
    Token，且不支持手动扩展思维。
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/messages:
    post:
      summary: 创建消息
      description: 发送结构化输入消息列表，Claude Sonnet 5 将生成对话中的下一条消息。
      operationId: createMessageClaudeSonnet5
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - max_tokens
                - messages
              properties:
                model:
                  type: string
                  enum:
                    - claude-sonnet-5
                  description: 模型 ID。
                  example: claude-sonnet-5
                messages:
                  type: array
                  minItems: 1
                  description: 输入消息列表。每条消息包含角色和内容。
                  items:
                    type: object
                    required:
                      - role
                      - content
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                        description: 消息作者的角色。
                      content:
                        oneOf:
                          - type: string
                          - type: array
                            items:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                    - image
                                text:
                                  type: string
                                source:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                    media_type:
                                      type: string
                                    data:
                                      type: string
                        description: 消息内容。可以是字符串或内容块数组。
                  example:
                    - role: user
                      content: 你好，Claude！
                max_tokens:
                  type: integer
                  minimum: 1
                  maximum: 128000
                  description: 生成前允许的最大 token 数。Claude Sonnet 5 最多支持 128K 输出 Token。
                  example: 1024
                system:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: object
                        properties:
                          type:
                            type: string
                          text:
                            type: string
                  description: 系统提示词，用于提供上下文和指令。
                metadata:
                  type: object
                  properties:
                    user_id:
                      type: string
                      description: 与请求关联的外部用户标识。
                  description: 请求的元数据对象。
                stop_sequences:
                  type: array
                  items:
                    type: string
                  description: 会导致模型停止生成的自定义文本序列。
                temperature:
                  type: number
                  minimum: 0
                  maximum: 1
                  default: 1
                  description: 注入到响应中的随机性程度。在 Claude Sonnet 5 上，非默认值会返回 400 错误。
                  example: 1
                top_p:
                  type: number
                  minimum: 0
                  maximum: 1
                  description: 核采样。在 Claude Sonnet 5 上，非默认值会返回 400 错误。
                top_k:
                  type: integer
                  minimum: 0
                  description: 每个后续 token 仅从前 K 个选项中采样。在 Claude Sonnet 5 上，非默认值会返回 400 错误。
                stream:
                  type: boolean
                  default: false
                  description: 是否使用服务器发送事件增量流式返回响应。
                tools:
                  type: array
                  items:
                    type: object
                    required:
                      - name
                      - input_schema
                    properties:
                      name:
                        type: string
                        description: 工具名称。
                      description:
                        type: string
                        description: 工具功能描述。
                      input_schema:
                        type: object
                        description: 工具输入的 JSON Schema。
                  description: 模型可使用的工具定义。
                tool_choice:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - auto
                        - any
                        - tool
                      description: 模型如何使用所提供的工具。
                    name:
                      type: string
                      description: 要使用的工具名称（当 type 为 "tool" 时）。
                  description: 模型如何使用工具。
                output_config:
                  type: object
                  properties:
                    effort:
                      type: string
                      enum:
                        - low
                        - medium
                        - high
                        - xhigh
                        - max
                      default: high
                      description: 控制自适应思维深度和 token 使用量。Claude Sonnet 5 默认 high。
                  description: 支持自适应思维 effort 的模型输出控制配置。
                thinking:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - adaptive
                        - disabled
                      description: 是否显式使用自适应思维或关闭思维。
                  description: >-
                    自适应思维配置。Claude Sonnet 5 默认启用自适应思维；请用 output_config.effort
                    控制深度。不支持手动扩展思维。
      responses:
        '200':
          description: 消息创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '400':
          description: 请求无效
          content:
            application/json:
              schema:
                $ref: 774d6950-f0fb-4529-994a-bcd1ee931e74
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: 774d6950-f0fb-4529-994a-bcd1ee931e74
        '429':
          description: 触发速率限制
          content:
            application/json:
              schema:
                $ref: 774d6950-f0fb-4529-994a-bcd1ee931e74
components:
  schemas:
    Message:
      type: object
      required:
        - id
        - type
        - role
        - content
        - model
        - stop_reason
        - usage
      properties:
        id:
          type: string
          example: msg_01XFDUDYJgAACzvnptvVoYEL
        type:
          type: string
          example: message
        role:
          type: string
          example: assistant
        content:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - text
                  - thinking
                  - tool_use
              text:
                type: string
              thinking:
                type: string
              id:
                type: string
              name:
                type: string
              input:
                type: object
          example:
            - type: text
              text: 你好！我能帮你做什么？
        model:
          type: string
          example: claude-sonnet-5
        stop_reason:
          type: string
          enum:
            - end_turn
            - max_tokens
            - stop_sequence
            - tool_use
            - refusal
            - null
          description: 被模型拒绝的请求会返回 `refusal`。
        stop_sequence:
          type: string
          nullable: true
        usage:
          type: object
          properties:
            input_tokens:
              type: integer
            output_tokens:
              type: integer
            cache_creation_input_tokens:
              type: integer
            cache_read_input_tokens:
              type: integer

````