import anthropic
client = anthropic.Anthropic(
base_url="https://api.sailresearch.com",
api_key="YOUR_KEY",
)
# URL source
response = client.messages.create(
model="moonshotai/Kimi-K2.6",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {"type": "url", "url": "https://example.com/cat.jpg"},
},
{"type": "text", "text": "What's in this image?"},
],
}
],
)
# Base64 source
response = client.messages.create(
model="moonshotai/Kimi-K2.6",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": b64, # raw base64 string, no data: prefix
},
},
{"type": "text", "text": "What's in this image?"},
],
}
],
)