Optimize Large PDF Workflows with the Files API
Use the Files API for large documents to reduce latency.
Upload large PDFs via the Files API rather than inline requests to speed up multi-turn conversations and save bandwidth.
The Scenario
You are working with a massive 500-page manual and need to ask ten different follow-up questions over the course of an hour.
Before & after
Re-uploading a large 50MB PDF for every new question wastes bandwidth and forces the model to re-process the file, taking 3-5 minutes per turn.
Use the Files API to upload the document once; subsequent queries take only seconds (under 1 minute) as the file is already indexed.
The Prompt
[IF_USING_API_OR_STUDIO] Use the Files API to upload [LARGE_FILE.PDF]. Then query: 'Based on the document I just uploaded, answer [SPECIFIC_QUESTION] using specific page references.'
For developers or power users, the Files API is more efficient than inline 'generateContent' requests. It reduces latency by keeping the document state available for multi-turn conversations without re-sending the entire byte stream.
Source
Release notes | Gemini API | Google AI for Developers"We recommend using the Files API for larger documents that you need to refer to in multi-turn interactions to improve request latency."
