How to adjust the model’s thinking level with reasoning_effort

The reasoning_effort parameter controls how much effort the model puts into reasoning and planning its response.

  • Higher effort β†’ more thoughtful, step-by-step, or structured answers
  • Lower effort β†’ faster, simpler replies

Allowed values:

ValueBehavior
"low"Quick, simple replies
"medium"Balanced depth and speed (good default choice)
"high"More detailed reasoning and structured answers

πŸ’‘ Tips:

  • Use "low" when you want short, direct responses.
  • Use "high" for tasks like explanations, problem solving, reasoning.
  • "medium" works well for most everyday interactions.

Note:

  • Setting higher reasoning effort may increase response time slightly, since the model is thinking more.

First, install the SDK:

$pip install -Uqq sarvamai

Then use the following Python code:

1from sarvamai import SarvamAI
2
3# Initialize the SarvamAI client with your API key
4client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
5
6# Example 1: Using default reasoning_effort (not specified) β€” balanced response
7response = client.chat.completions(
8 messages=[
9 {"role": "system", "content": "You are a helpful assistant."},
10 {"role": "user", "content": "Summarize the story of the Ramayana."}
11 ]
12 # reasoning_effort not specified β†’ defaults internally (balanced)
13)
14
15print(response.choices[0].message.content)
1from sarvamai import SarvamAI
2
3client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
4
5# Example 2: Using reasoning_effort = "high" β€” more detailed, thoughtful response
6response = client.chat.completions(
7 messages=[
8 {"role": "system", "content": "You are a helpful assistant."},
9 {"role": "user", "content": "Summarize the story of the Ramayana."}
10 ],
11 reasoning_effort="high"
12)
13
14# Receive assistant's reply as output
15print(response.choices[0].message.content)