Anthropic SDK
Point the official Anthropic SDK at Top Billing.
Point the official SDK at https://api.topbilling.in (no /v1 suffix; the SDK appends it).
Python
import os
import anthropic
client = anthropic.Anthropic(api_key=os.environ["TB_API_KEY"], base_url="https://api.topbilling.in")
msg = client.messages.create(
model="<model-id>",
max_tokens=256,
messages=[{"role": "user", "content": "Hello from Python"}],
)
print(msg.content[0].text)
# streaming
with client.messages.stream(model="<model-id>", max_tokens=256, messages=[{"role": "user", "content": "Stream"}]) as stream:
for text in stream.text_stream:
print(text, end="")
TypeScript
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ apiKey: process.env.TB_API_KEY, baseURL: 'https://api.topbilling.in' });
const msg = await client.messages.create({ model: '<model-id>', max_tokens: 256, messages: [{ role: 'user', content: 'Hello from Node' }] });
console.log(msg.content[0].type === 'text' ? msg.content[0].text : '');