Description
The Anthropic provider implementation does not support sending PDF documents as input, even though the Anthropic API fully supports this feature. Attempting to send a PDF with Claude models results in the error:
No models found that support text_generation for this prompt.
Expected Behavior
Users should be able to send PDF documents to Claude models using the SDK, as demonstrated in the official Anthropic API documentation:
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": [{
"type": "document",
"source": {
"type": "url",
"url": "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
}
},
{
"type": "text",
"text": "What are the key findings in this document?"
}]
}]
}'
Or
# Method 1: Fetch and encode a remote PDF
curl -s "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" | base64 | tr -d '\n' > pdf_base64.txt
# Method 2: Encode a local PDF file
# base64 document.pdf | tr -d '\n' > pdf_base64.txt
# Create a JSON request file using the pdf_base64.txt content
jq -n --rawfile PDF_BASE64 pdf_base64.txt '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": [{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": $PDF_BASE64
}
},
{
"type": "text",
"text": "What are the key findings in this document?"
}]
}]
}' > request.json
# Send the API request using the JSON file
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d @request.json
See the Anthropic PDF Support Documentation
Actual Behavior
The SDK rejects the prompt during model discovery because document modality is not recognized as a supported input type for Anthropic models.
Root Cause
Two issues in the Anthropic provider implementation:
1. Missing document modality in model metadata
In src/ProviderImplementations/Anthropic/AnthropicModelMetadataDirectory.php, the supported input modalities do not include documents:
new SupportedOption(
OptionEnum::inputModalities(),
[
[ModalityEnum::text()],
[ModalityEnum::text(), ModalityEnum::image()],
]
),
2. Missing document handling in message transformation
In src/ProviderImplementations/Anthropic/AnthropicTextGenerationModel.php, the getMessagePartData() method only handles image files and throws an exception for other file types, including documents.
Environment
My plugin uses PHP AI Client with depency of WP AI Client wordpress/wp-ai-client: 0.2.1
Description
The Anthropic provider implementation does not support sending PDF documents as input, even though the Anthropic API fully supports this feature. Attempting to send a PDF with Claude models results in the error:
Expected Behavior
Users should be able to send PDF documents to Claude models using the SDK, as demonstrated in the official Anthropic API documentation:
Or
See the Anthropic PDF Support Documentation
Actual Behavior
The SDK rejects the prompt during model discovery because document modality is not recognized as a supported input type for Anthropic models.
Root Cause
Two issues in the Anthropic provider implementation:
1. Missing document modality in model metadata
In
src/ProviderImplementations/Anthropic/AnthropicModelMetadataDirectory.php, the supported input modalities do not include documents:2. Missing document handling in message transformation
In
src/ProviderImplementations/Anthropic/AnthropicTextGenerationModel.php, thegetMessagePartData()method only handles image files and throws an exception for other file types, including documents.Environment
My plugin uses PHP AI Client with depency of WP AI Client wordpress/wp-ai-client: 0.2.1