ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Gemini -> Chat with PDF
Readonly
Gemini → Chat with PDF

Action summary

Gemini -> Chat with PDF

Xano / Google Gemini

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

  1. Talk to Uploaded Content
    • The function receives file_uri and question as inputs.
  2. 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`.
  1. Precondition
    • Checks: gemini_api.response.status == 200 (Proceeds only if the API response is successful.)
  2. Response
    • Returns: gemini_api.response.result

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_uri must 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 question can be any prompt or inquiry about the content of the PDF.
  • You must use a valid and enabled Gemini API key.

Troubleshooting

  • INVALID_ARGUMENT or NOT_FOUND: Verify the file_uri is 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

  • Gemini API: Overview \& Docs
  • Gemini API: Supported Models

Version notes

2025-06-30 16:36:23
Current
2025-06-30T11:09:29.000+00:00