| 1 |
from pathlib import Path |
| 2 |
|
| 3 |
from anthropic import Anthropic |
| 4 |
|
| 5 |
client = Anthropic() |
| 6 |
|
| 7 |
response = client.messages.create( |
| 8 |
max_tokens=1024, |
| 9 |
messages=[ |
| 10 |
{ |
| 11 |
"role": "user", |
| 12 |
"content": [ |
| 13 |
{ |
| 14 |
"type": "text", |
| 15 |
"text": "Hello!", |
| 16 |
}, |
| 17 |
{ |
| 18 |
"type": "image", |
| 19 |
"source": { |
| 20 |
"type": "base64", |
| 21 |
"media_type": "image/png", |
| 22 |
"data": Path(__file__).parent.joinpath("logo.png"), |
| 23 |
}, |
| 24 |
}, |
| 25 |
], |
| 26 |
}, |
| 27 |
], |
| 28 |
model="claude-sonnet-5", |
| 29 |
) |
| 30 |
print(response.model_dump_json(indent=2)) |