Anthropic SDK
ai& exposes Anthropic-compatible endpoints alongside its OpenAI surface. Use the official anthropic SDKs by overriding the base URL.
pip install anthropicfrom anthropic import Anthropic
client = Anthropic( base_url="https://api.aiand.com", api_key="sk-your-aiand-api-key",)npm install @anthropic-ai/sdkimport Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.aiand.com", apiKey: "sk-your-aiand-api-key",});Messages
Section titled “Messages”response = client.messages.create( model="...", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}],)print(response.content[0].text)Streaming
Section titled “Streaming”with client.messages.stream( model="...", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}],) as stream: for text in stream.text_stream: print(text, end="")The Anthropic Files API works too — selected by the SDK’s anthropic-version header:
file = client.beta.files.upload(file=open("cat.png", "rb"))See OpenAI vs Anthropic shape for how the dual-emit works.