SPB Git

Repository Public

effort.md 34.5 KB 642 lines markdown

1---2title: Effort3url: https://platform.claude.com/docs/en/build-with-claude/effort4description: Control how many tokens Claude uses when responding with the effort parameter, trading off between response thoroughness and token efficiency.5---67## Compatibility8- [ZDR](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention): eligible (excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements))9- Supported models: `claude-fable-5-1`, `claude-mythos-5-1`, `claude-fable-5`, `claude-mythos-5`, `claude-mythos-preview`, `claude-opus-5`, `claude-opus-4-8`, `claude-opus-4-7`, `claude-opus-4-6`, `claude-opus-4-5-20251101`, `claude-sonnet-5`, `claude-sonnet-4-6`10- Platforms: Claude API, Claude Platform on AWS, Amazon Bedrock, Google Cloud, Microsoft Foundry1112The effort parameter lets you control how many tokens Claude spends when responding to requests. You can trade off between response thoroughness and token efficiency with a single model. The top-level effort parameter is available on all supported models with no beta header required. [Per-message effort](https://platform.claude.com/docs/en/build-with-claude/effort#change-effort-mid-conversation-beta) is in beta.1314<Tip>15  To learn how effort interacts with thinking and which control to reach for, see [Thinking and effort](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-and-effort). Where adaptive thinking is available, effort is the recommended way to control thinking depth.16</Tip>1718## Set the effort level1920Set `output_config.effort` on the request. The following example runs one request at `medium` effort and prints the response text.2122<CodeGroup>23  ```bash cURL24  curl https://api.anthropic.com/v1/messages \25    -H "x-api-key: $ANTHROPIC_API_KEY" \26    -H "anthropic-version: 2023-06-01" \27    -H "content-type: application/json" \28    -d '{29      "model": "claude-opus-5",30      "max_tokens": 4096,31      "messages": [{32        "role": "user",33        "content": "Analyze the trade-offs between microservices and monolithic architectures"34      }],35      "output_config": {36        "effort": "medium"37      }38    }'39  ```4041  ```bash CLI42  ant messages create \43    --model claude-opus-5 \44    --max-tokens 4096 \45    --output-config '{effort: medium}' \46    --message '{role: user, content: "Analyze the trade-offs between microservices and monolithic architectures"}' \47    --transform 'content.#(type=="text").text' \48    --raw-output49  ```5051  ```python Python52  client = anthropic.Anthropic()5354  response = client.messages.create(55      model="claude-opus-5",56      max_tokens=4096,57      messages=[58          {59              "role": "user",60              "content": "Analyze the trade-offs between microservices and monolithic architectures",61          }62      ],63      output_config={"effort": "medium"},64  )6566  for block in response.content:67      if block.type == "text":68          print(block.text)69  ```7071  ```typescript TypeScript72  const client = new Anthropic();7374  const response = await client.messages.create({75    model: "claude-opus-5",76    max_tokens: 4096,77    messages: [78      {79        role: "user",80        content: "Analyze the trade-offs between microservices and monolithic architectures"81      }82    ],83    output_config: {84      effort: "medium"85    }86  });8788  const textBlock = response.content.find(89    (block): block is Anthropic.TextBlock => block.type === "text"90  );91  console.log(textBlock?.text);92  ```9394  ```csharp C#95  AnthropicClient client = new();9697  var parameters = new MessageCreateParams98  {99      Model = Model.ClaudeOpus5,100      MaxTokens = 4096,101      Messages = [102          new() {103              Role = Role.User,104              Content = "Analyze the trade-offs between microservices and monolithic architectures"105          }106      ],107      OutputConfig = new OutputConfig108      {109          Effort = Effort.Medium110      }111  };112113  var message = await client.Messages.Create(parameters);114  Console.WriteLine(message);115  ```116117  ```go Go118  client := anthropic.NewClient()119120  response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{121  	Model:     anthropic.ModelClaudeOpus5,122  	MaxTokens: 4096,123  	Messages: []anthropic.MessageParam{124  		anthropic.NewUserMessage(anthropic.NewTextBlock("Analyze the trade-offs between microservices and monolithic architectures")),125  	},126  	OutputConfig: anthropic.OutputConfigParam{127  		Effort: anthropic.OutputConfigEffortMedium,128  	},129  })130  if err != nil {131  	log.Fatal(err)132  }133  for _, block := range response.Content {134  	if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {135  		fmt.Println(textBlock.Text)136  	}137  }138  ```139140  ```java Java141  import com.anthropic.models.messages.OutputConfig;142143  void main() {144      AnthropicClient client = AnthropicOkHttpClient.fromEnv();145146      MessageCreateParams params = MessageCreateParams.builder()147          .model(Model.CLAUDE_OPUS_5)148          .maxTokens(4096L)149          .addUserMessage("Analyze the trade-offs between microservices and monolithic architectures")150          .outputConfig(OutputConfig.builder()151              .effort(OutputConfig.Effort.MEDIUM)152              .build())153          .build();154155      Message response = client.messages().create(params);156      response.content().stream()157          .flatMap(block -> block.text().stream())158          .forEach(textBlock -> IO.println(textBlock.text()));159  }160  ```161162  ```php PHP163  $client = new Client();164165  $message = $client->messages->create(166      maxTokens: 4096,167      messages: [168          ['role' => 'user', 'content' => 'Analyze the trade-offs between microservices and monolithic architectures']169      ],170      model: 'claude-opus-5',171      outputConfig: ['effort' => 'medium'],172  );173174  foreach ($message->content as $block) {175      if ($block->type === 'text') {176          echo $block->text, PHP_EOL;177      }178  }179  ```180181  ```ruby Ruby182  client = Anthropic::Client.new183184  message = client.messages.create(185    model: "claude-opus-5",186    max_tokens: 4096,187    messages: [188      { role: "user", content: "Analyze the trade-offs between microservices and monolithic architectures" }189    ],190    output_config: {191      effort: "medium"192    }193  )194195  message.content.each do |block|196    puts block.text if block.type == :text197  end198  ```199</CodeGroup>200201## How effort works202203By default, Claude uses high effort, spending as many tokens as needed for excellent results. You can raise the effort level to `max` for the absolute highest capability, or lower it to be more conservative with token usage, optimizing for speed and cost while accepting some reduction in capability.204205<Tip>206  Setting `effort` to `"high"` produces exactly the same behavior as omitting the `effort` parameter entirely.207</Tip>208209The effort parameter affects **all tokens** in the response, including:210211* Text responses and explanations212* Tool calls and function arguments213* Thinking (when active)214215Because effort applies to every output token, it works whether or not thinking is enabled. Lower effort also means fewer and terser tool calls.216217### Effort levels218219| Level    | Description                                                                                                                                                                                                                                                                            | Typical use case                                                                           |220| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |221| `max`    | Absolute maximum capability with no constraints on token spending. Available on Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Sonnet 5, and Claude Sonnet 4.6. | Tasks requiring the deepest possible reasoning and most thorough analysis                  |222| `xhigh`  | Extended capability for long-horizon work. Available on Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 5.                                                                                    | Long-running agentic and coding tasks (over 30 minutes) with token budgets in the millions |223| `high`   | High capability. Equivalent to not setting the parameter.                                                                                                                                                                                                                              | Complex reasoning, difficult coding problems, agentic tasks                                |224| `medium` | Balanced approach with moderate token savings.                                                                                                                                                                                                                                         | Agentic tasks that require a balance of speed, cost, and performance                       |225| `low`    | Most efficient. Significant token savings with some capability reduction.                                                                                                                                                                                                              | Simpler tasks that need the best speed and lowest costs, such as subagents                 |226227Not every model that supports `max` supports `xhigh`.228229<Note>230  Effort is a behavioral signal, not a strict token budget. At lower effort levels, Claude still thinks on sufficiently difficult problems, but thinks less than it would at higher effort levels for the same problem.231</Note>232233The per-model recommendations that follow override this table where they differ.234235### Recommended effort levels for Claude Fable 5.1236237Claude Fable 5.1 supports all five effort levels. **Start with `high`, the default.** Step up to `xhigh` or `max` for the most capability-sensitive agentic and coding work, and step down to `medium` or `low` for routine or latency-sensitive work once your evals show quality holds. At `high` and above, set a large `max_tokens`. It's a hard limit on total output (thinking plus response text). The same recommendations apply to Claude Mythos 5.1. See [Prompting Claude Fable 5.1](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#consider-all-effort-levels).238239Claude Fable 5.1 also supports [changing effort mid-conversation](https://platform.claude.com/docs/en/build-with-claude/effort#change-effort-mid-conversation-beta) with a per-message `output_config`, which preserves the prompt cache.240241### Recommended effort levels for Claude Fable 5242243Effort is the primary control for trading off intelligence, latency, and cost on Claude Fable 5. **Start with `high`, the default, for most tasks**, use `xhigh` for the most capability-sensitive workloads, and step down to `medium` or `low` for routine work. Lower effort settings on Claude Fable 5 still perform well and often exceed `xhigh` performance on prior models. At `high` and `xhigh`, set a large `max_tokens`. It's a hard limit on total output (thinking plus response text). See [Cost control](https://platform.claude.com/docs/en/build-with-claude/thinking-steering-and-cost#cost-control).244245Reduce effort if a task completes but takes longer than necessary, or if you want a faster, more interactive working style. The same recommendations apply to Claude Mythos 5. For fuller guidance, see [Prompting Claude Fable 5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5).246247### Recommended effort levels for Claude Opus 5248249Claude Opus 5 supports all five effort levels. **Start with `high`, the default**, and adjust based on your evals: step up to `xhigh` for demanding coding and agentic work, or to `max` when a task justifies unconstrained token spending, and use `low` and `medium` liberally as your primary control for token cost and response time wherever your evals show quality holds. If you carried effort settings over from an earlier model, run a fresh effort sweep on your evals rather than reusing them.250251Effort controls thinking volume, not visible response length: on Claude Opus 5, changing effort does not reliably shorten responses, so [prompt for length](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5#response-length-and-verbosity) instead.252253The API default is `high`. Set `effort` explicitly to use a different level. The value you pass overrides the default.254255On Claude Opus 5, thinking cannot be disabled at `xhigh` or `max` effort: requests that set `thinking: {"type": "disabled"}` at those levels return a 400 error. See [Effort with thinking](https://platform.claude.com/docs/en/build-with-claude/effort#effort-with-thinking).256257When running Claude Opus 5 at `xhigh` or `max` effort, set a large `max_tokens` so the model has room to think and act across subagents and tool calls. Starting at 64k tokens and tuning from there is a reasonable default.258259Claude Opus 5 also supports [changing effort mid-conversation](https://platform.claude.com/docs/en/build-with-claude/effort#change-effort-mid-conversation-beta) with a per-message `output_config`, which preserves the prompt cache.260261### Recommended effort levels for Claude Opus 4.8262263The guidance for Claude Opus 4.7 also applies to Claude Opus 4.8. **Start with `xhigh` for coding and agentic use cases**, use `high` for most other intelligence-sensitive workloads, and step down to `medium` or `low` only when you've measured that the lower level holds quality on your evals.264265The API default is `high`. Set `effort` explicitly to use a different level. The value you pass overrides the default.266267When running Claude Opus 4.8 at `xhigh` or `max` effort, set a large `max_tokens` so the model has room to think and act across subagents and tool calls. Starting at 64k tokens and tuning from there is a reasonable default.268269### Recommended effort levels for Claude Opus 4.7270271**Start with `xhigh` for coding and agentic use cases**, and use `high` as the minimum for most intelligence-sensitive workloads. Step down to `medium` for cost-sensitive workloads, or up to `max` only when your evals show measurable headroom at `xhigh`.272273The API default is `high`. To use `xhigh`, set `effort` explicitly. The value you pass overrides the default.274275| Effort   | Guidance for Claude Opus 4.7                                                                                                                                                                                             |276| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |277| `low`    | Efficient, but best for short, scoped tasks. Pair `low` with explicit checklists if your task has multiple sections.                                                                                                     |278| `medium` | The drop-in for the average workflow where you want good results while reducing costs.                                                                                                                                   |279| `high`   | Advanced use cases that still need a balance of intelligence and token consumption. This is often the best balance of quality and token efficiency.                                                                      |280| `xhigh`  | The recommended starting point for coding and agentic work, and for exploratory tasks such as repeated tool calling, detailed web search, and knowledge-base search. Expect meaningfully higher token usage than `high`. |281| `max`    | Reserve for frontier problems. On most workloads `max` adds significant cost for relatively small quality gains, and on some structured-output or less intelligence-sensitive tasks it can lead to overthinking.         |282283Claude Opus 4.7 also respects effort levels more strictly than Claude Opus 4.6, especially at `low` and `medium`. At lower effort levels, the model scopes its work to what was asked rather than doing more than requested. If you observe shallow reasoning on complex problems with Claude Opus 4.7, raise effort rather than prompting around it. If you must keep effort low for latency, add targeted guidance like "This task involves multistep reasoning. Think carefully before responding."284285When running Claude Opus 4.7 at `xhigh` or `max` effort, set a large `max_tokens` so the model has room to think and act across subagents and tool calls. Starting at 64k tokens and tuning from there is a reasonable default.286287### Recommended effort levels for Claude Sonnet 5288289Claude Sonnet 5 defaults to `high` effort on the Claude API and Claude Code.290291* **High effort (default):** Suitable for complex reasoning, coding, and agentic tasks where quality matters more than speed or cost.292* **Xhigh effort:** For the hardest coding and agentic tasks. See [Prompting Claude Sonnet 5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-sonnet-5#calibrating-effort-and-thinking-depth).293* **Medium effort:** Cost-saving step-down from the default. Comparable to Claude Sonnet 4.6 at high effort.294* **Low effort:** For high-volume or latency-sensitive workloads. Suitable for chat and non-coding use cases where faster turnaround is prioritized.295* **Max effort:** For tasks requiring the absolute highest capability with no constraints on token spending.296297### Recommended effort levels for Claude Sonnet 4.6298299Sonnet 4.6 defaults to `high` effort. Explicitly set effort when using Sonnet 4.6 to avoid unexpected latency:300301* **Medium effort** (recommended default): Best balance of speed, cost, and performance for most applications. Suitable for agentic coding, tool-heavy workflows, and code generation.302* **Low effort:** For high-volume or latency-sensitive workloads. Suitable for chat and non-coding use cases where faster turnaround is prioritized.303* **High effort:** For complex reasoning and tasks where quality matters more than speed or cost.304* **Max effort:** For tasks requiring the absolute highest capability with no constraints on token spending.305306## Effort with tool use307308When using tools, the effort parameter affects both the explanations around tool calls and the tool calls themselves. Lower effort levels tend to:309310* Combine multiple operations into fewer tool calls311* Make fewer tool calls312* Proceed directly to action without preamble313* Use terse confirmation messages after completion314315Higher effort levels may:316317* Make more tool calls318* Explain the plan before taking action319* Provide detailed summaries of changes320* Include more comprehensive code comments321322## Effort with thinking323324The `thinking` parameter controls whether Claude thinks in [thinking blocks](https://platform.claude.com/docs/en/build-with-claude/thinking) before answering; the `effort` parameter controls how much work Claude puts into the whole response, which in adaptive mode includes how often and how deeply it thinks. Don't pass `adaptive` as an `effort` value: `adaptive` is a thinking mode, not an effort level.325326At higher effort levels, Claude thinks on most requests and at greater length. At lower levels, it can skip thinking entirely for simpler problems. See [Thinking and effort](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-and-effort) for full guidance on how the two controls work together.327328On Claude Opus 4.5, the only extended-thinking-only model that supports effort, it works alongside [`budget_tokens`](https://platform.claude.com/docs/en/build-with-claude/extended-thinking): set the effort level for your task, then set the thinking token budget based on how much reasoning depth the task needs.329330For per-model thinking availability, see the [per-model configuration table](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#supported-models). Effort works with or without thinking. See [How effort works](https://platform.claude.com/docs/en/build-with-claude/effort#how-effort-works).331332## Change effort mid-conversation333334You can run later turns of a conversation at a different effort level in two ways. On Claude Fable 5.1, Claude Mythos 5.1, and Claude Opus 5, use a per-message effort change, which keeps the prompt cache. On other models, set a new top-level value on the next request, which starts the cache over.335336### Per-message effort (beta)337338Per-message effort is in beta and requires the [beta header](https://platform.claude.com/docs/en/api/beta-headers) `mid-conversation-output-config-2026-07-01`. Models without per-message effort, including Claude Fable 5, return a 400 error: `output_config.effort requires a model that supports per-turn effort; this model does not`.339340Add a `role: "system"` message with empty `content` and the new level in `output_config.effort`. The new level takes effect from the next `user` turn and holds until a later message changes it. Everything before that message is unchanged, so the cached prefix still matches.341342The following example starts at `high`, then drops to `low` for a routine follow-up:343344<CodeGroup>345  ```bash cURL346  # Effort-only system message: the new level takes effect from the next user turn.347  curl https://api.anthropic.com/v1/messages \348    -H "x-api-key: $ANTHROPIC_API_KEY" \349    -H "anthropic-version: 2023-06-01" \350    -H "anthropic-beta: mid-conversation-output-config-2026-07-01" \351    -H "content-type: application/json" \352    -d '{353      "model": "claude-fable-5-1",354      "max_tokens": 4096,355      "output_config": {"effort": "high"},356      "messages": [357        {"role": "user", "content": "Plan a migration from SQLite to PostgreSQL in three short steps."},358        {"role": "assistant", "content": "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts."},359        {"role": "system", "content": [], "output_config": {"effort": "low"}},360        {"role": "user", "content": "Summarize the plan in one sentence."}361      ]362    }'363  ```364365  ```bash CLI366  ant beta:messages create --beta mid-conversation-output-config-2026-07-01 \367    --transform 'content.#(type=="text").text' --raw-output <<'YAML'368  model: claude-fable-5-1369  max_tokens: 4096370  output_config:371    effort: high372  messages:373    - role: user374      content: Plan a migration from SQLite to PostgreSQL in three short steps.375    - role: assistant376      content: "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts."377    # Effort-only system message: the new level takes effect from the next user turn.378    - role: system379      content: []380      output_config:381        effort: low382    - role: user383      content: Summarize the plan in one sentence.384  YAML385  ```386387  ```python Python388  client = anthropic.Anthropic()389390  response = client.beta.messages.create(391      model="claude-fable-5-1",392      max_tokens=4096,393      output_config={"effort": "high"},394      messages=[395          {396              "role": "user",397              "content": "Plan a migration from SQLite to PostgreSQL in three short steps.",398          },399          {400              "role": "assistant",401              "content": "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts.",402          },403          # Effort-only system message: the new level takes effect from the next user turn.404          {"role": "system", "content": [], "output_config": {"effort": "low"}},405          {"role": "user", "content": "Summarize the plan in one sentence."},406      ],407      betas=["mid-conversation-output-config-2026-07-01"],408  )409410  for block in response.content:411      if block.type == "text":412          print(block.text)413  ```414415  ```typescript TypeScript416  const client = new Anthropic();417418  const response = await client.beta.messages.create({419    model: "claude-fable-5-1",420    max_tokens: 4096,421    output_config: { effort: "high" },422    messages: [423      {424        role: "user",425        content: "Plan a migration from SQLite to PostgreSQL in three short steps."426      },427      {428        role: "assistant",429        content:430          "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts."431      },432      // Effort-only system message: the new level takes effect from the next user turn.433      { role: "system", content: [], output_config: { effort: "low" } },434      { role: "user", content: "Summarize the plan in one sentence." }435    ],436    betas: ["mid-conversation-output-config-2026-07-01"]437  });438439  for (const block of response.content) {440    if (block.type === "text") {441      console.log(block.text);442    }443  }444  ```445446  ```csharp C#447  using Anthropic.Models.Beta;448  using Anthropic.Models.Beta.Messages;449450  AnthropicClient client = new();451452  var response = await client.Beta.Messages.Create(new MessageCreateParams453  {454      Model = "claude-fable-5-1",455      MaxTokens = 4096,456      OutputConfig = new() { Effort = Effort.High },457      Messages =458      [459          new() { Role = Role.User, Content = "Plan a migration from SQLite to PostgreSQL in three short steps." },460          new() { Role = Role.Assistant, Content = "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts." },461          // Effort-only system message: the new level takes effect from the next user turn.462          new()463          {464              Role = Role.System,465              Content = new([]),466              OutputConfig = new() { Effort = BetaSystemMessageOutputConfigEffort.Low },467          },468          new() { Role = Role.User, Content = "Summarize the plan in one sentence." },469      ],470      Betas = [AnthropicBeta.MidConversationOutputConfig2026_07_01],471  });472473  foreach (var block in response.Content)474  {475      if (block.TryPickText(out var textBlock))476      {477          Console.WriteLine(textBlock.Text);478      }479  }480  ```481482  ```go Go483  client := anthropic.NewClient()484485  response, err := client.Beta.Messages.New(context.Background(), anthropic.BetaMessageNewParams{486  	Model:     "claude-fable-5-1",487  	MaxTokens: 4096,488  	OutputConfig: anthropic.BetaOutputConfigParam{489  		Effort: anthropic.BetaOutputConfigEffortHigh,490  	},491  	Messages: []anthropic.BetaMessageParam{492  		anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Plan a migration from SQLite to PostgreSQL in three short steps.")),493  		{494  			Role:    anthropic.BetaMessageParamRoleAssistant,495  			Content: []anthropic.BetaContentBlockParamUnion{anthropic.NewBetaTextBlock("1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts.")},496  		},497  		// Effort-only system message: the new level takes effect from the next user turn.498  		anthropic.NewBetaSystemMessage(anthropic.BetaSystemMessageOutputConfigParam{499  			Effort: anthropic.BetaSystemMessageOutputConfigEffortLow,500  		}),501  		anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Summarize the plan in one sentence.")),502  	},503  	Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaMidConversationOutputConfig2026_07_01},504  })505  if err != nil {506  	log.Fatal(err)507  }508509  for _, block := range response.Content {510  	if textBlock, ok := block.AsAny().(anthropic.BetaTextBlock); ok {511  		fmt.Println(textBlock.Text)512  	}513  }514  ```515516  ```java Java517  import com.anthropic.models.beta.AnthropicBeta;518  import com.anthropic.models.beta.messages.BetaMessage;519  import com.anthropic.models.beta.messages.BetaMessageParam;520  import com.anthropic.models.beta.messages.BetaOutputConfig;521  import com.anthropic.models.beta.messages.BetaSystemMessageOutputConfig;522  import com.anthropic.models.beta.messages.MessageCreateParams;523524  void main() {525      AnthropicClient client = AnthropicOkHttpClient.fromEnv();526527      MessageCreateParams params = MessageCreateParams.builder()528          .model("claude-fable-5-1")529          .maxTokens(4096L)530          .addBeta(AnthropicBeta.MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01)531          .outputConfig(BetaOutputConfig.builder()532              .effort(BetaOutputConfig.Effort.HIGH)533              .build())534          .addUserMessage("Plan a migration from SQLite to PostgreSQL in three short steps.")535          .addAssistantMessage("1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts.")536          // Effort-only system message: the new level takes effect from the next user turn.537          .addMessage(BetaMessageParam.builder()538              .role(BetaMessageParam.Role.SYSTEM)539              .contentOfBetaContentBlockParams(List.of())540              .outputConfig(BetaSystemMessageOutputConfig.builder()541                  .effort(BetaSystemMessageOutputConfig.Effort.LOW)542                  .build())543              .build())544          .addUserMessage("Summarize the plan in one sentence.")545          .build();546547      BetaMessage response = client.beta().messages().create(params);548      response.content().stream()549          .flatMap(block -> block.text().stream())550          .forEach(textBlock -> IO.println(textBlock.text()));551  }552  ```553554  ```php PHP555  use Anthropic\Beta\AnthropicBeta;556  use Anthropic\Beta\Messages\BetaMessageParam;557  use Anthropic\Beta\Messages\BetaOutputConfig;558  use Anthropic\Beta\Messages\BetaSystemMessageOutputConfig;559  use Anthropic\Client;560561  $client = new Client();562563  $response = $client->beta->messages->create(564      model: 'claude-fable-5-1',565      maxTokens: 4096,566      outputConfig: BetaOutputConfig::with(effort: 'high'),567      messages: [568          BetaMessageParam::with(role: 'user', content: 'Plan a migration from SQLite to PostgreSQL in three short steps.'),569          BetaMessageParam::with(role: 'assistant', content: '1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts.'),570          // Effort-only system message: the new level takes effect from the next user turn.571          BetaMessageParam::with(572              role: 'system',573              content: [],574              outputConfig: BetaSystemMessageOutputConfig::with(effort: 'low'),575          ),576          BetaMessageParam::with(role: 'user', content: 'Summarize the plan in one sentence.'),577      ],578      betas: [AnthropicBeta::MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01],579  );580581  foreach ($response->content as $block) {582      if ($block->type === 'text') {583          echo $block->text, PHP_EOL;584      }585  }586  ```587588  ```ruby Ruby589  client = Anthropic::Client.new590591  response = client.beta.messages.create(592    model: "claude-fable-5-1",593    max_tokens: 4096,594    output_config: {effort: :high},595    messages: [596      {role: "user", content: "Plan a migration from SQLite to PostgreSQL in three short steps."},597      {role: "assistant", content: "1. Export the SQLite data. 2. Create the PostgreSQL schema. 3. Import the data and verify row counts."},598      # Effort-only system message: the new level takes effect from the next user turn.599      {role: "system", content: [], output_config: {effort: :low}},600      {role: "user", content: "Summarize the plan in one sentence."}601    ],602    betas: [Anthropic::AnthropicBeta::MID_CONVERSATION_OUTPUT_CONFIG_2026_07_01]603  )604605  response.content.each do |block|606    puts block.text if block.type == :text607  end608  ```609</CodeGroup>610611An effort-only system message carries no text, so the [placement rules for mid-conversation system messages](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages#limitations) don't apply. It can appear anywhere in `messages`, including as the first entry or between an `assistant` turn and the next `user` turn. Values are the level names (`low`, `medium`, `high`, `xhigh`, and `max`).612613On Claude Fable 5.1, prefer this form over changing the top-level value between requests. A top-level change restarts the cache and also steers the model less reliably: its earlier replies were written at the previous level, and it tends to stay consistent with them.614615### Top-level effort on the next request616617The top-level `output_config.effort` applies to the whole request. To run a later part of a conversation at a different level, set the new value on the next request. Because top-level effort shapes the rendered prompt, changing it between requests doesn't preserve cached prefixes from earlier turns. If you rely on [prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) across a long session and your model doesn't support per-message effort, pick an effort level at the start and keep it constant.618619## Best practices6206211. **Set effort explicitly:** The API defaults to `high`, but the right starting point depends on your model and workload.6222. **Use low for speed-sensitive or simple tasks:** When latency matters or tasks are straightforward, low effort can significantly reduce response times and costs.6233. **Test your use case:** The impact of effort levels varies by task type. Evaluate performance on your specific use cases before deploying.6244. **Consider dynamic effort:** Adjust effort based on task complexity. Simple queries may warrant low effort while agentic coding and complex reasoning benefit from high effort. See the next item before varying it within one conversation.6255. **Hold top-level effort constant within cached conversations:** Changing the top-level effort value between requests invalidates [prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching), so vary it across workloads rather than within a conversation that relies on cache hits. On models that support it, use a [per-message effort change](https://platform.claude.com/docs/en/build-with-claude/effort#change-effort-mid-conversation-beta) instead, which preserves the cache. See [Thinking and prompt caching](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-and-prompt-caching).626627## Next steps628629<CardGroup>630  <Card title="Task budgets" icon="gauge" href="https://platform.claude.com/docs/en/build-with-claude/task-budgets">631    Give Claude an advisory token budget for the full agentic loop to help the model self-regulate on long agentic tasks.632  </Card>633634  <Card title="Steering thinking" icon="compass" href="https://platform.claude.com/docs/en/build-with-claude/thinking-steering-and-cost">635    Understand adaptive thinking, where Claude decides when and how much to think, and steer it with effort and prompting.636  </Card>637638  <Card title="Thinking" icon="brain" href="https://platform.claude.com/docs/en/build-with-claude/thinking">639    Understand how thinking works, when Claude thinks by default, and how thinking interacts with effort.640  </Card>641</CardGroup>642
Files main
Menu

Theme