Skip to main content

Overview

Anannas provides full compatibility with the Anthropic Messages API format, allowing you to use Anannas with any tool or SDK designed for Anthropic’s API. This includes Claude Code, the official Anthropic SDK, and other tools in the Anthropic ecosystem. The /v1/messages endpoint converts Anthropic Messages API requests to Anannas’ internal format and works with all models that Anannas supports, not just Anthropic models. You can use any model (OpenAI, Google, Anthropic, etc.) through this endpoint by specifying the model in Anannas’ provider/model-name format.

Base URL

The Anannas Anthropic-compatible endpoint is available at:
https://api.anannas.ai/v1/messages
Alternatively, you can use:
https://api.anannas.ai/api/v1/messages

Authentication

All requests require a Bearer token in the Authorization header using your Anannas API key:
Authorization: Bearer <ANANNAS_API_KEY>
Get your API key from the Anannas dashboard.

Model IDs

The /v1/messages endpoint accepts any model that Anannas supports, not just Anthropic models. Specify models using Anannas’ standard provider/model-name format. The API will automatically route to the appropriate provider.

Example Models from Different Providers

OpenAI Models:
  • gpt-4.1-mini
  • gpt-5-mini
Google Models:
  • gemini-2.5-pro
  • gemini-2.5-flash
Other Providers:
  • grok-4-1-fast-non-reasoning-latest
  • mistralai/mistral-large
  • meta-llama/llama-3-70b
  • And many more…
For a complete list of available models, visit anannas.ai/models or query GET https://api.anannas.ai/v1/models.
The endpoint converts Anthropic Messages API format to Anannas’ internal format, allowing you to use any supported model through the Anthropic-compatible interface. Model routing and provider selection are handled automatically.

Using Claude Code

Claude Code is an agentic coding tool that lives in your terminal and helps you code faster through natural language commands. You can configure Claude Code to use Anannas instead of the default Anthropic API.

Step 1: Install Claude Code

npm install -g @anthropic-ai/claude-code
If you encounter permission issues during installation, try using sudo (macOS/Linux) or running the command prompt as an administrator (Windows).

Step 2: Configure Environment Variables

Set up environment variables to point Claude Code to Anannas: macOS/Linux:
export ANTHROPIC_BASE_URL=https://api.anannas.ai
export ANTHROPIC_AUTH_TOKEN=<ANANNAS_API_KEY>
export API_TIMEOUT_MS=600000
export ANTHROPIC_MODEL=grok-4-1-fast-non-reasoning-latest
export ANTHROPIC_SMALL_FAST_MODEL=gpt-5-mini
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
Windows (PowerShell):
$env:ANTHROPIC_BASE_URL="https://api.anannas.ai"
$env:ANTHROPIC_AUTH_TOKEN="<ANANNAS_API_KEY>"
$env:API_TIMEOUT_MS="600000"
$env:ANTHROPIC_MODEL="grok-4-1-fast-non-reasoning-latest"
$env:ANTHROPIC_SMALL_FAST_MODEL="gpt-5-mini"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
Windows (Command Prompt):
set ANTHROPIC_BASE_URL=https://api.anannas.ai
set ANTHROPIC_AUTH_TOKEN=<ANANNAS_API_KEY>
set API_TIMEOUT_MS=600000
set ANTHROPIC_MODEL=grok-4-1-fast-non-reasoning-latest
set ANTHROPIC_SMALL_FAST_MODEL=gpt-5-mini
set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
The API_TIMEOUT_MS parameter is configured to prevent excessively long outputs that could cause the Claude Code client to time out. Here, we set the timeout duration to 10 minutes (600000ms).

Step 3: Start Claude Code

Navigate to your project directory and run:
cd your-project
claude
If prompted with “Do you want to use this API key,” select “Yes.” After launching, grant Claude Code permission to access files in your folder. You can now use Claude Code with Anannas.

Model Configuration

Claude Code uses internal model environment variables that map to specific models. The default configuration maps:
  • ANTHROPIC_DEFAULT_OPUS_MODEL: Maps to Claude Code’s “opus” tier (most capable)
  • ANTHROPIC_DEFAULT_SONNET_MODEL: Maps to Claude Code’s “sonnet” tier (balanced)
  • ANTHROPIC_DEFAULT_HAIKU_MODEL: Maps to Claude Code’s “haiku” tier (fastest)
You can customize these mappings to use any Anannas-supported model. For example, you could use OpenAI models:
export ANTHROPIC_DEFAULT_OPUS_MODEL=gpt-4.1-mini
export ANTHROPIC_DEFAULT_SONNET_MODEL=grok-4-1-fast-non-reasoning-latest
export ANTHROPIC_DEFAULT_HAIKU_MODEL=gpt-5-mini
Or mix providers:
export ANTHROPIC_DEFAULT_OPUS_MODEL=anthropic/claude-opus-4
export ANTHROPIC_DEFAULT_SONNET_MODEL=grok-4-1-fast-non-reasoning-latest
export ANTHROPIC_DEFAULT_HAIKU_MODEL=gemini-2.5-flash
Alternatively, you can configure model mappings in Claude Code’s settings file (~/.claude/settings.json):
{
  "env": {
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5-mini",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "grok-4-1-fast-non-reasoning-latest",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "gpt-4.1-mini"
  }
}
It is generally not recommended to manually adjust the model mapping, as hardcoding the model mapping makes it inconvenient to automatically update to the latest model when Anannas adds new models. If you want to use the latest default mappings, simply delete the model mapping configuration in settings.json.

Using the Anthropic SDK

You can use the official Anthropic SDK with Anannas by configuring the base URL.

Step 1: Install the Anthropic SDK

Python:
pip install anthropic
Node.js:
npm install @anthropic-ai/sdk

Step 2: Configure the Client

Python:
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.anannas.ai/v1",
    api_key="<ANANNAS_API_KEY>"
)
Node.js:
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  baseURL: 'https://api.anannas.ai/v1',
  apiKey: '<ANANNAS_API_KEY>',
});

Step 3: Make API Calls

Python:
message = client.messages.create(
    model="grok-4-1-fast-non-reasoning-latest",
    max_tokens=1000,
    system="You are a helpful assistant.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Hi, how are you?"
                }
            ]
        }
    ]
)

print(message.content)
Node.js:
const message = await client.messages.create({
  model: 'grok-4-1-fast-non-reasoning-latest',
  max_tokens: 1000,
  system: 'You are a helpful assistant.',
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'Hi, how are you?',
        },
      ],
    },
  ],
});

console.log(message.content);

Direct HTTP Requests

You can also make direct HTTP requests to the endpoint:
import requests

response = requests.post(
    "https://api.anannas.ai/v1/messages",
    headers={
        "Authorization": "Bearer <ANANNAS_API_KEY>",
        "Content-Type": "application/json",
        "anthropic-version": "2023-06-01"
    },
    json={
        "model": "grok-4-1-fast-non-reasoning-latest",
        "max_tokens": 1000,
        "system": "You are a helpful assistant.",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "Explain quantum computing in simple terms"
                    }
                ]
            }
        ]
    }
)

data = response.json()
print(data["content"][0]["text"])

API Compatibility Details

HTTP Headers

FieldSupport Status
anthropic-betaIgnored
anthropic-versionIgnored
x-api-keyFully Supported (use Authorization: Bearer instead)
AuthorizationFully Supported

Request Fields

FieldSupport StatusNotes
modelFully SupportedUse any Anannas model format (e.g., grok-4-1-fast-non-reasoning-latest, anthropic/claude-4.5-sonnet, gemini-2.5-pro)
max_tokensFully SupportedRequired field
messagesFully SupportedRequired field, minimum 1 message
systemSupportedString or array of system blocks (cache_control in array blocks is not preserved)
temperatureFully SupportedRange [0.0 ~ 2.0]
top_pFully SupportedRange [0.0 ~ 1.0]
top_kIgnoredNot supported by all models. Not allowed when thinking is enabled
stop_sequencesFully SupportedArray of stop sequences
streamFully SupportedServer-Sent Events (SSE)
toolsFully SupportedTool definitions for function calling
tool_choiceFully Supportednone, auto, any, or specific tool. When thinking is enabled, only "auto" or "none" are allowed
thinkingSupportedbudget_tokens is converted to reasoning.max_tokens. Interleaved thinking is automatically enabled when tools are present and tool_choice is "auto"
metadataPartially Supporteduser_id is supported

Tool Fields

FieldSupport Status
nameFully Supported
descriptionFully Supported
input_schemaFully Supported
cache_controlSupportedPrompt caching support for tools

Tool Choice Values

ValueSupport StatusNotes
noneFully Supported
autoSupporteddisable_parallel_tool_use is ignored. Required for interleaved thinking when thinking is enabled
anySupporteddisable_parallel_tool_use is ignored. Not allowed when thinking is enabled
toolSupporteddisable_parallel_tool_use is ignored. Not allowed when thinking is enabled

Message Content Types

Content TypeSupport StatusNotes
textFully SupportedString or content block
imageSupportedBase64-encoded images
tool_useFully SupportedTool call from assistant
tool_resultFully SupportedTool result from user
thinkingSupportedReasoning/thinking blocks
documentNot Supported
search_resultNot Supported
redacted_thinkingSupportedRedacted/encrypted thinking blocks are supported and preserved
server_tool_useNot Supported
mcp_tool_useNot Supported

Response Format

Responses follow the Anthropic Messages API format:
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Response text here"
    }
  ],
  "model": "grok-4-1-fast-non-reasoning-latest",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 10,
    "output_tokens": 50
  }
}

Streaming

When stream: true is set, the API returns Server-Sent Events (SSE) with the following event types:
  • message_start: Initial message metadata
  • content_block_start: Start of a content block
  • content_block_delta: Incremental content updates
  • content_block_stop: End of a content block
  • message_delta: Message-level updates (stop_reason, usage)
  • message_stop: End of the message stream
  • ping: Keep-alive heartbeat events
  • error: Error events

Troubleshooting

Claude Code Configuration Not Working

If you manually modified the ~/.claude/settings.json configuration file but found the changes did not take effect:
  1. Close all Claude Code windows, open a new command-line window, and run claude again
  2. If the issue persists, try deleting the ~/.claude/settings.json file and then reconfigure the environment variables
  3. Confirm that the JSON format of the configuration file is correct - check variable names and ensure there are no missing or extra commas

Model Not Found Errors

If you receive a “model not found” error:
  1. Verify the model ID format is correct: provider/model-name (e.g., grok-4-1-fast-non-reasoning-latest, anthropic/claude-3.7-sonnet)
  2. Check available models at anannas.ai/models or via GET https://api.anannas.ai/v1/models
  3. Ensure your API key has access to the requested model
  4. Remember: you can use any model supported by Anannas, not just Anthropic models

Authentication Errors

If you receive authentication errors:
  1. Verify your API key is correct and active in the Anannas dashboard
  2. Ensure you’re using Authorization: Bearer <ANANNAS_API_KEY> header format
  3. Check that your API key has sufficient credits

Next Steps