# Claude 4.7

Move an app from Claude Opus 4.6 to Claude Opus 4.7: the model ID changes, three sampling fields and the thinking budget go.

1. [Change the model ID](#1-change-the-model-id).
2. [Update the request](#2-update-the-request).
3. [Read the answer](#3-read-the-answer).
4. [Set the effort](#4-set-the-effort).
5. [Compare before you switch](#5-compare-before-you-switch).

## 1. Change the model ID

Claude 4.7 is one model, Opus. For Sonnet, see [Sonnet 5](/docs/cookbook/sonnet-5).

| | From | To |
|---|---|---|
| Model ID | `anthropic/claude-opus-4.6` | `anthropic/claude-opus-4.7` |
| Context | 1 000 000 tokens | 1 000 000 tokens |
| Longest answer | 128 000 tokens | 128 000 tokens |
| Reasoning | off unless you ask | off unless you ask |
| Effort levels | `low` · `medium` · `high` · `max` | `low` · `medium` · `high` · `xhigh` · `max` |
| `supported_parameters` | holds `temperature`, `top_p`, `top_k` | holds none of the three |

[`GET /v1/model/{lab}/{model}`](/docs/reference/model) answers each model's entry: its context, its longest answer, its fields, its `reasoning`. The request keeps its shape; `model` changes.

```json
{
  "model": "anthropic/claude-opus-4.7",
  "reasoning": {
    "enabled": true,
    "effort": "xhigh"
  },
  "max_tokens": 64000,
  "messages": [
    {
      "role": "user",
      "content": "Refactor the payment module and list what changed."
    }
  ]
}
```

## 2. Update the request

| You send today | On Opus 4.7 | Send instead |
|---|---|---|
| `temperature`, `top_p` or `top_k` | not taken; Anthropic refuses any value but the default | nothing: steer with the prompt |
| a thinking budget: `reasoning.max_tokens` or `thinking.budget_tokens` | not honoured: reasoning is adaptive only | reasoning on, with an effort level |

| Route | Reasoning on, adaptive |
|---|---|
| `/v1/chat/completions` | `reasoning: {"enabled": true, "effort": "high"}` |
| `/v1/messages` | `thinking: {"type": "adaptive"}` and `output_config.effort` |

<div class="dont">
<p>Keep <code>temperature: 0</code> to make answers repeat. Opus 4.7 does not take it.</p>
</div>

<div class="do">
<p>Ask for a fixed shape with <a href="/docs/structured-outputs">Structured outputs</a>, and state in the prompt what must not vary.</p>
</div>

## 3. Read the answer

Anthropic lists four changes in what comes back.

| Change | What to do |
|---|---|
| a new tokenizer: the same text counts up to about 35 % more tokens | recount what your prompts hold, and check `max_tokens` |
| on `/v1/messages`, `thinking` blocks come back with their text left out unless you ask | send `thinking.display: "summarized"` where you show the reasoning |
| pictures read up to 2 576 pixels on the long side, where 1 568 was the limit | shrink pictures that need no more detail: a larger one counts more tokens |
| requests on some security topics can be refused | treat a refusal as an answer, not a failure to retry: see [Errors and retries](/docs/errors-and-retries) |

Opus 4.7 also writes progress notes during long agent runs on its own. Remove any prompt line that forces them. Both routes: [Chat](/docs/reference/chat-completions) · [Messages](/docs/reference/messages).

## 4. Set the effort

| Route | Field |
|---|---|
| `/v1/chat/completions` | `reasoning.effort`, or `reasoning_effort` |
| `/v1/messages` | `output_config.effort` |

Anthropic gives `high` as the default, and advises `xhigh` as the start for coding and agent work, `high` for most other work. `xhigh` is new, between `high` and `max`.

<div class="good-to-know">
<p>At <code>xhigh</code> or <code>max</code>, Anthropic's advice is a <code>max_tokens</code> of 64 000 to start: the reasoning and the reply both fit.</p>
</div>

## 5. Compare before you switch

Send the same set of real prompts to both IDs, and compare three things.

| Compare | Where |
|---|---|
| the answers | your own check: a test suite, a reviewer, the task's pass rate |
| what each cost | `usage.cost`, in DA, on every answer |
| how much each reasoned | `usage.completion_tokens_details.reasoning_tokens` |

The script sends each prompt to both IDs at one effort level, and prints one line per run: how the answer ended, what the prompt counted, what the model reasoned, and the charge in DA, then the first words of the answer. After each pair it prints the recount: the new ID's prompt tokens over the old one's. Prose, French and code are counted differently, so the three prompts are of the three kinds.

```python
import os
from openai import OpenAI

API_KEY = os.environ["OPENDUNES_API_KEY"]
BASE_URL = "https://opendunes.com/v1"
MODEL = "anthropic/claude-sonnet-4.5"
CANDIDATE = "anthropic/claude-sonnet-4.5"
EFFORT = "high"
MAX_TOKENS = 16000
PROMPTS = [
    "Explain in three lines why a parcel can be late on its way to Oran.",
    "Le burnous existe en quelle taille, et en quelle couleur ?",
    "Explain this function:\n"
    "def total(items):\n"
    "    return sum(item.price * item.count for item in items)",
]
RUNS = [("old", MODEL), ("new", CANDIDATE)]
FIELDS = {"reasoning": {"enabled": True, "effort": EFFORT}}

client = OpenAI(base_url=BASE_URL, api_key=API_KEY)

for prompt in PROMPTS:
    print(prompt.splitlines()[0])
    counted = {}
    for label, model in RUNS:
        reply = client.chat.completions.create(
            model=model,
            max_tokens=MAX_TOKENS,
            messages=[{"role": "user", "content": prompt}],
            extra_body=FIELDS,
        )
        usage = reply.usage
        counted[label] = usage.prompt_tokens
        details = usage.completion_tokens_details
        thought = details.reasoning_tokens if details else 0
        print(
            f"{label:4} {reply.choices[0].finish_reason:7}",
            f"in {usage.prompt_tokens}",
            f"thought {thought}",
            f"cost {usage.cost}",
        )
        print("   ", (reply.choices[0].message.content or "")[:60])
    print("prompt tokens, new over old:", counted["new"] / counted["old"])
```

```javascript
import OpenAI from "openai";

const API_KEY = process.env.OPENDUNES_API_KEY;
const BASE_URL = "https://opendunes.com/v1";
const MODEL = "anthropic/claude-sonnet-4.5";
const CANDIDATE = "anthropic/claude-sonnet-4.5";
const EFFORT = "high";
const MAX_TOKENS = 16000;
const PROMPTS = [
  "Explain in three lines why a parcel can be late on its way to Oran.",
  "Le burnous existe en quelle taille, et en quelle couleur ?",
  "Explain this function:\n" +
    "def total(items):\n" +
    "    return sum(item.price * item.count for item in items)",
];
const RUNS = [
  ["old", MODEL],
  ["new", CANDIDATE],
];
const FIELDS = { reasoning: { enabled: true, effort: EFFORT } };

const client = new OpenAI({ baseURL: BASE_URL, apiKey: API_KEY });

for (const prompt of PROMPTS) {
  console.log(prompt.split("\n")[0]);
  const counted = {};
  for (const [label, model] of RUNS) {
    const reply = await client.chat.completions.create({
      model,
      max_tokens: MAX_TOKENS,
      messages: [{ role: "user", content: prompt }],
      ...FIELDS,
    });
    const { usage, choices } = reply;
    counted[label] = usage.prompt_tokens;
    const thought = usage.completion_tokens_details?.reasoning_tokens ?? 0;
    console.log(
      label.padEnd(4),
      choices[0].finish_reason.padEnd(7),
      `in ${usage.prompt_tokens}`,
      `thought ${thought}`,
      `cost ${usage.cost}`,
    );
    console.log("   ", (choices[0].message.content ?? "").slice(0, 60));
  }
  console.log("prompt tokens, new over old:", counted.new / counted.old);
}
```

```go
package main

import (
	"context"
	"fmt"
	"os"
	"strconv"
	"strings"

	"github.com/openai/openai-go/v3"
	"github.com/openai/openai-go/v3/option"
)

const (
	baseURL   = "https://opendunes.com/v1"
	model     = "anthropic/claude-sonnet-4.5"
	candidate = "anthropic/claude-sonnet-4.5"
	effort    = "high"
	maxTokens = 16000
)

type run struct {
	label string
	model string
}

func main() {
	apiKey := os.Getenv("OPENDUNES_API_KEY")

	prompts := []string{
		"Explain in three lines why a parcel can be late on its " +
			"way to Oran.",
		"Le burnous existe en quelle taille, et en quelle couleur ?",
		"Explain this function:\n" +
			"def total(items):\n" +
			"    return sum(item.price * item.count for item in items)",
	}
	runs := []run{{"old", model}, {"new", candidate}}
	fields := map[string]any{
		"reasoning": map[string]any{"enabled": true, "effort": effort},
	}

	client := openai.NewClient(
		option.WithBaseURL(baseURL),
		option.WithAPIKey(apiKey),
	)
	for _, prompt := range prompts {
		fmt.Println(strings.Split(prompt, "\n")[0])
		counted := map[string]int64{}
		for _, r := range runs {
			params := openai.ChatCompletionNewParams{
				Model:     openai.ChatModel(r.model),
				MaxTokens: openai.Int(maxTokens),
				Messages: []openai.ChatCompletionMessageParamUnion{
					openai.UserMessage(prompt),
				},
			}
			params.SetExtraFields(fields)
			reply, err := client.Chat.Completions.New(
				context.TODO(), params)
			if err != nil {
				panic(err)
			}
			choice := reply.Choices[0]
			usage := reply.Usage
			counted[r.label] = usage.PromptTokens
			fmt.Printf("%-4s %-7s in %d thought %d cost %v\n",
				r.label, choice.FinishReason, usage.PromptTokens,
				usage.CompletionTokensDetails.ReasoningTokens,
				charge(reply))
			fmt.Printf("    %.60s\n", choice.Message.Content)
		}
		fmt.Println("prompt tokens, new over old:",
			float64(counted["new"])/float64(counted["old"]))
	}
}

func charge(reply *openai.ChatCompletion) float64 {
	cost := reply.Usage.JSON.ExtraFields["cost"].Raw()
	value, _ := strconv.ParseFloat(cost, 64)
	return value
}
```

```bash cURL
ADDRESS="https://opendunes.com/v1/chat/completions"
MODEL="anthropic/claude-sonnet-4.5"
CANDIDATE="anthropic/claude-sonnet-4.5"
EFFORT="high"
ENGLISH="Explain in three lines why a parcel can be late on its way to Oran."
FRENCH="Le burnous existe en quelle taille, et en quelle couleur ?"
CODE="Explain this function: \
def total(items): return sum(item.price * item.count for item in items)"

run() {
  jq -n --arg model "$2" --arg prompt "$PROMPT" --arg effort "$EFFORT" \
    '{model: $model, max_tokens: 16000,
      reasoning: {enabled: true, effort: $effort},
      messages: [{role: "user", content: $prompt}]}' |
    curl -s "$ADDRESS" \
      -H "Authorization: Bearer $OPENDUNES_API_KEY" \
      -H "Content-Type: application/json" \
      -d @- |
    jq -c --arg label "$1" '{label: $label,
      finish: .choices[0].finish_reason,
      in: .usage.prompt_tokens,
      thought: .usage.completion_tokens_details.reasoning_tokens,
      cost: .usage.cost,
      answer: ((.choices[0].message.content // "") | .[:60])}'
}

for PROMPT in "$ENGLISH" "$FRENCH" "$CODE"; do
  OLD="$(run "old" "$MODEL")"
  NEW="$(run "new" "$CANDIDATE")"
  printf '%s\n%s\n' "$OLD" "$NEW"
  printf '%s\n%s\n' "$OLD" "$NEW" |
    jq -rs '"prompt tokens, new over old: \(.[1].in / .[0].in)"'
done
```

The samples put `anthropic/claude-sonnet-4.5` in both seats, so they run as they stand, and the recount reads 1. Set `MODEL` to `anthropic/claude-opus-4.6` and `CANDIDATE` to `anthropic/claude-opus-4.7`.

Apply the recount to your own prompts: where it passes 1, raise `max_tokens` by the same share, and check what a long prompt now counts against the context.

Switch once the new ID holds; going back is the same one-line change. Run your red-team suite on the new ID too: [Red teaming](/docs/cookbook/red-teaming).
