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
| Route | Purpose |
|---|---|
POST https://gateway.api.anyint.ai/anthropic/v1/messages | Create a Claude-style message response |
POST https://gateway.api.anyint.ai/anthropic/v1/messages/count_tokens | Count tokens for a message payload before sending it |
Required headers
x-api-key: <ANYINT_API_KEY>
anthropic-version: 2023-06-01
content-type: application/jsonWhen to use this family
- You want Anthropic-style
messagesandcontentblocks - 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
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
model | string | Yes | Claude-compatible model ID available to your account. Fetch valid IDs from the Models API. | claude-sonnet-4-6 |
max_tokens | integer | Yes | Maximum number of tokens to generate. | 512 |
messages | array | Yes | Ordered conversation turns using Anthropic message format. | [{"role":"user","content":"Hello"}] |
system | string or array | No | System instruction for the conversation. Use this instead of an OpenAI-style system role if your client follows Anthropic format. | You are concise. |
temperature | number | No | Sampling temperature. Lower values are more deterministic. | 0.7 |
top_p | number | No | Nucleus sampling control. | 1 |
top_k | integer | No | Limits sampling to the top K tokens when supported by the model. | 40 |
stop_sequences | array | No | Strings that stop generation when encountered. | ["\nHuman:"] |
stream | boolean | No | Set true for streaming when supported by the selected route and model. | true |
tools | array | No | Anthropic-style tool definitions when supported by the model. | [{"name":"lookup",...}] |
tool_choice | object | No | Anthropic-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
textandimage
Message fields
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
role | string | Yes | Message author. Use user or assistant. | user |
content | string or array | Yes | Plain text or an array of Anthropic content blocks. | Summarize this image. |
Content block fields
| Field | Type | Required | Meaning | Example |
|---|---|---|---|---|
type | string | Yes | Block type. Common values are text and image. | text |
text | string | For text blocks | Text content. | Describe this image. |
source.type | string | For image blocks | Image source type. | base64 |
source.media_type | string | For image blocks | Image MIME type. | image/png |
source.data | string | For base64 image blocks | Base64-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
| Field | Meaning |
|---|---|
id | Message identifier returned by the compatible API path |
type | Object type, usually message |
role | Assistant role for generated responses |
content[] | Generated content blocks, usually text blocks |
model | Model that handled the request |
stop_reason | Why generation stopped, such as end turn, max tokens, or stop sequence |
usage.input_tokens | Input tokens counted by the provider when available |
usage.output_tokens | Output 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
| Field | Type | Required | Meaning |
|---|---|---|---|
model | string | Yes | Model ID to estimate against |
messages | array | Yes | Same message shape you plan to send to /messages |
system | string or array | No | Optional system instruction included in token estimation |
tools | array | No | Tool 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-versionheader - Sending
Authorization: Bearerinstead ofx-api-key - Assuming
contentmust always be a string even though image blocks are supported - Treating
/messages/count_tokensas a generation route
Related pages
OpenAI Extended Endpoints
Map of OpenAI-compatible pass-through endpoints beyond chat, including embeddings, images, audio, files, batches, assistants, threads, and videos.
Gemini Compatible API
AnyInt exposes Gemini-compatible routes under the /gemini/v1beta prefix. Treat these as provider-native routes and validate them in your environment before production use.