Images and documents
Send images and PDFs
Images
The model that can read images can send both text and images along with each other. Please provide the URL or data URL in the https address. You can see which model can read the image in Support for each model.
client.chat.completions.create(
model="anthropic/claude-opus-5.5",
messages=[{"role": "user", "content": [
{"type": "text", "text": "What is in this photo??"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
]}],
)- I can receive files in PNG, JPEG, GIF, and WebP formats. A single file can have a size of up to 3.75MB. I can send up to 10 files at a time.
- One image can be estimated to cost between 100 and 5,300 tokens, depending on its size and the model used. The cost is directly proportional to the price of the input tokens.
- The URL can be brought over by us once, and then passed to the model. Please send the URL that can be viewed after logging in as a data URL.
- Images are not saved.
PDF documents
The PDF can be sent to the Claude model using Messages API. Please convert the file to base64 format and place it in the document block.
import anthropic, base64
client = anthropic.Anthropic(base_url="https://alprouter.com/api", api_key="alp-your-key")
pdf = base64.standard_b64encode(open("report.pdf", "rb").read()).decode()
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": [
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": pdf}},
{"type": "text", "text": "Summarize this document in three lines"},
]}],
)- You can send up to 5 documents at a time. The total size of all the requests can reach up to 20MB.
- In
/chat/completions, PDF files haven’t been received yet.