Chat Messages (Anthropic)

Anthropic-compatible: POST /v1/messages. Suitable for Anthropic SDK or native protocol integration. Messages API

  • Path: https://www.tokenpad.ai/v1/messages
  • Auth: x-api-key: sk-your_token_here
  • Required header: anthropic-version: 2023-06-01
  • max_tokens: required

For multimodal input, content is an array. Images use type: image with base64 only (source.type = base64). URL sources are not supported.


1. Text only

curl -X POST https://www.tokenpad.ai/v1/messages \
  -H "x-api-key: sk-your_token_here" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, introduce yourself in one sentence."}
    ]
  }'

2. Multimodal: image + text (Base64)

data must be raw base64 (no data:image/...;base64, prefix).

curl -X POST https://www.tokenpad.ai/v1/messages \
  -H "x-api-key: sk-your_token_here" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/jpeg",
              "data": "<raw-base64>"
            }
          },
          { "type": "text", "text": "What is in this image? Briefly describe it." }
        ]
      }
    ]
  }'

media_type: image/jpeg, image/png, image/gif, image/webp.


3. Multimodal: compare multiple images

Append more base64 image parts, then a text part:

curl -X POST https://www.tokenpad.ai/v1/messages \
  -H "x-api-key: sk-your_token_here" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/png",
              "data": "<raw-base64-a>"
            }
          },
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/png",
              "data": "<raw-base64-b>"
            }
          },
          { "type": "text", "text": "Compare the differences between these two images." }
        ]
      }
    ]
  }'

4. Common parameters

ParamTypeRequiredDescription
modelstringYesClaude model ID
messagesarrayYescontent: string, or [text / image(base64)]
max_tokensintegerYesMax output tokens
streambooleanNoDefault false
temperaturenumberNo0~1
systemstringNoSystem prompt (top-level, not inside messages)

SDK: official anthropic with base_url="https://www.tokenpad.ai" (appends /v1) and this platform Token as api_key.

For OpenAI-compatible chat (/v1/chat/completions), see menu Chat.

5. Common Error Codes & Troubleshooting

HTTP codes, error body format, and troubleshooting are maintained in one dedicated page (not duplicated under each example).

👉 Gateway Error Codes & Troubleshooting

Quick reference:

CodeMeaning
400Invalid parameters / content moderation or copyright block
402Insufficient account balance (not 429)
429RPS/RPM limits or in-flight task cap (low balance)
403Token / IP / model permission (balance → 402; content filter → 400)
200 + status: failedAsync video/long-task business failure on poll

HTTP status matches call log status_code for traceability by log_id.

Maintenance: update the error-codes article only; this appendix links to it.

Raw Markdown (.md) · llms.txt