Skip to content

Feature Request: Support thinkingBudget configuration for Gemini 2.5 Flash in Flutter #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nmarafo opened this issue May 18, 2025 · 6 comments

Comments

@nmarafo
Copy link

nmarafo commented May 18, 2025

Hi team,

First of all, thank you for your amazing work on this library. I’d like to request support for a new feature introduced in the Gemini 2.5 Flash model — the ability to configure the internal "thinking" process via the thinkingBudget parameter.

As described in the official documentation, Gemini 2.5 Flash models support an internal reasoning process that can be tuned by setting the thinkingBudget (an integer between 0 and 24,576). This parameter gives the model guidance on how many tokens it can use internally to “think” before generating the final response.

Why is this important?
This feature is crucial for advanced tasks such as:

Complex code generation

Multistep problem solving in math or logic

Structured data analysis and reasoning

Use cases where we want to trade off latency vs. reasoning depth

For example, setting thinkingBudget: 0 disables the internal reasoning (faster response), while higher values allow more in-depth reasoning (better quality for complex tasks).

What we need
Please consider adding support for configuring the thinkingBudget parameter in the Flutter wrapper/library for Gemini. Ideally, it could be passed through a GenerateContentConfig (or similar config object), as is done in the Python API:

from google import genai
from google.genai import types

client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.5-flash-preview-04-17",
    contents="Explain the Occam's Razor concept and provide everyday examples of it",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_budget=1024)
    ),
)

Final thoughts
Having access to this parameter in Flutter will enable developers to optimize Gemini's performance depending on their specific app needs. It’s especially valuable in educational, scientific, and reasoning-intensive applications.

Thanks again for your hard work! Looking forward to your feedback.

Best regards,
Norberto

@csells
Copy link
Contributor

csells commented May 18, 2025

Have you tried setting the chat config when creating the provider? It should allow you to do what you want.

@nmarafo
Copy link
Author

nmarafo commented May 19, 2025

I get the following options:

package:firebase_vertexai/src/api.dart
(new) GenerationConfig GenerationConfig({
  int? candidateCount,
  List<String>? stopSequences,
  int? maxOutputTokens,
  double? temperature,
  double? topP,
  int? topK,
  double? presencePenalty,
  double? frequencyPenalty,
  String? responseMimeType,
  Schema? responseSchema,
})

Containing class: GenerationConfig

An example how I'm using the code:

  @override
  Future<String?> generateJsonResponse(String prompt, {
    Schema? responseSchema,
    int? maxOutputTokens,
  }) async {
    final generationConfig = responseSchema != null || maxOutputTokens != null
        ? GenerationConfig(
      responseMimeType: 'application/json',
      maxOutputTokens: maxOutputTokens ?? defaultMaxOutputTokens,
      responseSchema: responseSchema,
    )
        : null;

    final response = await _model.generateContent(
      [Content.text(prompt)],
      generationConfig: generationConfig,
    );

    return response.text;
  }

@csells
Copy link
Contributor

csells commented May 19, 2025

It looks like you're referring to the GenKit API. There's no config for "thinking" that I can find on the Vertex SDK for Dart: https://pub.dev/documentation/firebase_vertexai/latest/search.html?q=thinking

@nmarafo
Copy link
Author

nmarafo commented May 19, 2025 via email

@nmarafo
Copy link
Author

nmarafo commented May 19, 2025

https://pub.dev/packages/flutter_ai_toolkit
My issue is a feature request.

https://github.com/flutter/Ai is the repository link in flutter_ai_toolkit space in pub dev

@nmarafo
Copy link
Author

nmarafo commented May 19, 2025

Sorry, I found the issue tracker in flutter fire and opened an issue in the right place:
firebase/flutterfire#17368 (comment)
Thanks

@nmarafo nmarafo closed this as completed May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants