Actions2
Overview
This node integrates with Google Generative AI models to generate text completions or structured objects based on user input. It supports two main input modes: a simple single prompt or a conversation-style input with multiple messages, allowing flexible interaction styles with the AI model.
Common scenarios include:
- Generating creative or informative text completions from a single prompt.
- Engaging in multi-turn conversations by providing a sequence of messages.
- Producing structured data outputs that conform to a specified JSON schema, useful for extracting specific information or formatting AI responses programmatically.
- Analyzing or processing file content sent as part of messages (e.g., images, audio, documents) by including them as binary data or URLs.
Practical examples:
- Creating chatbot responses based on conversation history.
- Summarizing or expanding text prompts.
- Extracting sentiment or other structured insights from text using a defined schema.
- Sending an image or document for analysis along with textual instructions.
Properties
| Name | Meaning |
|---|---|
| Model Name or ID | Select which Google Generative AI model to use. Options include various Gemini models optimized for different tasks such as text generation or vision tasks. |
| Input Type | Choose how to provide input: "Simple Prompt" (a single text prompt) or "Messages" (a conversation with multiple messages). |
| System | (For Simple Prompt) Optional system prompt to specify the model's behavior or context, e.g., "You are a helpful assistant." |
| Prompt | (For Simple Prompt) The single text prompt to generate a completion for. |
| Messages | (For Messages input) A collection of messages forming a conversation. Each message has a role (user, assistant, system), content type (text or binary file), and content. Files can be provided as binary data or URLs with MIME types. |
| Messages as JSON | Whether to input messages as a raw JSON array instead of using the UI. |
| Messages (JSON) | The JSON array of message objects (role and content) when "Messages as JSON" is enabled. |
| Options | Collection of optional parameters: - Max Tokens: Maximum tokens to generate. - Temperature: Controls randomness of output (0 to 2). - Include Request Body: Whether to include the request body in the output. |
| Safety Settings | Configure safety categories (Hate Speech, Dangerous Content, Harassment, Sexually Explicit) and thresholds to block or filter certain outputs. |
| Use Search Grounding | Enable real-time or up-to-date information if supported by the model. |
Output
The node outputs a JSON object containing detailed response data from the Google Generative AI API, including:
text: The generated text completion (for text generation).toolCalls,toolResults: Any tool interactions during generation.finishReason: Reason why generation stopped.usage: Token usage statistics (promptTokens,completionTokens,totalTokens).response: Metadata about the API response (ID, model ID, timestamp, headers).steps: Generation steps if available.warnings: Any warnings returned by the API.experimental_providerMetadata: Additional metadata.- Optionally, if enabled, the original request body sent to the API.
For structured object generation, the output includes the generated object conforming to the provided JSON schema along with similar metadata fields.
If binary data is involved in messages, it is sent to the API but not directly outputted; the output focuses on the AI-generated textual or structured response.
Dependencies
- Requires a valid API key credential for Google Generative AI.
- Uses the Vercel AI SDK and Google Generative Language API endpoint.
- Node requires internet access to call Google's generative language API at
https://generativelanguage.googleapis.com/v1beta. - No additional environment variables beyond the API key credential are needed.
Troubleshooting
- Missing API Key: If no API key is provided in credentials, the node will throw an error. Ensure the API key credential is configured correctly.
- Invalid JSON in Messages (JSON): When using JSON input for messages, invalid JSON syntax or structure will cause errors. Validate JSON format before running.
- Binary Property Not Found: If a binary file is referenced in messages but the specified binary property does not exist on the input item, an error is thrown. Verify the binary property name matches the input data.
- Invalid JSON Schema: For structured object generation, the provided JSON schema must be valid. Invalid schemas cause validation errors.
- Safety Settings Blocking Output: Configured safety settings may block or filter outputs if content triggers those categories.
- Continue On Fail: If enabled, the node continues processing remaining items even if one fails, returning error details in the output JSON.