Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.nolma.ai/llms.txt

Use this file to discover all available pages before exploring further.

Anthropic via Nolma

Setup

import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    base_url="https://gateway.nolma.ai/anthropic",
    default_headers={
        "NM-Key": "nm_live_abc123",
        "NM-Agent": "my-agent",
        # Optional:
        "NM-User": "user_123",
        "NM-Env": "production",
    }
)

Supported models

ModelTierCost (input / output per 1M tokens)
claude-sonnet-4-6Premium3.00/3.00 / 15.00
claude-haiku-4-5-20251001Economy0.08/0.08 / 0.40

Streaming

Streaming works exactly as normal:
with client.messages.stream(
    model="claude-haiku-4-5-20251001",
    max_tokens=500,
    messages=[{"role": "user", "content": "Tell me a story"}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Node.js

import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
  baseURL: 'https://gateway.nolma.ai/anthropic',
  defaultHeaders: {
    'NM-Key': 'nm_live_abc123',
    'NM-Agent': 'my-agent',
  }
})

Required headers

The anthropic-version header is forwarded automatically. You do not need to add it manually.