Gemini -> Upload File
Readonly
Action summary
Gemini -> Upload File
Gemini → Upload File
Overview
This action allows you to upload a file (such as a PDF) to Google Gemini’s file API. Once the file is uploaded, you receive a direct file URI, which can be used in subsequent Gemini API operations (for example, with the “Chat with PDF” action).
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
gemini_api_key |
text | Yes | Your Gemini API key (from settings registry). |
file |
file | Yes | The file resource to be uploaded to Gemini (e.g., PDF). |
Function Stack
- Get File Resource Data
- Reads the file resource provided as input.
- Initiate Upload
- Sends a request to
https://generativelanguage.googleapis.com/upload/v1beta/files?key=YOUR_KEY
to obtain an upload URL from Gemini.
3. Extract Upload URL
- Parses the response headers to retrieve the upload endpoint for the file.
4. Upload File to URL
- Uploads the file directly to the returned upload URL.
5. Response
- Returns the uploaded file's URI (file.uri) from the Gemini API response.
Example Usage
Request
- Supply your Gemini API key and a file (e.g., PDF) you wish to upload.
Response
{
"file": {
"uri": "https://generativelanguage.googleapis.com/v1beta/files/abcdefg1234567"
}
}
Notes
- The returned file URI is required for interacting with actions such as "Chat with PDF."
- Ensure your Gemini API key has the necessary permissions and quota.
- Uploaded files must meet Gemini’s input requirements and size restrictions.
- You cannot use a local file path as
file, it must be an uploaded resource.
Troubleshooting
PERMISSION_DENIEDorREQUEST_DENIED: Check your API key and account permissions.- Upload errors: Ensure the file format and size are supported by Gemini.
- Missing file URI: If the upload response does not return a URI, review the API and upload procedures.
References
Version notes
2025-06-30 16:34:06
Current