import os
from anthropic import Anthropic
client = Anthropic(api_key=os.environ['HEIHUZI_API_KEY'], base_url='https://code.heihuzi.ai', timeout=120.0, max_retries=0)
import base64
from pathlib import Path
encoded = base64.b64encode(Path('reference.png').read_bytes()).decode('ascii')
result = client.messages.create(model='deepseek-flash', max_tokens=1024, messages=[{'role': 'user', 'content': [{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/png', 'data': encoded}}, {'type': 'text', 'text': 'What is the main object and its color? Answer briefly in English.'}]}])
answer = ''.join((block.text for block in result.content if block.type == 'text'))
print(answer)
assert result.stop_reason == 'end_turn'
assert 'blue' in answer.lower() and any((x in answer.lower() for x in ('cup', 'mug')))