Claude on WholeTech network
Persistent files

Files API shipping

Upload a document once; reference it by ID across many API calls. PDFs, images, CSVs, code archives.

01 — Why it exists

Stop re-uploading the same 200-page contract.

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.

02 — The flow

Three calls.

  1. POST /v1/files with the file. Get back a file_id.
  2. Reference it in messages as {"type":"document","source":{"type":"file","file_id":"…"}}.
  3. Combine with prompt caching — mark the document as cacheable so subsequent calls hit the cache.
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."}
        ]
    }]
)
03 — What you can upload

The accepted shapes.

04 — Operational habits

Don't make these mistakes.