Bastio
Providers

Anthropic Integration

Complete guide to using Anthropic with Bastio for Claude 3.5, 3, and 2 models.

Anthropic Integration

Use Anthropic's Claude models through their official API while maintaining Bastio's security protection.

Overview

Bastio offers full support for Anthropic models, allowing you to:

  • Access latest models - Claude 3.5 Sonnet, Claude 3 Opus, and more
  • Seamless integration - Drop-in replacement for Anthropic SDKs
  • Full security coverage - All Bastio security features work with Claude
  • Unified API - Use OpenAI-compatible endpoints for Claude models

Supported Models

Bastio supports all current Anthropic models:

ModelContextInput/Output Price
Claude 3.5 Sonnet200K$3.00/$15.00 per 1M tokens
Claude 3.5 Haiku200K$1.00/$5.00 per 1M tokens
Claude 3 Opus200K$15.00/$75.00 per 1M tokens
Claude 3 Sonnet200K$3.00/$15.00 per 1M tokens
Claude 3 Haiku200K$0.25/$1.25 per 1M tokens
Claude 4.5 Sonnet200K$3.00/$15.00 per 1M tokens

Quick Start

Prerequisites

  1. Anthropic API Key
  2. Anthropic account with credits

Step 1: Get Credentials

  1. Go to Anthropic Console
  2. Create a new API key
  3. Save it securely

Configuration

Via Dashboard

  1. Go to Dashboard → Proxies → Create New Proxy
  2. Select Anthropic as provider
  3. Enter your Anthropic API key

Via API

# Create Anthropic proxy
curl -X POST https://api.bastio.ai/proxy \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Anthropic",
    "provider": "anthropic",
    "llm_mode": "byok",
    "model_behavior": "passthrough"
  }'

# Add API Key
curl -X POST https://api.bastio.ai/keys/provider \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "anthropic",
    "key_name": "Anthropic Production",
    "api_key": "sk-ant-..."
  }'

Making Requests

Bastio provides an OpenAI-compatible interface for Anthropic, so you can use standard OpenAI SDKs even for Claude models.

Python Example

from openai import OpenAI

client = OpenAI(
    base_url="https://api.bastio.ai/v1/guard/{PROXY_ID}/v1",
    api_key="your-bastio-api-key"
)

response = client.chat.completions.create(
    model="claude-3-5-sonnet-20241022",
    messages=[
        {"role": "user", "content": "Explain quantum computing"}
    ]
)

print(response.choices[0].message.content)

JavaScript Example

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.bastio.ai/v1/guard/{PROXY_ID}/v1',
  apiKey: process.env.BASTIO_API_KEY,
});

const response = await client.chat.completions.create({
  model: 'claude-3-5-sonnet-20241022',
  messages: [
    { role: 'user', content: 'Hello from Claude!' }
  ],
});

console.log(response.choices[0].message.content);

Streaming Example

stream = client.chat.completions.create(
    model="claude-3-opus-20240229",
    messages=[{"role": "user", "content": "Write a poem"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Features & Limitations

Supported Features

  • Chat Completions: Full support via OpenAI-compatible API
  • Streaming: Real-time token streaming
  • Function Calling: Support for tools and function calling
  • Vision: Multimodal support (Claude 3/3.5 models)
  • System Prompts: Supported via system role messages

Vision Example

response = client.chat.completions.create(
    model="claude-3-5-sonnet-20241022",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What's in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg"
                    }
                }
            ]
        }
    ]
)

Troubleshooting

Invalid API Key

Error: 401 Unauthorized or Invalid API Key Solution: Check that your Anthropic key is active and starts with sk-ant-.

Rate Limits

Error: 429 Too Many Requests Solution: Check your Anthropic tier limits. Claude models have different rate limits depending on your tier.

Model Not Found

Error: 404 Not Found Solution: Ensure the model ID is correct (e.g., claude-3-5-sonnet-20241022) and available to your account.

Additional Resources