Claude API — Anthropic Developer Platform

Anthropic's Claude API centers on the Messages API, supporting text and image understanding/generation, tool calls (functions/skills), computer use, system prompts, streaming outputs, token counting, and prompt caching. Suitable for assistants, RAG, automation workflows, and enterprise integrations.

基础 URL
https://api.anthropic.com
认证
Bearer / Authorization: Bearer $ANTHROPIC_API_KEY
官方 SDK
JavaScript/TypeScript, Python
🔑 API Key 获取
前置要求:Requires an Anthropic account and sign-in; higher throughput or enterprise features may require organization setup and billing configuration.
入口:https://console.anthropic.com/
说明:Sign in to the Anthropic Console, open the API Keys page, and create a key. The key is shown only once—store it securely. Workspace and Organization tiers affect rate limits and service levels.

支持模型

API 接口列表

GET /v1/models Docs

List available Claude models (latest and stable), returning model names and capabilities.

认证Yes
频率限制60/min
计费模式按 token 计费(输入与输出分别计费)
{
  "url": "https://api.anthropic.com/v1/models"
}
GET /v1/models/{model_id} Docs

Retrieve detailed information for a specific model (e.g., availability and version).

认证Yes
频率限制60/min
计费模式免费查询;实际计费取决于后续调用的具体模型与端点
{
  "url": "https://api.anthropic.com/v1/models/claude-sonnet-4-5"
}
POST /v1/messages Docs

Create a chat message to generate the next turn, supporting text and images, multi-turn context, tool calls, and streaming outputs.

认证Yes
频率限制60/min
计费模式按 token 计费(输入与输出分别计费;缓存写入/命中有不同价格)
{
  "url": "https://api.anthropic.com/v1/messages",
  "body": {
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "你好,Claude"
          }
        ]
      }
    ]
  }
}
POST /v1/messages/batches Docs

Create a message batch job to generate responses asynchronously in bulk; suitable for high-throughput workloads.

认证Yes
频率限制60/min
计费模式按 token 计费(批处理仅改变提交/执行方式,不改变计费模式)
{
  "url": "https://api.anthropic.com/v1/messages/batches",
  "body": {
    "requests": [
      {
        "model": "claude-sonnet-4-5",
        "max_tokens": 512,
        "messages": [
          {
            "role": "user",
            "content": [
              {
                "type": "text",
                "text": "批处理任务示例"
              }
            ]
          }
        ]
      }
    ]
  }
}
POST /v1/messages/count_tokens Docs

Estimate token counts for prompts/messages to plan cost and quota usage.

认证Yes
频率限制60/min
计费模式计数请求免费,但受速率限制
{
  "url": "https://api.anthropic.com/v1/messages/count_tokens",
  "body": {
    "model": "claude-sonnet-4-5",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "统计一下这条消息的 tokens"
          }
        ]
      }
    ]
  }
}