Overview
The node integrates with Google Gemini AI to perform various AI-powered tasks. Specifically, the "Generate Text" operation allows users to generate text completions based on a prompt using different Gemini language models. This is useful for content creation, brainstorming, drafting emails, generating code snippets, or any scenario where AI-generated text can assist.
For example, you could input a prompt like "Write a professional email to schedule a meeting next week," and the node will return a generated email draft. The node supports customization of the model used, response format, temperature (randomness), and maximum output length.
Properties
| Name | Meaning |
|---|---|
| Model | The Gemini model to use for text generation. Options include: Gemini 1.5 Flash, Gemini 2.0 Flash, Gemini 2.5 Pro Preview, etc. |
| Prompt | The text prompt to send to Gemini for generating text. |
| System Prompt | Optional system instructions to guide the AI's behavior (e.g., "You are a helpful assistant..."). |
| Response Format | The format of the response returned by Gemini. Options: Plain text (text/plain) or JSON (application/json). |
| Temperature | Controls randomness in responses from 0 (deterministic) to 2 (very random). |
| Max Output Tokens | Maximum number of tokens to generate in the response (range 1 to 8192). |
Output
The node outputs a JSON object containing:
response: The generated text from Gemini based on the prompt.model: The name of the Gemini model used.prompt: The original prompt sent to Gemini.- Any additional input JSON data passed through from the previous node.
Example output JSON:
{
"response": "Generated text based on your prompt...",
"model": "gemini-2.5-flash-preview-05-20",
"prompt": "Your input prompt here"
}
No binary data is produced for this operation.
Dependencies
- Requires an API key credential for authenticating requests to the Google Gemini API.
- The node makes HTTP POST requests to the Gemini API endpoints for text generation.
- Proper n8n credential setup for the Gemini API is necessary.
Troubleshooting
- No valid response received from Gemini API: This error indicates that the API did not return usable text. Check your prompt and model selection.
- Gemini API Error: General errors from the API, possibly due to invalid credentials, network issues, or exceeding rate limits.
- Required properties missing: Ensure all required fields like "Prompt" and "Model" are set.
- If the node fails but "Continue On Fail" is enabled, it will output an error message per item instead of stopping execution.