# Gemini 3.1 Flash-Lite

Gemini 3.1 Flash-Lite 是一种低延迟、经济高效的多模态模型，针对高频、轻量级任务进行了优化。该模型支持文本、图像、视频、音频和 PDF 输入，专为大容量智能体工作流程、简单数据提取以及延迟和 API 成本为主要限制的应用程序而设计。

{% button href="https://aistudio.google.com/prompts/new_chat?model=gemini-3.1-flash-lite" variant="ais" %}在 Google AI Studio 中体验{% /button %}

## gemini-3.1-flash-lite  {% #gemini-31-flash-lite %}

{% doc-table variant="model" %}
{% doc-row header="true" %}
{% doc-cell %}
属性
{% /doc-cell %}

{% doc-cell %}
说明
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="id_card" /%}模型代码
{% /section %}
{% /doc-cell %}

{% doc-cell %}
`gemini-3.1-flash-lite`
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="save" /%}支持的数据类型
{% /section %}
{% /doc-cell %}

{% doc-cell %}
**输入** 文本、图像、视频、音频和 PDF

**输出** 文本
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="token_auto" /%}token 限制{% sup %}[[*]](/docs/tokens){% /sup %}
{% /section %}
{% /doc-cell %}

{% doc-cell %}
**输入token限制** 1,048,576

**输出 token 限制** 65,536
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="handyman" /%}功能
{% /section %}
{% /doc-cell %}

{% doc-cell %}
{% section class="three-column-grid" %}
{% section %}
[**音频生成**](/docs/speech-generation)

{% badge type="not-supported" /%}
{% /section %}

{% section %}
[**代码执行**](/docs/code-execution)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**计算机使用**](/docs/computer-use)

{% badge type="not-supported" /%}
{% /section %}

{% section %}
[**上下文缓存**](/docs/caching)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**文件搜索**](/docs/file-search)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**函数调用**](/docs/function-calling)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**使用 Google 地图提供事实依据**](/docs/maps-grounding)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**使用 Google 搜索提供事实依据**](/docs/google-search)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**图像生成**](/docs/image-generation)

{% badge type="not-supported" /%}
{% /section %}

{% section %}
[**Live API**](/docs/live-api)

{% badge type="not-supported" /%}
{% /section %}

{% section %}
[**结构化输出**](/docs/structured-output)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**思考**](/docs/thinking)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**URL 上下文**](/docs/url-context)

{% badge type="supported" /%}
{% /section %}
{% /section %}
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="speed" /%}消费选择
{% /section %}
{% /doc-cell %}

{% doc-cell %}
{% section class="three-column-grid" %}
{% section %}
[**Batch API**](/docs/batch-api)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**弹性推理**](/docs/flex-inference)

{% badge type="supported" /%}
{% /section %}

{% section %}
[**优先推理**](/docs/priority-inference)

{% badge type="supported" /%}
{% /section %}
{% /section %}
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="123" /%}版本
{% /section %}
{% /doc-cell %}

{% doc-cell %}
阅读 [模型版本模式](/docs/models#model-versions) 了解更多详情。

* `Stable: gemini-3.1-flash-lite`
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="calendar_month" /%}最新更新
{% /section %}
{% /doc-cell %}

{% doc-cell %}
5月 2026
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="id_card" /%}模型详情
{% /section %}
{% /doc-cell %}

{% doc-cell %}
[模型详情](https://deepmind.google/models/model-cards/gemini-3-1-flash-lite/)
{% /doc-cell %}
{% /doc-row %}

{% doc-row header="false" %}
{% doc-cell %}
{% section class="model-property" %}
{% icon name="paid" /%}价格
{% /section %}
{% /doc-cell %}

{% doc-cell %}
[价格](/docs/pricing#gemini-3.1-flash-lite)
{% /doc-cell %}
{% /doc-row %}
{% /doc-table %}

## 开发者指南  {% #developer-guide %}

Gemini 3.1 Flash-Lite 最适合处理大规模的简单任务。以下是一些最适合 Gemini 3.1 Flash-Lite 的用例：

* **翻译**：快速、廉价、大容量的翻译，例如大规模处理聊天消息、评论和支持票证。您可以使用系统指令将输出限制为仅翻译文本，没有额外的注释：

```python
from google import genai

client = genai.Client()
text = "Hey, are you down to grab some pizza later? I'm starving!"

response = client.models.generate_content(
    model="gemini-3.1-flash-lite",
    config={
        "system_instruction": "Only output the translated text"
    },
    contents=f"Translate the following text to German: {text}"
)

print(response.text)
```

* **转录**：处理录音、语音笔记或任何需要文本转录的音频内容，而无需启动单独的语音到文本管道。支持多模态输入，因此您可以直接传递音频文件进行转录：

```python
from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file='sample.mp3')

prompt = 'Generate a transcript of the audio.'

response = client.models.generate_content(
  model="gemini-3.1-flash-lite",
  contents=[prompt, uploaded_file]
)

print(response.text)
```

* **轻量级智能体任务和数据提取**：实体提取、分类和轻量级数据处理管道，支持结构化 JSON 输出。例如，从电子商务客户评论中提取结构化数据：

```python
from google import genai
from pydantic import BaseModel, Field

client = genai.Client()

prompt = "Analyze the user review and determine the aspect, sentiment score, summary quote, and return risk"
input_text = "The boots look amazing and the leather is high quality, but they run way too small. I'm sending them back."

class ReviewAnalysis(BaseModel):
    aspect: str = Field(description="The feature mentioned (e.g., Price, Comfort, Style, Shipping)")
    summary_quote: str = Field(description="The specific phrase from the review about this aspect")
    sentiment_score: int = Field(description="1 to 5 (1=worst, 5=best)")
    is_return_risk: bool = Field(description="True if the user mentions returning the item")

response = client.models.generate_content(
    model="gemini-3.1-flash-lite",
    contents=[prompt, input_text],
    config={
        "response_mime_type": "application/json",
        "response_json_schema": ReviewAnalysis.model_json_schema(),
    },
)

print(response.text)
```

* **文件处理与总结**：解析 PDF 并返回简洁的摘要，例如构建文档处理管道或快速分类传入文件：

```python
from google import genai
from google.genai import types
import httpx

client = genai.Client()

doc_url = "https://storage.googleapis.com/generativeai-downloads/data/med_gemini.pdf"
doc_data = httpx.get(doc_url).content

prompt = "Summarize this document"
response = client.models.generate_content(
    model="gemini-3.1-flash-lite",
    contents=[
        types.Part.from_bytes(
            data=doc_data,
            mime_type='application/pdf',
        ),
        prompt
    ]
)

print(response.text)
```

* **模型路由**：使用低延迟和低成本模型作为分类器，根据任务复杂性将查询路由到适当的模型。这是真正的生产模式——开源 [Gemini CLI](https://geminicli.com/docs/core/#model-fallback) 使用 Flash-Lite 对任务复杂性进行分类，并相应地路由到 Flash 或 Pro。

```python
from google import genai

client = genai.Client()

FLASH_MODEL = 'flash'
PRO_MODEL = 'pro'

CLASSIFIER_SYSTEM_PROMPT = f"""
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).

1. `{FLASH_MODEL}`: A fast, efficient model for simple, well-defined tasks.
2. `{PRO_MODEL}`: A powerful, advanced model for complex, open-ended, or multi-step tasks.

A task is COMPLEX if it meets ONE OR MORE of the following criteria:

1. High Operational Complexity (Est. 4+ Steps/Tool Calls)
2. Strategic Planning and Conceptual Design
3. High Ambiguity or Large Scope
4. Deep Debugging and Root Cause Analysis

A task is SIMPLE if it is highly specific, bounded, and has Low Operational Complexity (Est. 1-3 tool calls).
"""

user_input = "I'm getting an error 'Cannot read property 'map' of undefined' when I click the save button. Can you fix it?"

response_schema = {
  "type": "object",
  "properties": {
    "reasoning": {
      "type": "string",
      "description": "A brief, step-by-step explanation for the model choice, referencing the rubric."
    },
    "model_choice": {
      "type": "string",
      "enum": [FLASH_MODEL, PRO_MODEL]
    }
  },
  "required": ["reasoning", "model_choice"]
}

response = client.models.generate_content(
    model="gemini-3.1-flash-lite",
    contents=user_input,
    config={
        "system_instruction": CLASSIFIER_SYSTEM_PROMPT,
        "response_mime_type": "application/json",
        "response_json_schema": response_schema
    },
)

print(response.text)
```

* **思考**：为了从逐步推理中受益的任务获得更高的准确性，请配置思维，以便模型在生成最终输出之前在内部推理上花费额外的计算：

```python
from google import genai
from google.genai import types

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3.1-flash-lite",
    contents="How does AI work?",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_level="high")
    ),
)

print(response.text)
```
