# pip install anthropic
import os

import anthropic

# The Anthropic SDK takes the address WITHOUT /v1.
client = anthropic.Anthropic(base_url="https://api.klinch.cloud", api_key=os.environ["KLINCH_API_KEY"])

with client.messages.stream(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a haiku about code"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
print()
