Claude Opus 5
Text Generation • Anthropic
anthropic/claude-opus-5
- Third-party
Claude Opus 5 is Anthropic's model for complex agentic coding and enterprise work, delivering intelligence close to Claude Fable 5 at half the price. It uses adaptive thinking to calibrate reasoning per task and supports a one million token context window at standard pricing. Unlike Fable 5, Opus 5 has no data retention requirements for general access.
| Model Info | |
|---|---|
| Context Window ↗ | 1,000,000 tokens |
| Terms and License | link ↗ |
| More information | link ↗ |
| Request formats | Anthropic Messages |
| Pricing | <ul><li>Input (per 1M tokens)$5.00</li><li>Output (per 1M tokens)$25.00</li><li>Cached input (per 1M tokens)$0.50</li><li>Cache creation (per 1M tokens)$6.25</li></ul> |
Usage
const response = await env.AI.run(
'anthropic/claude-opus-5',
{
max_tokens: 1024,
messages: [{ content: 'What are the three laws of thermodynamics?', role: 'user' }],
},
)
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",
"max_tokens": 1024,
"messages": [
{
"content": "What are the three laws of thermodynamics?",
"role": "user"
}
]
}'
The laws of thermodynamics describe how energy and heat behave in physical systems. Here are the three (plus a bonus fourth that was added later but numbered "zeroth").
**First Law — Conservation of Energy**
Energy cannot be created or destroyed, only transferred or converted between forms. For a closed system, the change in internal energy equals the heat added minus the work done by the system:
ΔU = Q − W
Practical implication: there's no such thing as a perpetual motion machine that produces energy from nothing.
**Second Law — Entropy Increases**
The total entropy (disorder, or more precisely the number of accessible microscopic states) of an isolated system never decreases over time. Equivalent formulations:
- Heat flows spontaneously from hot to cold, never the reverse
- No heat engine can convert heat entirely into work — some is always lost to a cold reservoir
- Processes have a preferred direction in time
This law is why engines have efficiency limits (the Carnot limit) and why it's often described as giving time its "arrow."
**Third Law — Absolute Zero is Unreachable**
As a system's temperature approaches absolute zero (0 K, −273.15 °C), its entropy approaches a constant minimum — zero for a perfect crystal. A consequence is that no finite number of steps can cool something all the way to absolute zero; you can only get asymptotically closer.
**Zeroth Law — Thermal Equilibrium**
If system A is in thermal equilibrium with system C, and B is also in equilibrium with C, then A and B are in equilibrium with each other. This is what makes temperature a meaningful, measurable property — it's the basis for thermometers. It was formalized after the other three, hence the odd numbering.
A common informal summary: *you can't win (1st), you can't break even (2nd), and you can't get out of the game (3rd).*
{
"id": "msg_011CdMcWsWTt6YQBsVgBJKET",
"type": "message",
"role": "assistant",
"content": [
{
"type": "thinking",
"thinking": "",
"signature": "CAIS+wkKhwEIEBgCKkCQkqK6v16N37+5nxwsLhxrzfCzIPF8EtZFUMp15QDBKBAUGSIu2rqp+X6/Hi8Ul8I6R5cRA5sW1cubAR0uFsttMg1jbGF1ZGUtb3B1cy01OAFCCHRoaW5raW5nWiQ5ODY2MTIzNC03NmUwLTRlMGQtYTgyMS1iZThmOGMzNDc0ZDYSDBjGGGXscwelkjSVsRoM76EmL+Pl2dtvcTfkIjBy2Ayh9NZsLWod+geEtrv0CZx22kjdWmRHFED/zy3kvHn4eM1OJrP3lhPjNTckDU0qoAh+2jG1EqZNl6grp923Shc5W4S3srKv4zy7w4z6n150KajRAZSSpC/BYrGJb6lq6nVEsgjvnrOHIeF3mq1Y3/3rPJ346UB5iJRwP+rpm6lA4LkUVQZZGYeKqUhplIEMOdQdajx2iPjmTMTV0DjdiB0bHWA776a1SXuK5VjTpcnn77iwz8okVSbhqL6annDIiWET5Z9kHhjuqHhxdAXMeGkmYWbD2i0ttDdpaHgmrvW0FRYHDEDSQr/zUT6sXgke+AIG/jWwe5SmqZIIlHhOHufoW549PnXx/W6fkiiu/sNwYL85/3toWXePQkDKnD4GEFClcdCHVOEdOh45aC7XxtRwSMTBtRDz5DeAQvHwosoZoM/dJYru0s00EkG9pAq7I15ED7XTtJkUCE61wMdqifXkOSsAHbKxH6nJemHfSpS+14jaAZdWydahPq1j8wJVppQ1KC73HJZJ1wgKHT2ZCT1WlV9FuE+hmqp13NUirZRe+o7DEJiNSenND0L1GZ13FWFXiFFSXMQiAwDJTk4yWk8cLCGt45dFtAW/m8QoKKxcx+JctfpE21IMKnOG9mPJjvUdNsP3s5bk3ZkD2dcpbv4jfdJsZdz7DqNnR0tQS0TGFAc+hBuYM0ftPJlfyhKlwpi227CIVmhlxKKAUkODCMrdjevZhyJ/JZKbAJ2yzGQ2TaLxlmkbhM4XH0RBaQ+ALv5tg+oNZ0vA9OA5uKwbN9u9yKDq7hYBQeSatyPoJ+pGxEoeGeFOP4bZHvOplm/5V67E90HzDf0k/EVvjkj0P5nqVHsUb9N6IYNkMPdsNAAenNWBNk3Z8kW1xGxRw/JXZGKUr1Ql6nD5dUMw3DIDKG1c1+8QPaata4WzR/zMO8+btn3VObUDjekjC72bKMfsAjMMkX7dWYojE94Hg2rAFRQ20hmbjYDAwt8x/k8LD8bGBa/xw5WHY1Fa64r5YvJgK98sCtJbo68axk6/Tf8AgnzwVzjDugI+pQJ2oAoC22iqQQVzTwmsoLnqi9i3F/fe9wHqITf+jGytEfT0AG73R9dFD73mac0QVIbWXkm8Weld3twIvtzC3W0IPb2v1rhQkRCCJM/s6IBvRP2N0PIwCE2oexDeW+rw59vL8d/tsZ1Woogo1+76ldngoeLF4rEV4VjfP22rTN6ZLcfnerdYbF1lDXfQhTHgs+4LvMuHfYX8lMIq/wJssPyIpnXhXtmxgd9/ce2OInU3dUHXqISUHXIeiHeDxglxblzSK9B0rAzk1UaVJn4PMNGF3M1wguw6i9AAx8s+1AU5hLOinfZ166Az9HUYz/uHkQ6d0JYRx5L6xHXaWXF51ZifLRtfoeNqLdHGKxrfjSNQK8Ouuce7SzLMGi4YH5W2rED1XmpwI69xXnssHuQKHqt7ggSV5P26e5EYAQ=="
},
{
"type": "text",
"text": "The laws of thermodynamics describe how energy and heat behave in physical systems. Here are the three (plus a bonus fourth that was added later but numbered \"zeroth\").\n\n**First Law — Conservation of Energy**\nEnergy cannot be created or destroyed, only transferred or converted between forms. For a closed system, the change in internal energy equals the heat added minus the work done by the system:\n\nΔU = Q − W\n\nPractical implication: there's no such thing as a perpetual motion machine that produces energy from nothing.\n\n**Second Law — Entropy Increases**\nThe total entropy (disorder, or more precisely the number of accessible microscopic states) of an isolated system never decreases over time. Equivalent formulations:\n\n- Heat flows spontaneously from hot to cold, never the reverse\n- No heat engine can convert heat entirely into work — some is always lost to a cold reservoir\n- Processes have a preferred direction in time\n\nThis law is why engines have efficiency limits (the Carnot limit) and why it's often described as giving time its \"arrow.\"\n\n**Third Law — Absolute Zero is Unreachable**\nAs a system's temperature approaches absolute zero (0 K, −273.15 °C), its entropy approaches a constant minimum — zero for a perfect crystal. A consequence is that no finite number of steps can cool something all the way to absolute zero; you can only get asymptotically closer.\n\n**Zeroth Law — Thermal Equilibrium**\nIf system A is in thermal equilibrium with system C, and B is also in equilibrium with C, then A and B are in equilibrium with each other. This is what makes temperature a meaningful, measurable property — it's the basis for thermometers. It was formalized after the other three, hence the odd numbering.\n\nA common informal summary: *you can't win (1st), you can't break even (2nd), and you can't get out of the game (3rd).*"
}
],
"model": "claude-opus-5",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 20,
"output_tokens": 969,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
},
"stop_sequence": null,
"stop_details": null,
"gatewayMetadata": {
"keySource": "Unified"
}
}
Examples
<details>
<summary>With System Message — Using a system message to set context</summary>
const response = await env.AI.run(
'anthropic/claude-opus-5',
{
max_tokens: 2048,
messages: [{ content: 'How do I read a JSON file in Python?', role: 'user' }],
system: 'You are a helpful coding assistant specializing in Python.',
},
)
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",
"max_tokens": 2048,
"messages": [
{
"content": "How do I read a JSON file in Python?",
"role": "user"
}
],
"system": "You are a helpful coding assistant specializing in Python."
}'
````
Reading JSON Files in Python
Python's built-in json module handles this. The key function is json.load().
The basic pattern
import json
with open("data.json", "r", encoding="utf-8") as f:
data = json.load(f)
print(data)
That's it. json.load() reads from a file object; the with statement ensures the file gets closed even if something goes wrong.
load() vs loads()
This trips people up constantly:
| Function | Input | Use when |
|---|---|---|
json.load(f) |
file object | reading from a file |
json.loads(s) |
string (or bytes) | you already have JSON text |
```python
