Anthropic SDK

UberLLM exposes an Anthropic-compatible Messages API at /v1/messages. Point the official anthropic SDK at UberLLM by setting its base URL, and you can call any model in the catalog through the Anthropic wire format — not just Anthropic models. UberLLM translates between the Anthropic and OpenAI shapes in its own gateway, including streaming.

  • Base URL: https://api.uberllm.dev
  • Endpoint: POST /v1/messages
  • Auth: your ull_ key

The Anthropic SDK sends the key in the x-api-key header; UberLLM also accepts Authorization: Bearer ull_.... Either works.

Python

import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.uberllm.dev",
    api_key=os.environ["UBERLLM_API_KEY"],
)

msg = client.messages.create(
    model="deepseek/deepseek-v3.1",
    max_tokens=256,
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(msg.content[0].text)

Streaming

with client.messages.stream(
    model="deepseek/deepseek-v3.1",
    max_tokens=256,
    messages=[{"role": "user", "content": "Count to five."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

TypeScript / JavaScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.uberllm.dev",
  apiKey: process.env.UBERLLM_API_KEY,
});

const msg = await client.messages.create({
  model: "deepseek/deepseek-v3.1",
  max_tokens: 256,
  messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : "");

curl

curl -N https://api.uberllm.dev/v1/messages \
  -H "x-api-key: $UBERLLM_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v3.1",
    "max_tokens": 256,
    "stream": true,
    "messages": [{"role": "user", "content": "Say hello."}]
  }'

Notes

  • max_tokens is required by the Anthropic Messages API — include it.
  • System prompts use the top-level system field, as in the native Anthropic API; UberLLM maps it to the target model correctly.
  • Anthropic models are billed at their provider price like any other model; there is no inference markup. See Pricing.
  • If your framework only speaks OpenAI, use the OpenAI SDK drop-in instead — both surfaces reach the same models and billing.