Anthropic Compatibility Guide
Use the Anthropic Messages API format with Ask Sage — works with Claude Code out of the box
Table of Contents
What’s New?
Ask Sage now supports the Anthropic Messages API format, making it easy to:
Messages
The main endpoint for creating messages using the standard Anthropic format. Requests are routed to AWS Bedrock or Google Vertex AI based on the resolved model.
Authorization header, or pass your token via x-access-tokens or x-api-key. Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string (header) | Required | Bearer token: Bearer YOUR_API_KEY |
model | string | Required | Claude model — see naming formats below |
messages | array | Required | Array of message objects with role (user/assistant) and content |
system | string or array | Optional | System prompt — string or array of content blocks with optional cache control |
max_tokens | integer | Required | Maximum number of tokens to generate |
temperature | number | Optional | Controls randomness (0.0–1.0). Default: 1.0 |
tools | array | Optional | Array of tool definitions for function calling |
tool_choice | object | Optional | {"type": "auto"}, {"type": "any"}, or {"type": "tool", "name": "..."} |
Model Naming Formats
The model field accepts multiple naming formats:
- Simple names:
sonnet,opus,haiku - Date-suffixed:
claude-sonnet-4-5-20250929,claude-opus-4-7-default,claude-opus-4-6-default - Vertex format:
claude-sonnet-4-5@20250929,claude-opus-4-7@default - AskSage format:
google-claude-47-opus,google-claude-45-sonnet,aws-bedrock-claude-45-sonnet-gov
Response
| Status | Description |
|---|---|
200 Success | Returns id, type, role, model, content (array of text/tool_use blocks), stop_reason (end_turn/max_tokens/tool_use), and usage (input_tokens, output_tokens) |
400 Error | Invalid request format or missing required parameters |
401 Error | Authentication failure — invalid or missing API key |
429 Error | Rate limit exceeded — retry after a moment |
Example: Basic Message
curl -X POST 'https://api.asksage.ai/server/anthropic/v1/messages' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "What is Ask Sage?"}
]
}'Example: Multi-Turn Conversation with System Prompt
curl -X POST 'https://api.asksage.ai/server/anthropic/v1/messages' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"system": "You are a helpful cybersecurity assistant.",
"messages": [
{"role": "user", "content": "What is zero trust architecture?"},
{"role": "assistant", "content": "Zero trust is a security framework that requires all users to be authenticated and authorized before accessing resources."},
{"role": "user", "content": "How does it apply to cloud environments?"}
]
}'Example: Function Calling
curl -X POST 'https://api.asksage.ai/server/anthropic/v1/messages' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "What'\''s the weather like in San Francisco?"}
],
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a location",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
]
}'Token Counting
Count the number of input tokens for a message payload before sending the full request. Useful for context-window management.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string (header) | Required | Bearer token: Bearer YOUR_API_KEY |
model | string | Required | The Claude model to count tokens for |
messages | array | Required | Array of message objects (same format as Messages endpoint) |
Response
| Field | Type | Description |
|---|---|---|
input_tokens | integer | Number of input tokens in the request |
Example
curl -X POST 'https://api.asksage.ai/server/anthropic/v1/messages/count_tokens' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'Claude Code Integration
Ask Sage's Anthropic endpoint is fully compatible with Claude Code. Connect your Claude Code CLI or VS Code extension to Ask Sage with minimal configuration.
Method 1 — Settings File (Recommended)
Create or edit ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.asksage.ai/server/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-asksage-token-here",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": 4096,
"MAX_THINKING_TOKENS": 1024
},
"permissions": {
"allow": ["*"],
"deny": ["Delete"]
}
}
CLAUDE_CODE_MAX_OUTPUT_TOKENS must be greater than MAX_THINKING_TOKENS. Anthropic recommends setting these values when using AWS Bedrock Claude 4.5 Sonnet (default) due to burndown throttling. Method 2 — Environment Variables
Export variables in your terminal before launching Claude Code:
export ANTHROPIC_BASE_URL="https://api.asksage.ai/server/anthropic"
export ANTHROPIC_API_KEY="your-asksage-token-here"
Available Models
| Model | Provider | Capability |
|---|---|---|
claude-sonnet-4-5-20250929 | AWS Bedrock (Gov) | Default — balanced speed and quality |
claude-opus-4-7-default | Google Vertex AI | Most capable — coding, agents, enterprise workflows |
claude-opus-4-6-default | Google Vertex AI | Previous generation Opus — complex reasoning |
claude-opus-4-5-20251101 | Google Vertex AI | Previous generation Opus |
claude-sonnet-4-6-default | Google Vertex AI | Latest Sonnet via Vertex |
claude-haiku-4-5-20251001 | Google Vertex AI | Fastest — lightweight tasks |
How It Works
Ask Sage's anthropic/v1/* endpoints follow the Anthropic Messages API specification, making integration seamless.
- Your application sends a request to
https://api.asksage.ai/server/anthropic/v1/messages - Ask Sage validates your authentication token
- The model name is resolved and routed to the appropriate backend (AWS Bedrock or Google Vertex AI)
- The response is returned in standard Anthropic Messages API format
https://api.anthropic.com), use Ask Sage's base URL (https://api.asksage.ai/server/anthropic). Supported Features
anthropic-beta header.