Overview
This node integrates with the Gemini generative language API to generate content based on a user-provided prompt. It is useful for automating text generation tasks such as creating articles, summaries, creative writing, or any scenario where AI-generated text can assist. For example, you could input a product description prompt and receive a detailed marketing copy, or provide a question and get an AI-generated answer.
Properties
| Name | Meaning |
|---|---|
| Prompt | The input text prompt that guides the content generation. |
| Top-P | Controls nucleus sampling; the cumulative probability threshold for token selection (e.g., 0.95). |
| Top-K | Limits the number of highest probability tokens to consider during generation (e.g., 40). |
| Temperatura | Controls randomness in output; higher values produce more diverse results (default 1). |
| Tamanho Máximo da Saída | Maximum number of tokens allowed in the generated output (default 8192). |
| Formato de Saída | Output format of the response: either application/json or text/plain. |
| Modelo | Choice of Gemini model variant: "Gemini 1.5 Flash", "Gemini 1.5 Pro", or "Gemini 1.0 Pro". |
Output
The node outputs an array with one item per input. Each item contains a json object with two fields:
prompt: The original prompt string provided as input.content: The full response from the Gemini API, which includes the generated content structured according to the selected output format.
If the output format is JSON, the content will be structured data; if plain text, it will be raw text. The node does not output binary data.
Dependencies
- Requires an active API key credential for the Gemini generative language API.
- Makes HTTP POST requests to the Gemini API endpoint at
https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent. - The node expects the API key to be configured securely within n8n credentials.
Troubleshooting
Common issues:
- Invalid or missing API key: The node will fail to authenticate with the Gemini API.
- Exceeding token limits: Setting
maxOutputTokenstoo high may cause API errors. - Network or service downtime: API calls may fail due to connectivity or server issues.
Error messages:
- Errors returned by the Gemini API are caught and rethrown with a message like:
Erro ao chamar a API do Gemini: [status code] - [error message]
This indicates the HTTP status and error details from the API response. - To resolve, verify API key validity, check parameter values, and ensure network access.
- Errors returned by the Gemini API are caught and rethrown with a message like:
Links and References
- Gemini Generative Language API documentation (Google Cloud):
https://cloud.google.com/generative-ai/docs/apis - n8n documentation on creating custom nodes:
https://docs.n8n.io/integrations/creating-nodes/