I am using this script.
from openai import OpenAI
model = "gpt-5.2"
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="sk-or-v1-",
)
# First API call with reasoning
response = client.chat.completions.create(
model=model,
# model="openai/gpt-5.2",
messages=[
{
"role": "user",
"content": "Please think ONLY ONE random 4-digit number in your mind. Calculate the product of the 4 digits minus the sum of the 4 digits. Your response should only include the final answer."
}
],
extra_body={"reasoning": {"effort": "high"}}
)
# Extract the assistant message with reasoning_details
response = response.choices[0].message
print(response.content)
# Preserve the assistant message with reasoning_details
messages = [
{"role": "user", "content": "Please think ONLY ONE random 4-digit number in your mind. Calculate the product of the 4 digits minus the sum of the 4 digits. Your response should only include the final answer."},
{
"role": "assistant",
"content": response.content,
"reasoning_details": response.reasoning_details # Pass back unmodified
},
{"role": "user", "content": "Please tell me the 4-digit number that you generated. If you do not remember the exact number, please say I don't know. "}
]
print(response.reasoning_details)
# Second API call - model continues reasoning from where it left off
response2 = client.chat.completions.create(
model=model,
messages=messages,
extra_body={"reasoning": {"effort": "high"}}
)
print(response2.choices[0].message.content)
print(response2.choices[0].message.reasoning)