-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Hi all!
I'm trying to use Claude Sonnet to add descriptions to the images on PDFs with the following code:
api_key = "sk-ant-api03-YOUR_ACTUAL_KEY_HERE"
model = "claude-sonnet-4-5-20250929"
picture_desc_api_option = PictureDescriptionApiOptions(
url="https://api.anthropic.com/v1/messages",
prompt="Describe this image in sentences in a single paragraph.",
params=dict(
model=model,
max_tokens=1024,
messages=[], # Docling might need this structure
),
headers={
"x-api-key": api_key,
"anthropic-version": "2023-06-01",
"Content-Type": "application/json",
},
timeout=60,
)
When I run, it gives this error:
HTTPError: 400 Client Error: Bad Request for url: https://api.anthropic.com/v1/messages
According to Anthropic:
A 400 Bad Request error means the API request format is incorrect. This is likely because Docling is formatting the request in a way that doesn't match Anthropic's API expectations, for example:
- Missing required fields: Anthropic's API requires specific fields like the messages array
- Image encoding: The image data might not be formatted correctly
- Docling compatibility: Docling might be designed for OpenAI's format, not Anthropic's
Metadata
Metadata
Assignees
Labels
No labels