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

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# Claude 消息

> 创建消息

使用与 Anthropic 兼容的 Messages API 创建 Claude 模型响应。此端点与 [Anthropic `/v1/messages` 规范](https://platform.claude.com/docs/en/api/messages/create)保持一致，并通过位于 `https://api.aisa.one/v1/messages` 的 AIsa 网关路由。

如果希望使用 Anthropic 原生请求格式调用 Claude 模型（`claude-opus-4-7`、`claude-sonnet-4-6`、`claude-haiku-4-5-20251001` 等），包括扩展思考、工具使用和提示词缓存，请使用此端点。如果您更倾向于 OpenAI 风格的聊天补全，也可以通过 [OpenAI Chat](https://aisa.one/docs/zh/api-reference/chat/post_chat-completions.md) 端点使用相同的 Claude 模型。

身份验证使用您的 AIsa API 密钥作为 Bearer token。有关支持的完整 Claude 变体列表和上下文窗口，请参阅[模型目录](https://aisa.one/docs/guides/models.md)；有关按词元计费的费率，请参阅[定价](https://aisa.one/docs/zh/guides/pricing.md#模型)。

## 请求规范

* **方法与路径:** POST /messages
* **请求 URL 模板:** `https://api.aisa.one/v1/messages`

[完整 OpenAPI 定义](https://aisa.one/docs/reference-contracts/zh/claude-messages.json)

有效请求声明（包括认证和引用的 schema）：

```json theme={null}
{
  "operationId": "createMessage",
  "method": "POST",
  "path": "/messages",
  "servers": [
    {
      "url": "https://api.aisa.one/v1"
    }
  ],
  "parameters": [],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "max_tokens": {
              "description": "停止前可生成的最大词元数。",
              "example": 1024,
              "type": "integer"
            },
            "messages": {
              "description": "对话轮次。",
              "example": [
                {
                  "content": "Hello, Claude",
                  "role": "user"
                }
              ],
              "items": {
                "properties": {
                  "content": {
                    "description": "字符串或内容块数组。",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "items": {
                          "type": "object"
                        },
                        "type": "array"
                      }
                    ]
                  },
                  "role": {
                    "enum": [
                      "user",
                      "assistant"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "role",
                  "content"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "metadata": {
              "properties": {
                "user_id": {
                  "description": "外部用户 ID（不含个人身份信息）。",
                  "type": "string"
                }
              },
              "type": "object"
            },
            "model": {
              "description": "Claude 模型标识符。示例：claude-opus-4-7、claude-sonnet-4-6、claude-haiku-4-5-20251001。",
              "example": "claude-sonnet-4-6",
              "type": "string"
            },
            "service_tier": {
              "default": "auto",
              "enum": [
                "auto",
                "standard_only"
              ],
              "type": "string"
            },
            "stop_sequences": {
              "description": "用于停止生成的自定义序列。",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "stream": {
              "default": false,
              "description": "启用 SSE 流式传输。",
              "type": "boolean"
            },
            "system": {
              "description": "系统提示词。字符串或文本块数组。",
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              ]
            },
            "temperature": {
              "default": 1.0,
              "description": "随机性。0 = 确定性，1 = 创造性。",
              "format": "float",
              "maximum": 1.0,
              "minimum": 0.0,
              "type": "number"
            },
            "thinking": {
              "description": "为复杂推理启用扩展思考。",
              "properties": {
                "budget_tokens": {
                  "example": 10000,
                  "type": "integer"
                },
                "display": {
                  "enum": [
                    "summarized",
                    "omitted"
                  ],
                  "type": "string"
                },
                "type": {
                  "enum": [
                    "enabled"
                  ],
                  "type": "string"
                }
              },
              "type": "object"
            },
            "tool_choice": {
              "description": "模型使用工具的方式。",
              "properties": {
                "disable_parallel_tool_use": {
                  "default": false,
                  "type": "boolean"
                },
                "name": {
                  "description": "当 type 为 tool 时必填。",
                  "type": "string"
                },
                "type": {
                  "enum": [
                    "auto",
                    "any",
                    "tool",
                    "none"
                  ],
                  "type": "string"
                }
              },
              "type": "object"
            },
            "tools": {
              "description": "模型可使用的工具。",
              "items": {
                "properties": {
                  "description": {
                    "type": "string"
                  },
                  "input_schema": {
                    "type": "object"
                  },
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "example": "custom",
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "input_schema"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "top_k": {
              "description": "每个词元仅从概率最高的 K 个选项中采样。",
              "type": "integer"
            },
            "top_p": {
              "description": "核采样。用于替代 temperature。",
              "format": "float",
              "type": "number"
            }
          },
          "required": [
            "model",
            "max_tokens",
            "messages"
          ],
          "type": "object"
        }
      }
    },
    "required": true
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "bearerFormat": "AISA API Key",
        "description": "您的 AIsa API 密钥，作为 Bearer token 提供。",
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```


## OpenAPI

````yaml reference-contracts/zh/claude-messages.json POST /messages
openapi: 3.0.3
info:
  description: 通过 AIsa 提供的 Anthropic 兼容 Messages API。使用 Claude 模型发送结构化消息并生成响应。
  title: Claude Messages API
  version: 1.0.0
servers:
  - url: https://api.aisa.one/v1
security:
  - BearerAuth: []
paths:
  /messages:
    post:
      summary: 创建消息
      description: 向 Claude 模型发送结构化对话并接收响应。兼容 Anthropic Messages API。
      operationId: createMessage
      requestBody:
        content:
          application/json:
            schema:
              properties:
                max_tokens:
                  description: 停止前可生成的最大词元数。
                  example: 1024
                  type: integer
                messages:
                  description: 对话轮次。
                  example:
                    - content: Hello, Claude
                      role: user
                  items:
                    properties:
                      content:
                        description: 字符串或内容块数组。
                        oneOf:
                          - type: string
                          - items:
                              type: object
                            type: array
                      role:
                        enum:
                          - user
                          - assistant
                        type: string
                    required:
                      - role
                      - content
                    type: object
                  type: array
                metadata:
                  properties:
                    user_id:
                      description: 外部用户 ID（不含个人身份信息）。
                      type: string
                  type: object
                model:
                  description: >-
                    Claude
                    模型标识符。示例：claude-opus-4-7、claude-sonnet-4-6、claude-haiku-4-5-20251001。
                  example: claude-sonnet-4-6
                  type: string
                service_tier:
                  default: auto
                  enum:
                    - auto
                    - standard_only
                  type: string
                stop_sequences:
                  description: 用于停止生成的自定义序列。
                  items:
                    type: string
                  type: array
                stream:
                  default: false
                  description: 启用 SSE 流式传输。
                  type: boolean
                system:
                  description: 系统提示词。字符串或文本块数组。
                  oneOf:
                    - type: string
                    - items:
                        type: object
                      type: array
                temperature:
                  default: 1
                  description: 随机性。0 = 确定性，1 = 创造性。
                  format: float
                  maximum: 1
                  minimum: 0
                  type: number
                thinking:
                  description: 为复杂推理启用扩展思考。
                  properties:
                    budget_tokens:
                      example: 10000
                      type: integer
                    display:
                      enum:
                        - summarized
                        - omitted
                      type: string
                    type:
                      enum:
                        - enabled
                      type: string
                  type: object
                tool_choice:
                  description: 模型使用工具的方式。
                  properties:
                    disable_parallel_tool_use:
                      default: false
                      type: boolean
                    name:
                      description: 当 type 为 tool 时必填。
                      type: string
                    type:
                      enum:
                        - auto
                        - any
                        - tool
                        - none
                      type: string
                  type: object
                tools:
                  description: 模型可使用的工具。
                  items:
                    properties:
                      description:
                        type: string
                      input_schema:
                        type: object
                      name:
                        type: string
                      type:
                        example: custom
                        type: string
                    required:
                      - name
                      - input_schema
                    type: object
                  type: array
                top_k:
                  description: 每个词元仅从概率最高的 K 个选项中采样。
                  type: integer
                top_p:
                  description: 核采样。用于替代 temperature。
                  format: float
                  type: number
              required:
                - model
                - max_tokens
                - messages
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  content:
                    description: 响应内容块（text、tool_use、thinking 等）。
                    items:
                      type: object
                    type: array
                  id:
                    example: msg_024e7cf42f5d47cfa6982b5ff8b55642
                    type: string
                  model:
                    example: claude-sonnet-4-6
                    type: string
                  role:
                    example: assistant
                    type: string
                  stop_reason:
                    enum:
                      - end_turn
                      - stop_sequence
                      - max_tokens
                      - tool_use
                    type: string
                  stop_sequence:
                    nullable: true
                    type: string
                  type:
                    example: message
                    type: string
                  usage:
                    properties:
                      cache_creation_input_tokens:
                        type: integer
                      cache_read_input_tokens:
                        type: integer
                      input_tokens:
                        type: integer
                      output_tokens:
                        type: integer
                    type: object
                type: object
          description: 成功响应
        '400':
          description: 请求参数无效
        '401':
          description: 缺少 API 密钥或 API 密钥无效
        '429':
          description: 超出速率限制
        '500':
          description: 内部服务器错误
      security:
        - BearerAuth: []
components:
  securitySchemes:
    BearerAuth:
      bearerFormat: AISA API Key
      description: 您的 AIsa API 密钥，作为 Bearer token 提供。
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.