Claude Opus 5.5·续

Then she ran her thumb along the spiral binding and felt the small, ragged teeth of paper where the second page had been torn out.

"Detective?"

"Get me a list," she said quietly, "of every unattended death in this city for the past six months. Every single one where the coroner said natural causes."

"That's gonna be a lot of names."

Inez looked down at the dead man's folded hands, at the careful, tender way someone had placed them, and felt a cold certainty settle in her chest like a stone sinking to the bottom of a well.

"I know," she said. "That's what worries me."


```json
{
  "model": "claude-opus-5-5",
  "id": "msg_011CfJq3WeHfjsXNsyLj1M39",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "thinking",
      "thinking": "",
      "signature": "CAQShRMKEAgSGAI4AUIIdGhpbmtpbmcSDIDVDS0bZ7tPwidUBhoMJcIrOXoIrKeBZ736IjCiR9c1BYgFaV/KxfRZIfBPODzcDk/kotKaz5Woz9lPOpdHsl8lRRTVO76eFTnpg+sqohLBBcpO7QZvgesqX3d0RJSeflcA0UOhFW47+Z00C5loAtHYzKc9UlimVw4mqL+3P5i0twnlzuwymUtoIzC7qrOaJPwd3rTRY0irzUE5lfuDQrMeES5MZE8PHPUkI+Pr/VgrfSd1sW7F7gBZBNtaZO/mDlaHUhpghVVCs5F+zzaMzW+hJ/XZWUGMLWJbBaIWogx3eDiMNGeSb46TzU1r0tY/IwLv/jHJluH4NAljHZd5haivBeCEYNtHnfXSiI2X+feSLWIb0QaklSwFdjvR+wq8QSWqviCYHdjAOyMuPDiI3w+y58LQ6aqiiqcIg5rQWj4Adl+bAV6Yfy3w7UKjD5HZgrBDFbnMNzbBMYxdlnGQQT69LoauE2pPUSsy7IGlyEejbb693I/eH0xEP3o95CW6ImoJg3H6iTyDTU+dCOHn4lxmH6EMIrc9mmYGFy5tqzvMxn1UITB/HRdLWkSO4ZOAu9DQUa7PiIr26qXhY5zDfkZ+4WWf3urgy0p+bBjBaS37M8dBpDNIdILQkNqhw5WZ8CT/9Ehp2ONL2B1OQdOxBAbVnQBbQfnmCkB6nXnBcmaMQT+jZSDgWFVH9lgVIzuKro0At5qaW95fAktX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7tpKGF0TqCbbqn6EFDt6jtIDzZjkUNNy+jpCJts1hCj1bs8SQH0bzw7rs5yHOzljbvz8N1g6jwBKcVStkFr9IdxTvxW3PejuGoc4CSh9zwEZ2CiedISd4OlcODmr7VZFqlXSv6gzteyhv6RjYj96qYLxWkQoeD4Py9+RQ1wuOFm/6KNjul2HYOOap+82RM/0A1kKcQhF+DAeOPpwzKZEVtbRwEZX2pCe4NXnpCZLia5oSol2IpGr/m4tKzr9AjDG1EB6PWUgO2gyYhWzrA2qt/wezIQ9tppnUkoAlfEH6kule0GbJMBiXmGpr+IESTnyoD4miyLiYxYB6T0T6/DbKOGAE="
    },
    {
      "type": "text",
      "text": "# The Missing Page\n\nThe dead man had been arranged with the kind of care people usually reserve for sleeping children. Hands folded over his sternum. Shoes placed side by side at the foot of the bed, laces tucked in. Someone had even drawn the curtains halfway, as if the morning light might disturb him.\n\nDetective Inez Halloran stood in the doorway longer than she needed to, letting the room tell her what it wanted to tell her. Rooms always talked, if you let them. This one was saying *nothing happened here*, and it was saying it far too politely.\n\n\"Neighbor found him,\" said Patrolman Deaks, hovering at her elbow. \"Door was unlocked. No sign of forced entry, no sign of a struggle. Coroner's thinking heart, maybe. Guy was sixty-one.\"\n\n\"Guys who die of heart attacks don't usually take their shoes off first and line them up.\"\n\n\"Maybe he was tidy.\"\n\nInez didn't answer. She crossed the room, snapped on a pair of gloves, and crouched beside the shoes. Brown oxfords, recently polished, heels worn unevenly in a way that suggested a bad left knee. She picked up the right shoe, then the left, and felt something shift inside the toe.\n\nA folded square of paper, pale blue, lined.\n\nShe knew the paper before she'd even opened it. It was the same shade of blue as the cheap spiral notebook she'd bought from the pharmacy on Calder Street that morning, because her old one had gotten coffee-soaked in the car. She'd grabbed it off the rack without thinking, paid with exact change, and written exactly one thing in it: the address of this apartment.\n\nShe unfolded the paper.\n\nFour words, written in blue ballpoint:\n\n*He wasn't the first.*\n\nThe handwriting was slanted, cramped, the *t*s crossed low and hard, the way her father had taught her when she was seven because he said it looked more decisive. Nobody else crossed their *t*s like that. She'd never seen anyone else do it.\n\nIt was her handwriting.\n\n\"Detective?\" Deaks leaned in. \"You got something?\"\n\nInez folded the paper back along its creases and slipped it into an evidence bag, keeping her face very still. Then, as casually as she could manage, she reached into her coat pocket and pulled out her new notebook. She flipped it open to the first page, where the address sat in her own familiar scrawl.\n\nThen she ran her thumb along the spiral binding and felt the small, ragged teeth of paper where the second page had been torn out.\n\n\"Detective?\"\n\n\"Get me a list,\" she said quietly, \"of every unattended death in this city for the past six months. Every single one where the coroner said *natural causes*.\"\n\n\"That's gonna be a lot of names.\"\n\nInez looked down at the dead man's folded hands, at the careful, tender way someone had placed them, and felt a cold certainty settle in her chest like a stone sinking to the bottom of a well.\n\n\"I know,\" she said. \"That's what worries me.\""
    }
  ],
  "container": null,
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 28,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 1633,
    "output_tokens_details": {
      "thinking_tokens": 656
    },
    "service_tier": "standard",
    "inference_geo": "global"
  }
}
**Streaming Response** — Enable streaming for real-time output
const response = await env.AI.run(
  'anthropic/claude-opus-5.5',
  {
    max_tokens: 1024,
    messages: [{ content: 'Explain the concept of recursion with a simple example.', role: 'user' }],
    stream: true,
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/messages \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "anthropic/claude-opus-5.5",
  "max_tokens": 1024,
  "messages": [
    {
      "content": "Explain the concept of recursion with a simple example.",
      "role": "user"
    }
  ],
  "stream": true
}'
# Recursion

**Recursion** is when a function solves a problem by **calling itself** on a smaller version of the same problem, until it reaches a case simple enough to answer directly.

Every recursive function needs two parts:

1. **Base case**: the simplest version of the problem, answered directly without recursion. This is what stops the function.
2. **Recursive case**: the function calls itself on a smaller input, moving closer to the base case.

## A Simple Example: Factorial

The factorial of a number `n` (written `n!`) is the product of all positive integers up to `n`:

```
5! = 5 × 4 × 3 × 2 × 1 = 120
```

Notice that `5! = 5 × 4!`, and `4! = 4 × 3!`, and so on. The problem contains a smaller copy of itself, which makes it a natural fit for recursion.

```python
def factorial(n):
    if n == 1:                       # Base case
        return 1
    return n * factorial(n - 1)      # Recursive case

print(factorial(5))  # Output: 120
```

## How It Works Step by Step

When you call `factorial(5)`, the calls stack up until they reach the base case:

```
factorial(5) = 5 * factorial(4)
                   factorial(4) = 4 * factorial(3)
                                      factorial(3) = 3 * factorial(2)
                                                         factorial(2) = 2 * factorial(1)
                                                                            factorial(1) = 1   ← base case
```

Then the results are returned back up the chain:

```
factorial(1) = 1
factorial(2) = 2 * 1  = 2
factorial(3) = 3 * 2  = 6
factorial(4) = 4 * 6  = 24
factorial(5) = 5 * 24 = 120
```

## A Real-World Analogy

Imagine you're standing in a long line and want to know your position. You ask the person in front of you, "What's your position?" They ask the person in front of them, and so on. The person at the very front knows they're #1 (**base case**). Each person then answers the one behind them with "my position + 1," until the answer reaches you.

## Common Pitfall

If you forget the base case, or the input never gets closer to it, the function calls itself forever:

```python
def broken(n):
    return n * broken(n - 1)   # No base case!
```

In Python this raises a `RecursionError` (a "stack overflow") because each call takes up memory until the limit is hit.

## When to Use Recursion

Recursion works well for problems that naturally break into smaller, similar subproblems, such as:
- Traversing trees and folder structures
- Sorting algorithms like merge sort and quicksort
- Mathematical sequences (factorial, Fibonacci)
- Puzzles like the Tower of Hanoi

For simple repetitive tasks, a regular loop is often more efficient, but recursion can make certain problems much clearer and easier to write.
[
  {
    "type": "message_start",
    "message": {
      "model": "claude-opus-5-5",
      "id": "msg_011CfJq56VHXzuR3jeXnycTD",
      "type": "message",
      "role": "assistant",
      "content": [],
      "container": null,
      "stop_reason": null,
      "stop_sequence": null,
      "stop_details": null,
      "usage": {
        "input_tokens": 24,
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "cache_creation": {
          "ephemeral_5m_input_tokens": 0,
          "ephemeral_1h_input_tokens": 0
        },
        "output_tokens": 2,
        "service_tier": "standard",
        "inference_geo": "global"
      }
    }
  },
  {
    "type": "content_block_start",
    "index": 0,
    "content_block": {
      "type": "thinking",
      "thinking": "",
      "signature": ""
    }
  },
  "... 169 more chunks omitted ...",
  {
    "type": "message_stop"
  }
]

Parameters

▶messages[]

arrayrequired

max_tokens

numberrequiredexclusiveMinimum: 0

system

string

stream

boolean

▶metadata{}

object

▶thinking{}

object

▶output_config{}

object

▶tool_choice

one of

▶tools[]

array

id

string

type

stringconst: message

role

stringconst: assistant

▶content[]

array

model

string

stop_reason

string

▶usage{}

object

API Schemas (Raw)

Input Open Download

Output Open Download

Was this helpful?

YesNo

On this page

Claude Opus 5.5·续 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/anthropic/claude-opus-5.5/#page","headline":"Claude Opus 5.5","description":"Claude Opus 5.5 is Anthropic's model for long-running agentic coding and knowledge work. It combines a one million token context window with adaptive thinking that is always on, a 128K token maximum output, and a medium default effort level.","url":"https://developers.cloudflare.com/ai/models/anthropic/claude-opus-5.5/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Claude Sonnet 4.5 is the best coding model to date, with significant improvements across the entire development lifecycle. title: Claude Sonnet 4.5 image: https://developers.cloudflare.com/og-docs.png


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt
Use this file to discover all available pages before exploring further.

Anthropic logo