Gemini
Gemini is a component that lets you ask Google’s Gemini AI to generate text.
You simply choose a Gemini model, give it a prompt, and the component returns the model’s reply. It can also do more advanced things like letting the model think before answering, streaming the answer as it’s produced, or generating several answers at once.
How it Works
When you add Gemini to a workflow, the component first looks for a Google Gemini API credential that you have set up in Nappai.
If the credential is present, the component fetches the list of available Gemini text‑generation models from Google’s API and shows them in the Model dropdown.
When you run the workflow, Gemini sends your prompt (the Input field) to the chosen model via the Google Generative AI API.
The API returns the generated text, which the component passes on as the Text output.
If you enable Include Thoughts and set a Thinking Budget, the model will first produce a short “thought” explaining how it will answer, then give the final answer.
You can also stream the answer in real time with the Stream option.
Inputs
Credential
This component requires a Google Gemini API credential.
- Go to Credentials in Nappai and create a new credential of type Google Gemini API.
- Enter your Google API Key (password).
- In the Gemini component, select this credential in the Credential field.
Mapping Mode
This component has a special mode called “Mapping Mode”. When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
- Include Thoughts ( only works with thinking_budget > 0 ): Ask the model to generate internal thoughts before giving the final answer.
- Input: The text prompt you want the model to respond to.
- Mapping Mode: Enable mapping mode to process multiple data records in batch.
- Max Output Tokens: The maximum number of tokens the model can generate in its reply.
- Model: The name of the Gemini model to use (e.g.,
gemini-1.5-flash-001
). - N: Number of separate completions to generate for each prompt.
- Stream: Stream the response from the model as it is produced.
- System Message: A system‑level instruction that influences the model’s behavior.
- Temperature: Controls randomness; lower values make the output more deterministic.
- Thinking Budget: Number of tokens the model can spend on internal reasoning before answering.
- Top K: Limits sampling to the top‑k most probable tokens.
- Top P: Limits sampling to the smallest set of tokens whose cumulative probability exceeds this value.
Outputs
- Text: The generated text from Gemini (Message type).
- Model: The underlying Gemini language model object (LanguageModel type).
These outputs can be used in subsequent components, such as storing the text, sending it via email, or feeding it into another AI model.
Usage Example
- Add Gemini to your workflow.
- Select the Google Gemini API credential you created earlier.
- Choose a model from the dropdown (e.g.,
gemini-1.5-flash-001
). - Set the Input to “Summarize the following paragraph: …”.
- (Optional) Set Temperature to
0.3
for a more factual summary. - Run the workflow.
- The Text output will contain the summary, which you can then pass to a “Save to File” component or display in a dashboard widget.
Related Components
- OpenAI – Use OpenAI’s GPT models for text generation.
- Anthropic – Generate text with Claude models.
- Azure OpenAI – Access OpenAI models hosted on Azure.
- Text Splitter – Break long documents into chunks before sending them to Gemini.
Tips and Best Practices
- Choose the right model:
gemini-1.5-flash-001
is fast and inexpensive;gemini-1.5-pro-001
is more powerful for complex tasks. - Keep temperature low (e.g., 0.2–0.4) for consistent, factual responses.
- Use Thinking Budget only when you need the model to explain its reasoning; it adds extra tokens to the output.
- Stream large responses to improve user experience in dashboards.
- Limit Max Output Tokens to avoid exceeding quota or paying for unnecessary tokens.
Security Considerations
- Store your Google API Key in Nappai’s credential store; it is never exposed in the workflow UI.
- Restrict credential access to users who need to run Gemini workflows.
- Monitor API usage in Google Cloud to detect any unexpected activity.