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:
Connect Claude Code directly to Ask Sage with minimal configuration
Use the same Messages API format and patterns as Anthropic
Access Claude models via AWS Bedrock and Google Vertex AI backends
Anthropic-Compatible Endpoints
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
Bearer token authentication: Bearer YOUR_API_KEY
The Claude model to use. Supports multiple naming formats:
- Simple names:
sonnet,opus,haiku - Date-suffixed:
claude-sonnet-4-5-20250929,claude-opus-4-6-default - Vertex format:
claude-sonnet-4-5@20250929 - AskSage format:
google-claude-45-sonnet,aws-bedrock-claude-45-sonnet-gov
Array of message objects with roles: user or assistant
- role: Message role (
userorassistant) - content: Message content — string or array of content blocks
System prompt — can be a string or array of content blocks with optional cache control
Maximum number of tokens to generate in the response
Controls randomness (0.0–1.0). Lower values are more deterministic. Default: 1.0
Array of tool definitions for function calling
Controls tool usage: {"type": "auto"}, {"type": "any"}, or {"type": "tool", "name": "..."}
Response Details
Response Structure:
- id: Unique message ID
- type: "message"
- role: "assistant"
- model: Model used
- content: Array of content blocks:
- type: "text" or "tool_use"
- text: Response text (for text blocks)
- stop_reason: Reason for completion (end_turn, max_tokens, tool_use)
- usage: Token usage with input_tokens and output_tokens
Invalid request format or missing required parameters
Authentication failure — invalid or missing API key
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
Bearer token authentication: Bearer YOUR_API_KEY
The Claude model to count tokens for
Array of message objects (same format as Messages endpoint)
Response Details
input_tokens (integer) — Number of input tokens in the request
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-6-default | Google Vertex AI | Most capable — 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.
Request Flow
- 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
Full message responses returned in a single payload
Define tools and let Claude call them during conversation
Set system-level instructions with optional cache control
Maintain context across multiple messages
Count input tokens before sending requests
Anthropic beta features supported via the anthropic-beta header