Claude API

This platform provides a chat endpoint compatible with the Anthropic Claude Messages API.

This document is intended for client-side integrators and focuses on the public request path, authentication method, request parameters, and example payloads. Field names and JSON structure are kept as close as possible to the native Claude Messages API.

Overview:

  • Endpoint: POST /v1/messages
  • Capability type: chat / text generation
  • Response modes:
    • When stream = false or omitted: standard JSON response
    • When stream = true: text/event-stream SSE response
  • Protocol style: the request body follows the native Claude Messages API structure and does not wrap content in an extra input field

1. API Overview

  • HTTP method: POST
  • Request path: /v1/messages
  • Content-Type: application/json
  • Response type:
    • Non-streaming: application/json
    • Streaming: text/event-stream

2. Authentication and Headers

Example headers:

Authorization: Bearer YOUR_REACH_API_KEY
anthropic-version: 2023-06-01
Content-Type: application/json

At least one of Authorization or x-api-key must be provided.

Header details:

HeaderRequiredDescription
AuthorizationNoPlatform API key in the format Bearer sk-xxxxxx
x-api-keyNoYou can also pass the platform API key directly in this header
anthropic-versionRecommendedFor Claude Messages API client compatibility, 2023-06-01 is recommended
Content-TypeYesMust be application/json

3. Request Body

The request body follows the native Claude Messages API object structure:

{
  "model": "YOUR_MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Please introduce yourself in one sentence."
    }
  ],
  "max_tokens": 1024,
  "temperature": 0.2,
  "stream": false
}

3.1 Top-Level Parameters

FieldTypeRequiredDescription
modelstringYesModel ID
messagesarray<object>YesChat message list
systemstring or array<object>NoSystem prompt
max_tokensintegerYesMaximum number of output tokens, minimum value 1
temperaturenumberNoSampling temperature
top_pnumberNoNucleus sampling parameter
top_kintegerNoTop-k sampling parameter
streambooleanNoWhether to return SSE streaming output
stop_sequencesarray<string>NoAdditional stop sequences
toolsarray<object>NoTool definitions
tool_choiceobjectNoTool calling strategy
thinkingobjectNoReasoning budget or thinking-mode configuration
metadataobjectNoInvocation metadata

3.2 messages Parameter

Each message uses the following structure:

FieldTypeRequiredDescription
rolestringYesRole. Common values: user, assistant
contentstring or array<object>YesMessage content. Can be plain text or an array of content blocks

Text example:

{
  "role": "user",
  "content": "Write a short product introduction within 50 words."
}

Content block example:

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Please describe this image."
    }
  ]
}

Common content block types:

typeTypical fieldsDescription
texttextText content
imagesourceImage input
tool_useid, name, inputTool call initiated by the model
tool_resulttool_use_id, contentTool execution result returned to the model

4. Request Examples

4.1 Standard Non-Streaming Request

curl -X POST "https://direct.reachapi.ai/v1/messages" \
  -H "Authorization: Bearer YOUR_REACH_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      {
        "role": "user",
        "content": "Introduce ReachAPI in one sentence."
      }
    ],
    "max_tokens": 512,
    "temperature": 0.2
  }'

4.2 Streaming Request

curl -X POST "https://direct.reachapi.ai/v1/messages" \
  -H "Authorization: Bearer YOUR_REACH_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      {
        "role": "user",
        "content": "Summarize today'\''s priorities in three lines."
      }
    ],
    "max_tokens": 512,
    "stream": true
  }'

4.3 Request with Tool Definitions

curl -X POST "https://direct.reachapi.ai/v1/messages" \
  -H "Authorization: Bearer YOUR_REACH_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      {
        "role": "user",
        "content": "Help me check the weather in Shanghai."
      }
    ],
    "max_tokens": 512,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get weather information for a city",
        "input_schema": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": ["city"]
        }
      }
    ],
    "tool_choice": {
      "type": "auto"
    }
  }'

5. Non-Streaming Response

On success, the API returns a standard message object:

{
  "id": "msg_01ABCDEF",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "ReachAPI is a unified AI gateway platform."
    }
  ],
  "model": "YOUR_MODEL_ID",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 32,
    "output_tokens": 18,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}

6. Streaming Response

When stream = true, the endpoint returns text/event-stream. Typical events look like this:

event: message_start
data: {"type":"message_start","message":{"id":"msg_1","type":"message","role":"assistant","content":[],"model":"YOUR_MODEL_ID","stop_reason":null,"usage":{"input_tokens":7,"output_tokens":0}}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":13}}

event: message_stop
data: {"type":"message_stop"}

7. Error Response

When a request fails, the API returns a JSON error object. Example:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Field `model` is required"
  }
}

Common scenarios:

  • Missing or invalid API key
  • Request body is not valid JSON
  • Missing model
  • Missing messages

8. Compatibility Notes

  • This document lists commonly used fields and example payloads. Actual field names and structures follow the Claude Messages API.
  • If you use advanced features such as tool calling or thinking budgets, confirm that the target model actually supports them.
  • If your client is built on top of the Anthropic or Claude SDK, passing anthropic-version is recommended.

9. Supported Models and Reference Pricing

The following prices are summarized from the unified pricing document and apply to the Claude text models currently listed. Pricing was checked on 2026-04-17. For detailed pricing rules, refer to claude.md.

ModelInputCache write 5mCache readOutput
claude-haiku-4-5$1 / 1M tokens$1.25 / 1M tokens$0.10 / 1M tokens$5 / 1M tokens
claude-sonnet-4-5$3 / 1M tokens$3.75 / 1M tokens$0.30 / 1M tokens$15 / 1M tokens
claude-sonnet-4-6$3 / 1M tokens$3.75 / 1M tokens$0.30 / 1M tokens$15 / 1M tokens
claude-opus-4-5-20251101$5 / 1M tokens$6.25 / 1M tokens$0.50 / 1M tokens$25 / 1M tokens
claude-opus-4-6$5 / 1M tokens$6.25 / 1M tokens$0.50 / 1M tokens$25 / 1M tokens

Notes:

  • Cache write 5m refers to the prompt cache write price for the 5-minute tier
  • claude-opus-4-5-20251101 is a snapshot model ID and can be used for version-pinned requests
  • For longer cache durations or extended context pricing, refer to the detailed pricing document

10. References

On this page