AnyInt Docs
API Reference

Anthropic Compatible API

Use this family when your application already speaks Anthropic's Messages API or when you need message-block semantics that are different from OpenAI chat completions.

Use this family when your application already speaks Anthropic's Messages API or when you need message-block semantics that are different from OpenAI chat completions.

Published routes

RoutePurpose
POST https://gateway.api.anyint.ai/anthropic/v1/messagesCreate a Claude-style message response
POST https://gateway.api.anyint.ai/anthropic/v1/messages/count_tokensCount tokens for a message payload before sending it

Required headers

x-api-key: <ANYINT_API_KEY>
anthropic-version: 2023-06-01
content-type: application/json

When to use this family

  • You want Anthropic-style messages and content blocks
  • You want text-plus-image inputs inside the same message format
  • You need token estimation before sending expensive prompts

Messages route

Use /messages when you want Anthropic-style request bodies and response objects.

Core request fields

FieldTypeRequiredMeaningExample
modelstringYesClaude-compatible model ID available to your account. Fetch valid IDs from the Models API.claude-sonnet-4-6
max_tokensintegerYesMaximum number of tokens to generate.512
messagesarrayYesOrdered conversation turns using Anthropic message format.[{"role":"user","content":"Hello"}]
systemstring or arrayNoSystem instruction for the conversation. Use this instead of an OpenAI-style system role if your client follows Anthropic format.You are concise.
temperaturenumberNoSampling temperature. Lower values are more deterministic.0.7
top_pnumberNoNucleus sampling control.1
top_kintegerNoLimits sampling to the top K tokens when supported by the model.40
stop_sequencesarrayNoStrings that stop generation when encountered.["\nHuman:"]
streambooleanNoSet true for streaming when supported by the selected route and model.true
toolsarrayNoAnthropic-style tool definitions when supported by the model.[{"name":"lookup",...}]
tool_choiceobjectNoAnthropic-style control over which tool the model should use.{"type":"auto"}

Each messages[].content value can be either:

  • a plain string
  • an array of content blocks such as text and image

Message fields

FieldTypeRequiredMeaningExample
rolestringYesMessage author. Use user or assistant.user
contentstring or arrayYesPlain text or an array of Anthropic content blocks.Summarize this image.

Content block fields

FieldTypeRequiredMeaningExample
typestringYesBlock type. Common values are text and image.text
textstringFor text blocksText content.Describe this image.
source.typestringFor image blocksImage source type.base64
source.media_typestringFor image blocksImage MIME type.image/png
source.datastringFor base64 image blocksBase64-encoded image bytes without a data URL prefix.<BASE64_IMAGE_DATA>

Text-only example

curl https://gateway.api.anyint.ai/anthropic/v1/messages \
  -H "x-api-key: $ANYINT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [
      {"role": "user", "content": "Summarize why API gateways matter."}
    ]
  }'

Image input example

curl https://gateway.api.anyint.ai/anthropic/v1/messages \
  -H "x-api-key: $ANYINT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/png",
              "data": "<BASE64_IMAGE_DATA>"
            }
          },
          {
            "type": "text",
            "text": "Describe what is in this image."
          }
        ]
      }
    ]
  }'

Response shape

FieldMeaning
idMessage identifier returned by the compatible API path
typeObject type, usually message
roleAssistant role for generated responses
content[]Generated content blocks, usually text blocks
modelModel that handled the request
stop_reasonWhy generation stopped, such as end turn, max tokens, or stop sequence
usage.input_tokensInput tokens counted by the provider when available
usage.output_tokensOutput tokens counted by the provider when available

Token count route

Use /messages/count_tokens when you need token estimation before sending a real request.

Token count request fields

FieldTypeRequiredMeaning
modelstringYesModel ID to estimate against
messagesarrayYesSame message shape you plan to send to /messages
systemstring or arrayNoOptional system instruction included in token estimation
toolsarrayNoTool definitions included in token estimation when relevant
curl https://gateway.api.anyint.ai/anthropic/v1/messages/count_tokens \
  -H "x-api-key: $ANYINT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "Count the tokens for this message."}
    ]
  }'

Typical use cases:

  • budget checks before high-context requests
  • UI previews that warn about large prompts
  • batching or queueing systems that need admission control

Common mistakes

  • Omitting the required anthropic-version header
  • Sending Authorization: Bearer instead of x-api-key
  • Assuming content must always be a string even though image blocks are supported
  • Treating /messages/count_tokens as a generation route

On this page