Gemini Text Generation
Generate text and structured AI classifications with your own Gemini API key.
About
The Gemini Text Generation component sends prompts and document content to the Gemini API using your own Gemini API key. It can generate text or return structured JSON for classification and document enrichment.
The component processes the documents received in a pipeline batch in one Gemini request. For each document, it reads the configured Source Path and sends Gemini an item containing the source text. Returned results are mapped back to the documents and written to the configured Destination Path.
Available Recipes
Gemini Text Generation is a generic component. These recipes provide ready-to-use prompts and response schemas for common classification and enrichment tasks; they are not separate component modes.
| Use case | Output | Destination Path |
|---|---|---|
| Sentiment analysis | positive, negative, or neutral with confidence | enrichment.sentiment_details |
| Category classification | Topic category with confidence | enrichment.category |
| Brand recognition | Explicitly mentioned brand names | enrichment.brands |
| Brand recognition from hashtags | Brands embedded in hashtags or combined words | enrichment.brands |
| Entity recognition | People, organizations, locations, events, and products | enrichment.entities |
| Translation | Text translated to a configurable target language | enrichment.text_translation |
| ESG classification | environmental, social, governance, or none | enrichment.esg |
| Emotion analysis | joy, anger, fear, sadness, surprise, disgust, love, or none | enrichment.emotions |
| Intent classification | yes or no for purchase or commercial intent | enrichment.intent |
Add to a Pipeline
Add the Gemini Text Generation component to a Pipeline after a component that produces documents containing the text to analyze. If you are using the standard Datastreamer Unify Schema, the default Source Path is content.body.
The component requires a Gemini API key. Store the key as a Datastreamer Secret and select that secret in the component configuration.
Configuration
API Key (Required)
Your Gemini API key stored as a Datastreamer Secret.
Source Path (Required)
The JSON path containing the text sent to Gemini. The default is content.body. Documents without a value at this path are skipped.
Destination Path (Required)
The JSON path where each Gemini result is written. The default is enrichment.classification.
Prompt Text (Required)
The instructions sent to Gemini as the system prompt. The catalog includes a simple sentiment-analysis prompt as the default example:
Analyze the sentiment of each input text and return one JSON object per input, in the same order, with a "label" of "positive", "negative", or "neutral" and a "confidence" score between 0 and 1. Do not include the original text in the output.Replace this prompt when using the component for another classification, extraction, translation, or text-generation task. Ready-to-use prompts are available in the Gemini recipes.
Model Name and Version (Required)
The Gemini model used for the request. The default is gemini-3.1-flash-lite.
Response JSON Format (Optional)
Use this property when the response must follow a JSON schema. The schema is sent to Gemini as a structured-output schema with application/json response MIME type.
For batch processing, use an array schema and return one result per input in the same order. The following is the default sentiment-analysis example:
{
"type": "array",
"items": {
"type": "object",
"required": ["label", "confidence"],
"properties": {
"label": {
"type": "string",
"enum": ["positive", "negative", "neutral"]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"additionalProperties": false
}
}The schema above return one object per input with a sentiment label and a confidence score. The component writes each returned object to the matching document's Destination Path.
Filter Condition (Optional)
Limit processing to documents that match a JSON filter condition. Results are mapped back to their original documents when a filter is configured.
Sentiment Example
The following configuration classifies the text in content.body and stores the result in enrichment.classification.
| Setting | Value |
|---|---|
| Source Path | content.body |
| Destination Path | enrichment.classification |
| Model Name and Version | gemini-3.1-flash-lite |
| Prompt Text | Sentiment prompt shown above |
| Response JSON Format | Sentiment schema shown above |
Given this input document:
{
"content": {
"body": "I love this product!"
}
}The component writes a result similar to this:
{
"content": {
"body": "I love this product!"
},
"enrichment": {
"classification": {
"label": "positive",
"confidence": 0.98
}
}
}Recipes and References
Updated about 1 hour ago
