SPB Git

Repository Public

gemini-3.1-flash-lite.md 8.9 KB 200 lines markdown

1<br />23Gemini 3.1 Flash-Lite is a low-latency, cost-effective multimodal model4optimized for high-frequency, lightweight tasks. The model supports text, image,5video, audio, and PDF inputs, and is designed for high-volume agentic workflows,6simple data extraction, and applications where latency and API cost are the7primary constraints.8[Try in Google AI Studio](https://aistudio.google.com/prompts/new_chat?model=gemini-3.1-flash-lite)910## gemini-3.1-flash-lite1112| Property | Description |13|---|---|14| Model code | `gemini-3.1-flash-lite` |15| Supported data types | **Inputs** Text, Image, Video, Audio, and PDF **Output** Text |16| Token limits^[\[\*\]](https://ai.google.dev/gemini-api/docs/tokens)^ | **Input token limit** 1,048,576 **Output token limit** 65,536 |17| Capabilities | **[Audio generation](https://ai.google.dev/gemini-api/docs/speech-generation)** Not supported **[Caching](https://ai.google.dev/gemini-api/docs/caching)** Supported **[Code execution](https://ai.google.dev/gemini-api/docs/code-execution)** Supported **[Computer use](https://ai.google.dev/gemini-api/docs/computer-use)** Not supported **[File search](https://ai.google.dev/gemini-api/docs/file-search)** Supported **[Function calling](https://ai.google.dev/gemini-api/docs/function-calling)** Supported **[Grounding with Google Maps](https://ai.google.dev/gemini-api/docs/maps-grounding)** Supported **[Image generation](https://ai.google.dev/gemini-api/docs/image-generation)** Not supported **[Live API](https://ai.google.dev/gemini-api/docs/live-api)** Not supported **[Search grounding](https://ai.google.dev/gemini-api/docs/google-search)** Supported **[Structured outputs](https://ai.google.dev/gemini-api/docs/structured-output)** Supported **[Thinking](https://ai.google.dev/gemini-api/docs/thinking)** Supported **[URL context](https://ai.google.dev/gemini-api/docs/url-context)** Supported |18| Consumption options | **[Batch API](https://ai.google.dev/gemini-api/docs/batch-api)** Supported **[Flex inference](https://ai.google.dev/gemini-api/docs/flex-inference)** Supported **[Priority inference](https://ai.google.dev/gemini-api/docs/priority-inference)** Supported |19| Versions | Read the [model version patterns](https://ai.google.dev/gemini-api/docs/models/gemini#model-versions) for more details. - `Stable: gemini-3.1-flash-lite` |20| Latest update | May 2026 |21| Model card | [Model card](https://deepmind.google/models/model-cards/gemini-3-1-flash-lite/) |2223## Developer guide2425Gemini 3.1 Flash-Lite is best at handling straightforward tasks at significant26scale. Here are some use cases best suited for Gemini 3.1 Flash-Lite:2728- **Translation**: Fast, cheap, high-volume translation, such as processing29  chat messages, reviews, and support tickets at scale. You can use system30  instructions to constrain output to only the translated text with no extra31  commentary:3233      from google import genai3435      client = genai.Client()36      text = "Hey, are you down to grab some pizza later? I'm starving!"3738      response = client.models.generate_content(39          model="gemini-3.1-flash-lite",40          config={41              "system_instruction": "Only output the translated text"42          },43          contents=f"Translate the following text to German: {text}"44      )4546      print(response.text)4748- **Transcription**: Process recordings, voice notes, or any audio content49  where you need a text transcript without spinning up a separate50  speech-to-text pipeline. Supports multimodal inputs, so you can pass audio51  files directly for transcription:5253      from google import genai5455      client = genai.Client()5657      # URL = "https://storage.googleapis.com/generativeai-downloads/data/State_of_the_Union_Address_30_January_1961.mp3"58      # Upload the audio file to the GenAI File API59      uploaded_file = client.files.upload(file='sample.mp3')6061      prompt = 'Generate a transcript of the audio.'6263      response = client.models.generate_content(64        model="gemini-3.1-flash-lite",65        contents=[prompt, uploaded_file]66      )6768      print(response.text)6970- **Lightweight agentic tasks and data extraction**: Entity extraction,71  classification, and lightweight data processing pipelines supported with72  structured JSON output. For example, extracting structured data from an73  e-commerce customer review:7475      from google import genai76      from pydantic import BaseModel, Field7778      client = genai.Client()7980      prompt = "Analyze the user review and determine the aspect, sentiment score, summary quote, and return risk"81      input_text = "The boots look amazing and the leather is high quality, but they run way too small. I'm sending them back."8283      class ReviewAnalysis(BaseModel):84          aspect: str = Field(description="The feature mentioned (e.g., Price, Comfort, Style, Shipping)")85          summary_quote: str = Field(description="The specific phrase from the review about this aspect")86          sentiment_score: int = Field(description="1 to 5 (1=worst, 5=best)")87          is_return_risk: bool = Field(description="True if the user mentions returning the item")8889      response = client.models.generate_content(90          model="gemini-3.1-flash-lite",91          contents=[prompt, input_text],92          config={93              "response_mime_type": "application/json",94              "response_json_schema": ReviewAnalysis.model_json_schema(),95          },96      )9798      print(response.text)99100- **Document processing and summarization**: Parse PDFs and return concise101  summaries, like for building a document processing pipeline or quickly102  triaging incoming files:103104      from google import genai105      from google.genai import types106      import httpx107108      client = genai.Client()109110      # Download a sample PDF document111      doc_url = "https://storage.googleapis.com/generativeai-downloads/data/med_gemini.pdf"112      doc_data = httpx.get(doc_url).content113114      prompt = "Summarize this document"115      response = client.models.generate_content(116          model="gemini-3.1-flash-lite",117          contents=[118              types.Part.from_bytes(119                  data=doc_data,120                  mime_type='application/pdf',121              ),122              prompt123          ]124      )125126      print(response.text)127128- **Model routing** : Use a low-latency and low-cost model as a classifier that129  routes queries to the appropriate model based on task complexity. This is a130  real pattern in production --- the open-source [Gemini CLI](https://geminicli.com/docs/core/#model-fallback) uses Flash-Lite to131  classify task complexity and route to Flash or Pro accordingly.132133      from google import genai134135      client = genai.Client()136137      FLASH_MODEL = 'flash'138      PRO_MODEL = 'pro'139140      CLASSIFIER_SYSTEM_PROMPT = f"""141      You are a specialized Task Routing AI. Your sole function is to analyze the user's request and classify its complexity. Choose between `{FLASH_MODEL}` (SIMPLE) or `{PRO_MODEL}` (COMPLEX).142      1.  `{FLASH_MODEL}`: A fast, efficient model for simple, well-defined tasks.143      2.  `{PRO_MODEL}`: A powerful, advanced model for complex, open-ended, or multi-step tasks.144145      A task is COMPLEX if it meets ONE OR MORE of the following criteria:146      1.  High Operational Complexity (Est. 4+ Steps/Tool Calls)147      2.  Strategic Planning and Conceptual Design148      3.  High Ambiguity or Large Scope149      4.  Deep Debugging and Root Cause Analysis150151      A task is SIMPLE if it is highly specific, bounded, and has Low Operational Complexity (Est. 1-3 tool calls).152      """153154      user_input = "I'm getting an error 'Cannot read property 'map' of undefined' when I click the save button. Can you fix it?"155156      response_schema = {157        "type": "object",158        "properties": {159          "reasoning": {160            "type": "string",161            "description": "A brief, step-by-step explanation for the model choice, referencing the rubric."162          },163          "model_choice": {164            "type": "string",165            "enum": [FLASH_MODEL, PRO_MODEL]166          }167        },168        "required": ["reasoning", "model_choice"]169      }170171      response = client.models.generate_content(172          model="gemini-3.1-flash-lite",173          contents=user_input,174          config={175              "system_instruction": CLASSIFIER_SYSTEM_PROMPT,176              "response_mime_type": "application/json",177              "response_json_schema": response_schema178          },179      )180181      print(response.text)182183- **Thinking**: For better accuracy for tasks that benefit from step-by-step184  reasoning, configure thinking so the model spends additional compute on185  internal reasoning before producing the final output:186187      from google import genai188      from google.genai import types189190      client = genai.Client()191192      response = client.models.generate_content(193          model="gemini-3.1-flash-lite",194          contents="How does AI work?",195          config=types.GenerateContentConfig(196              thinking_config=types.ThinkingConfig(thinking_level="high")197          ),198      )199200      print(response.text)
Files main
Menu

Theme