add thinking budget option for gemini
def generate():
client = genai.Client(
api_key=os.environ.get("GEMINI_API_KEY"),
)
model = "gemini-2.5-flash-preview-05-20"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""INSERT_INPUT_HERE"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
thinking_config = types.ThinkingConfig(
thinking_budget=8000,
),
response_mime_type="text/plain",
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if name == "main":
generate()
add a small button so we can set thinking budget
Great idea. After all, we've got to make good use of all the sugary sweet new things announced at I/O!
Great idea. After all, we've got to make good use of all the sugary sweet new things announced at I/O!
as of now this is only supported in gemini-2.5-flash-preview-05-20 model
I don't use Gemini's library so I don't think I can do that
There'll probably be an option to set the budget with their API, but I don't know if the OpenAI library can access these fields. That's a question which is likely answered somewhere deeeep down in dusty documentation 😭