Gemini -> Chat with PDF
Readonly
Action summary
Gemini -> Chat with PDF
Gemini → Chat with PDF
Overview
This action enables you to interact with the Gemini API using a PDF file and a text question. The function accepts a reference to an already uploaded PDF file (as a file_uri) hosted on Google, and a user question, then queries Gemini’s generative content API to get a response.
Important: A file_uri must already be uploaded and available on Google before using this action. The function does not handle file uploads; it operates on an existing, accessible URI.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
gemini_api_key |
text | Yes | Your Gemini API key (from settings registry). |
file_uri |
text | Yes | URI of the already-uploaded PDF file on Google. |
question |
text | Yes | The question to ask Gemini about the content of the uploaded PDF. |
Function Stack
- Talk to Uploaded Content
- The function receives
file_uriandquestionas inputs.
- The function receives
- API Request
- Sends a POST request to:
https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=YOUR_API_KEY
Using the following payload structure:
{
"contents": [
{
"parts": [
{
"file_data": { "file_uri": "<file_uri>" }
},
{
"text": "<question>"
}
]
}
]
}
- Authenticates using `gemini_api_key`.
- Returns the API response as `gemini_api`.
- Precondition
- Checks:
gemini_api.response.status == 200(Proceeds only if the API response is successful.)
- Checks:
- Response
- Returns:
gemini_api.response.result
- Returns:
Example Usage
Request
{
"gemini_api_key": "AIzaSyD...",
"file_uri": "https://storage.googleapis.com/path-to-your-pdf.pdf",
"question": "Summarize the main arguments from this document."
}
Response
{
"result": "The main arguments in this document are..."
}
Notes
- The
file_urimust be a direct URL to a PDF file that is already uploaded and publicly or appropriately accessible to the Gemini API. - The function does NOT upload files; ensure you upload your PDF first and obtain the URI.
- The
questioncan be any prompt or inquiry about the content of the PDF. - You must use a valid and enabled Gemini API key.
Troubleshooting
INVALID_ARGUMENTorNOT_FOUND: Verify thefile_uriis correct, accessible, and the PDF exists.PERMISSION_DENIED: Ensure your API key has access, and the file permissions are properly set on Google.REQUEST_DENIED: Check your API key and ensure billing or usage limits have not been exceeded.- Other API errors: Refer to Gemini API documentation for more details.
References
Version notes
2025-06-30 16:36:23
Current