Solving a puzzle with local Gemma

from openai import OpenAI

client = OpenAI(
base_url=“http://localhost:8000/v1”,
api_key=“EMPTY”
)

response = client.chat.completions.create(
model=“google/gemma-4-31B-it”,
messages=[
{“role”: “user”, “content”: “A snail is at the bottom of a 20-foot well. Each day it climbs 3 feet, but at night it slides back 2 feet. How many days will it take to reach the top?”}
],
max_tokens=4096,
extra_body={
“chat_template_kwargs”: {“enable_thinking”: True}
}
)

message = response.choices[0].message

The thinking process is in reasoning_content

if hasattr(message, “reasoning_content”) and message.reasoning_content:
print(“=== Thinking ===”)
print(message.reasoning_content)

print(“\n=== Answer ===”)
print(message.content)