Skip to main content
Uno LLM Gateway supports Anthropic’s Messages API for text generation, images, tool calling, and reasoning. You can use any Anthropic SDK by simply pointing it to Uno’s gateway endpoint. This allows you to leverage Uno’s features like virtual keys, provider management, and observability while using your existing Anthropic code.

Overview

The Uno LLM Gateway provides an endpoint at /api/gateway/anthropic/v1/messages that implements Anthropic’s Messages API specification. This means you can use any Anthropic SDK (Python, JavaScript, Go, etc.) without modifying your code - just change the base URL.

Usage Examples

main.py
from anthropic import Anthropic

# Point the client to Uno's gateway endpoint
client = Anthropic(
    base_url="http://localhost:6060/api/gateway/anthropic/v1",
    api_key="sk-amg-your-virtual-key-here",  # or your Anthropic API key
)

# Use the Messages API
message = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, how are you?"}
    ],
)

print(message.content[0].text)

Streaming Support

The gateway supports streaming responses via Server-Sent Events (SSE). Use your SDK’s streaming methods as you normally would:
streaming.py
from anthropic import Anthropic

client = Anthropic(
    base_url="http://localhost:6060/api/gateway/anthropic/v1",
    api_key="sk-amg-your-virtual-key-here",
)

with client.messages.stream(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Tell me a story."}
    ],
) as stream:
    for event in stream:
        if event.type == "content_block_delta":
            print(event.delta.text, end="", flush=True)

Supported Features

The gateway currently supports the Messages API with:
  • Text generation - Standard text completions
  • Images - Image input (vision capabilities)
  • Tool calling - Function calling capabilities
  • Reasoning - Advanced reasoning models

Authentication

The gateway accepts authentication via the x-api-key header:
  • Virtual Key: Use a virtual key (starts with sk-amg-) for managed access control
  • Direct API Key: Use your Anthropic API key directly