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

# Claude 格式 - 调用工具消息

> - 适用于所有兼容 Claude 格式模型的通用 Anthropic Messages API（含工具调用）
- 工具调用：支持 Function Calling，定义模型可调用的工具
- 多模态输入：支持文本 + 图像混合输入
- 扩展思考：支持思维链推理模式
- 支持流式和非流式响应




## OpenAPI

````yaml openapi/zh/claude-format-tool-calling-messages.json POST /v1/messages
openapi: 3.1.0
info:
  title: Claude Format - Tool Calling Messages
  version: '1.0'
servers:
  - url: https://api.aihubmax.com
security:
  - BearerAuth: []
paths:
  /v1/messages:
    post:
      tags:
        - Text Series > Claude Format
      summary: Claude Format - Tool Calling Messages
      description: |
        - 适用于所有兼容 Claude 格式模型的通用 Anthropic Messages API（含工具调用）
        - 工具调用：支持 Function Calling，定义模型可调用的工具
        - 多模态输入：支持文本 + 图像混合输入
        - 扩展思考：支持思维链推理模式
        - 支持流式和非流式响应
      operationId: claude-format-tool-calling-messages
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClaudeMessagesRequest'
            examples:
              tool-calling-weather:
                summary: 天气查询
                description: 让模型调用天气查询工具
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: 深圳现在天气怎么样？适合去海边吗？
                  tools:
                    - name: get_weather
                      description: 获取指定城市的当前天气信息
                      input_schema:
                        type: object
                        properties:
                          city:
                            type: string
                            description: 城市名称
                          unit:
                            type: string
                            enum:
                              - celsius
                              - fahrenheit
                            description: 温度单位
                        required:
                          - city
              tool-calling-search:
                summary: 网页搜索
                description: 让模型调用搜索工具查找信息
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 2048
                  messages:
                    - role: user
                      content: 帮我查一下最新的 React 19 有哪些新特性
                  tools:
                    - name: web_search
                      description: 在互联网上搜索最新信息
                      input_schema:
                        type: object
                        properties:
                          query:
                            type: string
                            description: 搜索关键词
                          num_results:
                            type: integer
                            description: 返回结果数量
                            default: 5
                        required:
                          - query
              tool-calling-multi-tools:
                summary: 多工具定义
                description: 定义多个工具供模型选择调用
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 2048
                  messages:
                    - role: user
                      content: 帮我看看明天北京的天气，然后在我的日历上创建一个户外跑步的日程
                  tools:
                    - name: get_weather
                      description: 获取天气预报
                      input_schema:
                        type: object
                        properties:
                          city:
                            type: string
                            description: 城市名称
                          days:
                            type: integer
                            description: 预报天数（1-7）
                        required:
                          - city
                    - name: create_calendar_event
                      description: 在日历中创建事件
                      input_schema:
                        type: object
                        properties:
                          title:
                            type: string
                            description: 事件标题
                          date:
                            type: string
                            description: 日期（YYYY-MM-DD）
                          time:
                            type: string
                            description: 时间（HH:MM）
                          duration_minutes:
                            type: integer
                            description: 持续时间（分钟）
                        required:
                          - title
                          - date
              tool-calling-send-email:
                summary: 发送邮件
                description: 让模型调用邮件发送工具
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: 帮我给团队发一封邮件，通知明天下午3点开产品评审会
                  tools:
                    - name: send_email
                      description: 发送电子邮件
                      input_schema:
                        type: object
                        properties:
                          to:
                            type: array
                            items:
                              type: string
                            description: 收件人列表
                          subject:
                            type: string
                            description: 邮件主题
                          body:
                            type: string
                            description: 邮件正文
                          cc:
                            type: array
                            items:
                              type: string
                            description: 抄送列表
                        required:
                          - to
                          - subject
                          - body
      responses:
        '200':
          $ref: '#/components/responses/ClaudeMessagesSuccess'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    ClaudeMessagesRequest:
      type: object
      required:
        - model
        - messages
        - max_tokens
      properties:
        model:
          type: string
          description: 模型名称，如 claude-sonnet-4-6
          example: claude-sonnet-4-6
        messages:
          type: array
          description: 对话消息列表
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                description: 消息发送者的角色
                enum:
                  - user
                  - assistant
              content:
                type: string
                description: 消息内容
        max_tokens:
          type: integer
          description: 最大生成token数（必填）
        system:
          oneOf:
            - type: string
              description: 系统提示词（文本形式）
            - type: array
              description: 系统提示词（结构化形式）
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
          description: 系统提示词
        temperature:
          type: number
          description: 采样温度 (0-1)
          minimum: 0
          maximum: 1
        top_p:
          type: number
          description: 核采样参数 (0-1)
          minimum: 0
          maximum: 1
        top_k:
          type: integer
          description: Top-K 采样参数
        stream:
          type: boolean
          description: 是否流式返回响应
          default: false
        stop_sequences:
          type: array
          description: 停止序列
          items:
            type: string
        tools:
          type: array
          description: 可用工具列表
          items:
            type: object
            properties:
              name:
                type: string
                description: 工具名称
              description:
                type: string
                description: 工具描述
              input_schema:
                type: object
                description: 工具输入参数的 JSON Schema
        tool_choice:
          type: object
          description: 工具选择策略
          properties:
            type:
              type: string
              description: 工具选择类型
              enum:
                - auto
                - any
                - tool
            name:
              type: string
              description: 指定工具名称（当 type 为 tool 时）
        metadata:
          type: object
          description: 请求元数据
          properties:
            user_id:
              type: string
              description: 用户标识符
    ClaudeMessagesResponse:
      type: object
      properties:
        id:
          type: string
          description: 唯一消息ID
          example: msg_abc123
        type:
          type: string
          description: 对象类型
          enum:
            - message
        role:
          type: string
          description: 角色
          enum:
            - assistant
        content:
          type: array
          description: 内容块列表
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - text
              text:
                type: string
                example: Hello! How can I help you today?
        model:
          type: string
          description: 使用的模型
        stop_reason:
          type: string
          description: 生成停止原因
          enum:
            - end_turn
            - max_tokens
            - stop_sequence
            - tool_use
          example: end_turn
        usage:
          type: object
          description: 用量统计
          properties:
            input_tokens:
              type: integer
              description: 输入token数
              example: 25
            output_tokens:
              type: integer
              description: 输出token数
              example: 150
    ErrorResponse400:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求参数无效
            type:
              type: string
              example: invalid_request_error
    ErrorResponse401:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: API密钥无效
            type:
              type: string
              example: authentication_error
    ErrorResponse403:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 访问被拒绝
            type:
              type: string
              example: permission_error
    ErrorResponse429:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求频率超限
            type:
              type: string
              example: rate_limit_error
    ErrorResponse500:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 服务器内部错误
            type:
              type: string
              example: server_error
  responses:
    ClaudeMessagesSuccess:
      description: Claude Messages API 响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ClaudeMessagesResponse'
    BadRequest:
      description: 请求错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse401'
    PaymentRequired:
      description: 余额不足
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Forbidden:
      description: 禁止访问
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse403'
    TooManyRequests:
      description: 请求过多
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse429'
    InternalServerError:
      description: 服务器内部错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse500'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        ## 所有接口均需要使用Bearer Token进行认证 ##

        使用时在请求头中添加：

        `Authorization: Bearer YOUR_API_KEY`

````