Skip to main content

Vision

import anthropic

client = anthropic.Anthropic(api_key="your-api-key", base_url="https://aisupermarket.work")

# Use an image URL
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {"type": "url", "url": "https://example.com/image.jpg"},
},
{"type": "text", "text": "Please describe this image"},
],
}
],
)
print(response.content[0].text)

Base64 Images

import anthropic
import base64

client = anthropic.Anthropic(api_key="your-api-key", base_url="https://aisupermarket.work")

with open("image.jpg", "rb") as f:
image_data = base64.b64encode(f.read()).decode("utf-8")

response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": image_data
},
},
{"type": "text", "text": "What is in this image?"},
],
}
],
)
print(response.content[0].text)

Compare Multiple Images

import anthropic

client = anthropic.Anthropic(api_key="your-api-key", base_url="https://aisupermarket.work")

response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{"type": "image", "source": {"type": "url", "url": "https://example.com/img1.jpg"}},
{"type": "image", "source": {"type": "url", "url": "https://example.com/img2.jpg"}},
{"type": "text", "text": "Compare the differences between these two images"},
],
}
],
)
print(response.content[0].text)

Supported formats: JPEG, PNG, GIF, WEBP. Each image can be up to 5 MB.