Anthropic-Compatible

Anthropic Compatibility Guide

Use the Anthropic Messages API format with Ask Sage — works with Claude Code out of the box

Table of Contents
  1. What’s New?
  2. Messages
    1. Request Parameters
    2. Model Naming Formats
    3. Response
    4. Example: Basic Message
    5. Example: Multi-Turn Conversation with System Prompt
    6. Example: Function Calling
  3. Token Counting
    1. Request Parameters
    2. Response
    3. Example
  4. Claude Code Integration
    1. Method 1 — Settings File (Recommended)
    2. Method 2 — Environment Variables
  5. Available Models
  6. How It Works
  7. Supported Features

What’s New?


Messages

Create a Message

POST https://api.asksage.ai/server/anthropic/v1/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.

Authentication: Use a Bearer token in the 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

Tip: Tool use enables the model to call external functions to retrieve information or perform actions.
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 Input Tokens

POST https://api.asksage.ai/server/anthropic/v1/messages/count_tokens

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

Connect Claude Code to Ask Sage

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.

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"]
}
}
Note: 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"
VS Code Extension: The VS Code extension requires Method 2 (environment variables) — there is no built-in way to set them within the extension settings.

Available Models

Supported Claude 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
Intelligent Fallback: If the requested model is unavailable on your account, Ask Sage automatically falls back to the best available model in the same capability tier.

How It Works

Request Flow

Ask Sage's anthropic/v1/* endpoints follow the Anthropic Messages API specification, making integration seamless.

  1. Your application sends a request to https://api.asksage.ai/server/anthropic/v1/messages
  2. Ask Sage validates your authentication token
  3. The model name is resolved and routed to the appropriate backend (AWS Bedrock or Google Vertex AI)
  4. The response is returned in standard Anthropic Messages API format
Key Difference: Instead of using Anthropic's base URL (https://api.anthropic.com), use Ask Sage's base URL (https://api.asksage.ai/server/anthropic).
Full Compatibility: Use the same request structure, parameters, and response formats you're already familiar with from the Anthropic API.

Supported Features

Feature Coverage

Non-Streaming Responses: Full message responses returned in a single payload.
Tool Use / Function Calling: Define tools and let Claude call them during conversation.
System Prompts: Set system-level instructions with optional cache control.
Multi-Turn Conversations: Maintain context across multiple messages.
Token Counting: Count input tokens before sending requests.
Beta Features: Anthropic beta features supported via the anthropic-beta header.

Important Note: Base URLs may vary depending on your environment. For assistance, please contact us at support@asksage.ai.

Back to top

Copyright © 2026 Ask Sage Inc. All Rights Reserved. Ask Sage is a BigBear.ai company.