Anthropic Claude Native API Guide

Anthropic Messages–compatible path. Send Claude request payloads (such as claude-3-5-sonnet-20241022). Messages API

1. Message Generation Dialogue (Messages API)

  • Request Path: /v1/messages
  • Request Method: POST

Core Request Parameter Description

  • model (string, Required) Specifies the Claude model name, such as claude-3-5-sonnet-20241022.
  • messages (array, Required) Historical conversation array, structured like [{"role": "user", "content": "Hello"}].
  • max_tokens (integer, Required) The maximum limit of tokens generated. Note: The official Anthropic protocol requires this parameter to be filled in.
  • system (string, Optional) System prompt, used to set the role and behavior of the model.
  • stream (boolean, Optional) Whether to return in SSE (Server-Sent Events) streaming format. Optional values are true or false.
  • temperature (number, Optional) Sampling temperature, ranging between 0.0 and 1.0.

Call Example (Curl)

curl -X POST https://www.tokenpad.ai/v1/messages \
  -H "x-api-key: sk-your_token" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, please describe your core features in one sentence."}
    ]
  }'

2. API Authentication Methods

When calling the native Claude API, the gateway supports the following two authentication headers:

  1. Unified Bearer Token Authentication (Recommended):
    Authorization: Bearer sk-your_token
    
  2. Official Anthropic API Key:
    x-api-key: sk-your_token
    

Raw Markdown (.md) · llms.txt