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. Anthropic-Compatible Endpoints
    1. Messages
    2. Token Counting
  3. Claude Code Integration
  4. Available Models
  5. How It Works
  6. Supported Features

What’s New?

Ask Sage now supports the Anthropic Messages API format, making it easy to:

Claude Code Integration

Connect Claude Code directly to Ask Sage with minimal configuration

Standard Format

Use the same Messages API format and patterns as Anthropic

Model Flexibility

Access Claude models via AWS Bedrock and Google Vertex AI backends


Anthropic-Compatible Endpoints

Messages

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 Bearer token in the Authorization header, or pass your token via x-access-tokens or x-api-key

Request Parameters

Authorization string (header) Required

Bearer token authentication: Bearer YOUR_API_KEY

model string Required

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
messages array Required

Array of message objects with roles: user or assistant

  • role: Message role (user or assistant)
  • content: Message content — string or array of content blocks
system string or array Optional

System prompt — can be a string or array of content blocks with optional cache control

max_tokens integer Required

Maximum number of tokens to generate in the response

temperature number Optional

Controls randomness (0.0–1.0). Lower values are more deterministic. Default: 1.0

tools array Optional

Array of tool definitions for function calling

tool_choice object Optional

Controls tool usage: {"type": "auto"}, {"type": "any"}, or {"type": "tool", "name": "..."}

Response Details
200 Success

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
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

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

Authorization string (header) Required

Bearer token authentication: 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 Details
200 Success

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:

~/.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:

Terminal
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) as there is no built-in way to set them within the extension settings.

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
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

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

Request Flow

  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

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.