Skip to contentSkip to content

Migrate from the Anthropic SDK

AI Credits provides a compatible /v1/messages endpoint. Point the SDK base URL at the data API and read both the key and model from the environment.

python
import os
from anthropic import Anthropic

client = Anthropic(api_key=os.environ["API_KEY"], base_url=os.environ["API_BASE_URL"])
message = client.messages.create(
    model=os.environ["MODEL"],
    max_tokens=128,
    messages=[{"role": "user", "content": "Reply briefly."}],
)

Exact SDK options depend on its installed version. Available models and entitlements are determined by /v1/models.