Without the Files API, every API call that needs a big document re-sends the full bytes. With it, you upload once, get a file_id, and reference that ID. Combine with prompt caching and the document loads at a tiny fraction of the cost on each follow-up call.
file_id.{"type":"document","source":{"type":"file","file_id":"…"}}.file = client.files.upload(file=open("contract.pdf","rb"))
msg = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{
"role":"user",
"content":[
{"type":"document","source":{"type":"file","file_id":file.id},
"cache_control":{"type":"ephemeral"}},
{"type":"text","text":"Summarize the indemnity clauses."}
]
}]
)