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 caseOutputDestination Path
Sentiment analysispositive, negative, or neutral with confidenceenrichment.sentiment_details
Category classificationTopic category with confidenceenrichment.category
Brand recognitionExplicitly mentioned brand namesenrichment.brands
Brand recognition from hashtagsBrands embedded in hashtags or combined wordsenrichment.brands
Entity recognitionPeople, organizations, locations, events, and productsenrichment.entities
TranslationText translated to a configurable target languageenrichment.text_translation
ESG classificationenvironmental, social, governance, or noneenrichment.esg
Emotion analysisjoy, anger, fear, sadness, surprise, disgust, love, or noneenrichment.emotions
Intent classificationyes or no for purchase or commercial intentenrichment.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.

SettingValue
Source Pathcontent.body
Destination Pathenrichment.classification
Model Name and Versiongemini-3.1-flash-lite
Prompt TextSentiment prompt shown above
Response JSON FormatSentiment 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


Did this page help you?