Guide

Use Claude with the OpenAI SDK

You don't need Anthropic's own SDK to call Claude. Nicrron serves Claude models through an OpenAI-compatible API, so the OpenAI SDK you already use calls them after two changes: the base URL and the key.

The same key also calls every other model on Nicrron, so trying Claude against what you use today is a one-word change.

1. Get a key

Make an API key in the dashboard and add credit. Keep the key in an environment variable, for example NICRRON_API_KEY.

2. Point the SDK at Nicrron

Set base_url (Python) or baseURL (TypeScript) to https://api.nicrron.ai/v1, and use the model id anthropic/claude-sonnet-5-5.

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.nicrron.ai/v1",
    api_key=os.environ["NICRRON_API_KEY"],
)

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Write a haiku about the sea."}],
)
print(reply.choices[0].message.content)
TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.nicrron.ai/v1",
  apiKey: process.env.NICRRON_API_KEY,
});

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5-5",
  messages: [{ role: "user", content: "Write a haiku about the sea." }],
});
console.log(reply.choices[0].message.content);

3. Pick a Claude model

List prices in US dollars from the live catalog; requests paid from credit add a 5% platform fee. More on the Anthropic models page.

4. Stream the answer

Streaming works the same as with OpenAI: pass stream=True and read the chunks.

Python
stream = client.chat.completions.create(
    model="anthropic/claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Explain DNS in three sentences."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

5. Add a fallback

Nicrron takes a models list as well as model. If Claude Sonnet 5.5 can't answer, the same request goes to the next model in the list, and reply.model says which one answered. The OpenAI SDK sends extra fields through extra_body.

Python
reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Hello!"}],
    # Tried in order if Claude Sonnet 5.5 can't answer: an outage or a rate limit.
    extra_body={"models": ["openai/gpt-6.2-sol"]},
)
print(reply.model)  # the model that actually answered

More in Fall back to another model.

Questions

Can I use Claude with the OpenAI SDK?
Yes. Point the OpenAI SDK at https://api.nicrron.ai/v1 with a Nicrron API key, and set the model to a Claude id such as "anthropic/claude-sonnet-5-5". The request and the answer have the OpenAI chat completions shape, so the rest of your code stays the same.
Which Claude models can I call this way?
14 right now: Claude Sonnet 5.5, Claude Sonnet 5, Claude Sonnet 4.6, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Opus 4.5, Claude Haiku 5.5, Claude Haiku 4.5, Claude Fable 5.2, Claude Fable 5.1, Claude Fable 5. The ids and prices are on nicrron.ai/models.
Do streaming and function calling work with Claude?
Streaming works with stream: true, as server-sent events of chat.completion.chunk. Tools use the OpenAI tools format; Nicrron passes them to models that support function calling.
How much does Claude cost through Nicrron?
The provider's list price per token, shown for each model on its page. Requests paid from Nicrron credit add a 5% platform fee. API keys spend paid credit: add credit in the dashboard, with no subscription.