{ "model_id": "anthropic/claude-opus-5", "provider_id": "anthropic", "name": "Claude Opus 5", "description": "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.", "task": "Text Generation", "tags": [ "LLM", "Coding", "Reasoning", "Enterprise", "Agentic", "Financial Analysis", "Legal" ], "context_length": 1000000, "max_output_tokens": 128000, "schema_version": "1.0.0", "pricing": { "Input tokens (per 1M)": 5, "Cached input tokens (per 1M)": 0.5, "Cache creation tokens (per 1M)": 6.25, "Output tokens (per 1M)": 25 }, "examples": [ { "name": "Simple Question", "description": "Basic message request", "input": { "max_tokens": 1024, "messages": [ { "content": "What are the three laws of thermodynamics?", "role": "user" } ] }, "output": { "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 \u2014 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\u0394U = Q \u2212 W\n\nPractical implication: there's no such thing as a perpetual motion machine that produces energy from nothing.\n\n**Second Law \u2014 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 \u2014 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 \u2014 Absolute Zero is Unreachable**\nAs a system's temperature approaches absolute zero (0 K, \u2212273.15 \u00b0C), its entropy approaches a constant minimum \u2014 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 \u2014 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 \u2014 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).*" }, "raw_response": { "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 \u2014 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\u0394U = Q \u2212 W\n\nPractical implication: there's no such thing as a perpetual motion machine that produces energy from nothing.\n\n**Second Law \u2014 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 \u2014 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 \u2014 Absolute Zero is Unreachable**\nAs a system's temperature approaches absolute zero (0 K, \u2212273.15 \u00b0C), its entropy approaches a constant minimum \u2014 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 \u2014 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 \u2014 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" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'anthropic/claude-opus-5',\n {\n max_tokens: 1024,\n messages: [{ content: 'What are the three laws of thermodynamics?', role: 'user' }],\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/messages \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"anthropic/claude-opus-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"What are the three laws of thermodynamics?\",\n \"role\": \"user\"\n }\n ]\n}'" } ] }, { "name": "With System Message", "description": "Using a system message to set context", "input": { "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." }, "output": { "text": "# Reading JSON Files in Python\n\nPython's built-in `json` module handles this. The key function is `json.load()`.\n\n## The basic pattern\n\n```python\nimport json\n\nwith open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\n\nprint(data)\n```\n\nThat's it. `json.load()` reads from a file object; the `with` statement ensures the file gets closed even if something goes wrong.\n\n## `load()` vs `loads()`\n\nThis trips people up constantly:\n\n| Function | Input | Use when |\n|---|---|---|\n| `json.load(f)` | file object | reading from a file |\n| `json.loads(s)` | string (or bytes) | you already have JSON text |\n\n```python\n# From a string\ntext = '{\"name\": \"Ada\", \"age\": 36}'\ndata = json.loads(text)\n\n# Equivalent to the file version\nwith open(\"data.json\", encoding=\"utf-8\") as f:\n data = json.loads(f.read()) # works, but load(f) is cleaner\n```\n\n## What you get back\n\nJSON types map to Python types like this:\n\n```\nobject -> dict\narray -> list\nstring -> str\nnumber -> int / float\ntrue -> True\nfalse -> False\nnull -> None\n```\n\nSo access it like any nested dict/list:\n\n```python\n# data.json: {\"users\": [{\"name\": \"Ada\", \"roles\": [\"admin\"]}]}\ndata[\"users\"][0][\"name\"] # \"Ada\"\ndata[\"users\"][0][\"roles\"][0] # \"admin\"\n```\n\nUse `.get()` for keys that might be missing:\n\n```python\nemail = data[\"users\"][0].get(\"email\", \"unknown\")\n```\n\n## Handling errors properly\n\nReal-world files are messy. Catch the two things that actually go wrong:\n\n```python\nimport json\nfrom pathlib import Path\n\ndef read_json(path):\n try:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return json.load(f)\n except FileNotFoundError:\n print(f\"No such file: {path}\")\n except json.JSONDecodeError as e:\n print(f\"Invalid JSON in {path} at line {e.lineno}, column {e.colno}: {e.msg}\")\n return None\n\ndata = read_json(\"data.json\")\n```\n\n`JSONDecodeError` is a subclass of `ValueError`, and it carries `lineno`, `colno`, and `pos` \u2014 genuinely useful for pinpointing a bad comma.\n\n## Using `pathlib` (slightly tidier)\n\n```python\nimport json\nfrom pathlib import Path\n\ndata = json.loads(Path(\"data.json\").read_text(encoding=\"utf-8\"))\n```\n\n## Common gotchas\n\n**Always specify `encoding=\"utf-8\"`.** Without it, Python uses the platform default, which on some Windows setups is cp1252 and will blow up on non-ASCII characters. JSON is UTF-8 by spec.\n\n**JSON Lines (`.jsonl`) is a different format.** One JSON object per line \u2014 `json.load()` will fail. Parse line by line:\n\n```python\nwith open(\"data.jsonl\", encoding=\"utf-8\") as f:\n records = [json.loads(line) for line in f if line.strip()]\n```\n\n**Trailing commas and comments aren't valid JSON.** `{\"a\": 1,}` or `// comment` will raise `JSONDecodeError`. If you're stuck with such files, use the `json5` or `commentjson` package.\n\n**Huge files:** `json.load()` builds the whole structure in memory. For files that don't fit, use a streaming parser like [`ijson`](https://pypi.org/project/ijson/):\n\n```python\nimport ijson\n\nwith open(\"huge.json\", \"rb\") as f:\n for record in ijson.items(f, \"users.item\"):\n process(record)\n```\n\n## Writing it back out\n\nFor completeness:\n\n```python\nwith open(\"out.json\", \"w\", encoding=\"utf-8\") as f:\n json.dump(data, f, indent=2, ensure_ascii=False)\n```\n\n`indent=2` makes it human-readable; `ensure_ascii=False` keeps non-ASCII characters as-is instead of escaping them to `\\uXXXX`." }, "raw_response": { "id": "msg_011CdMcXtLbe6orhyjErTMK4", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "", "signature": "CAISlgMKhwEIEBgCKkAMw2x29hUCKlXqNB76pH+D/yqNHzKCZSWl13/1q5MvcRHqGBsMYVt5OPNJRBpoK96H4yBdLeYFynRrC3brOl8VMg1jbGF1ZGUtb3B1cy01OAFCCHRoaW5raW5nWiQ5ODY2MTIzNC03NmUwLTRlMGQtYTgyMS1iZThmOGMzNDc0ZDYSDPHl470mvTSS/VVloBoMjuO0rbloh1ffzl7/IjCQVDk88te+JO4ShyaKbxvx7tByViz6N6zO3AnWMoRShuVZmByIC9M123krmAR3d0squwH0oba6v809aPGBRis6zXZjjkxj9xUPeK9bIiAs2F4LqShktrO0enUaJGxlcocxt2tmwdkC5SF7XOy5lKpcBDf6XvOTeaV0bYyxgAQ6L2FkiOU9NtnSGiZZ0VmKz2v8RZ9nVisaD6kA15+UOqX8SO5ZYny+Ttrgue6Cx5DJ7MfBcRcE6SsSsuyLnrRFY1S7XNsCcd0lY1rv1CzkYOnItoxD6fDWab8uxQGGXWBhUnSy4XxtZ0+TR/2fRTuXGAE=" }, { "type": "text", "text": "# Reading JSON Files in Python\n\nPython's built-in `json` module handles this. The key function is `json.load()`.\n\n## The basic pattern\n\n```python\nimport json\n\nwith open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\n\nprint(data)\n```\n\nThat's it. `json.load()` reads from a file object; the `with` statement ensures the file gets closed even if something goes wrong.\n\n## `load()` vs `loads()`\n\nThis trips people up constantly:\n\n| Function | Input | Use when |\n|---|---|---|\n| `json.load(f)` | file object | reading from a file |\n| `json.loads(s)` | string (or bytes) | you already have JSON text |\n\n```python\n# From a string\ntext = '{\"name\": \"Ada\", \"age\": 36}'\ndata = json.loads(text)\n\n# Equivalent to the file version\nwith open(\"data.json\", encoding=\"utf-8\") as f:\n data = json.loads(f.read()) # works, but load(f) is cleaner\n```\n\n## What you get back\n\nJSON types map to Python types like this:\n\n```\nobject -> dict\narray -> list\nstring -> str\nnumber -> int / float\ntrue -> True\nfalse -> False\nnull -> None\n```\n\nSo access it like any nested dict/list:\n\n```python\n# data.json: {\"users\": [{\"name\": \"Ada\", \"roles\": [\"admin\"]}]}\ndata[\"users\"][0][\"name\"] # \"Ada\"\ndata[\"users\"][0][\"roles\"][0] # \"admin\"\n```\n\nUse `.get()` for keys that might be missing:\n\n```python\nemail = data[\"users\"][0].get(\"email\", \"unknown\")\n```\n\n## Handling errors properly\n\nReal-world files are messy. Catch the two things that actually go wrong:\n\n```python\nimport json\nfrom pathlib import Path\n\ndef read_json(path):\n try:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return json.load(f)\n except FileNotFoundError:\n print(f\"No such file: {path}\")\n except json.JSONDecodeError as e:\n print(f\"Invalid JSON in {path} at line {e.lineno}, column {e.colno}: {e.msg}\")\n return None\n\ndata = read_json(\"data.json\")\n```\n\n`JSONDecodeError` is a subclass of `ValueError`, and it carries `lineno`, `colno`, and `pos` \u2014 genuinely useful for pinpointing a bad comma.\n\n## Using `pathlib` (slightly tidier)\n\n```python\nimport json\nfrom pathlib import Path\n\ndata = json.loads(Path(\"data.json\").read_text(encoding=\"utf-8\"))\n```\n\n## Common gotchas\n\n**Always specify `encoding=\"utf-8\"`.** Without it, Python uses the platform default, which on some Windows setups is cp1252 and will blow up on non-ASCII characters. JSON is UTF-8 by spec.\n\n**JSON Lines (`.jsonl`) is a different format.** One JSON object per line \u2014 `json.load()` will fail. Parse line by line:\n\n```python\nwith open(\"data.jsonl\", encoding=\"utf-8\") as f:\n records = [json.loads(line) for line in f if line.strip()]\n```\n\n**Trailing commas and comments aren't valid JSON.** `{\"a\": 1,}` or `// comment` will raise `JSONDecodeError`. If you're stuck with such files, use the `json5` or `commentjson` package.\n\n**Huge files:** `json.load()` builds the whole structure in memory. For files that don't fit, use a streaming parser like [`ijson`](https://pypi.org/project/ijson/):\n\n```python\nimport ijson\n\nwith open(\"huge.json\", \"rb\") as f:\n for record in ijson.items(f, \"users.item\"):\n process(record)\n```\n\n## Writing it back out\n\nFor completeness:\n\n```python\nwith open(\"out.json\", \"w\", encoding=\"utf-8\") as f:\n json.dump(data, f, indent=2, ensure_ascii=False)\n```\n\n`indent=2` makes it human-readable; `ensure_ascii=False` keeps non-ASCII characters as-is instead of escaping them to `\\uXXXX`." } ], "model": "claude-opus-5", "stop_reason": "end_turn", "usage": { "input_tokens": 38, "output_tokens": 1398, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 }, "stop_sequence": null, "stop_details": null, "gatewayMetadata": { "keySource": "Unified" } }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'anthropic/claude-opus-5',\n {\n max_tokens: 2048,\n messages: [{ content: 'How do I read a JSON file in Python?', role: 'user' }],\n system: 'You are a helpful coding assistant specializing in Python.',\n },\n)\nconsole.log(response)" }, { "label": "curl", "language": "bash", "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/messages \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"anthropic/claude-opus-5\",\n \"max_tokens\": 2048,\n \"messages\": [\n {\n \"content\": \"How do I read a JSON file in Python?\",\n \"role\": \"user\"\n }\n ],\n \"system\": \"You are a helpful coding assistant specializing in Python.\"\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": false, "zdr_comment": null, "external_info": "https://www.anthropic.com/claude/opus", "terms": "https://www.anthropic.com/legal/commercial-terms", "cover_image_url": null, "metadata": { "Adaptive Thinking": "Yes", "Architecture": "Transformer", "fedrampAvailable": "true" }, "request_formats": [ "anthropic-messages" ], "providers": null, "provider_details": [ { "id": "anthropic", "pricing": { "input_tokens": 5, "input_cached_tokens": 0.5, "input_cache_creation_tokens": 6.25, "output_tokens": 25 } } ], "banner": null, "created_at": "2026-07-24 19:36:01", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "enum": [ "user", "assistant", "system" ] }, "content": { "anyOf": [ { "type": "string" }, { "type": "array", "items": { "type": "object", "properties": { "type": { "type": "string" }, "text": { "type": "string" }, "source": {}, "cache_control": { "type": "object", "properties": { "type": { "type": "string", "const": "ephemeral" }, "ttl": { "type": "string", "enum": [ "5m", "1h" ] } }, "required": [ "type" ], "additionalProperties": false } }, "required": [ "type" ], "additionalProperties": {} } } ] } }, "required": [ "role", "content" ], "additionalProperties": false } }, "max_tokens": { "type": "number", "exclusiveMinimum": 0 }, "system": { "anyOf": [ { "type": "string" }, { "type": "array", "items": { "type": "object", "properties": { "type": { "type": "string", "const": "text" }, "text": { "type": "string" }, "cache_control": { "type": "object", "properties": { "type": { "type": "string", "const": "ephemeral" }, "ttl": { "type": "string", "enum": [ "5m", "1h" ] } }, "required": [ "type" ], "additionalProperties": false } }, "required": [ "type", "text" ], "additionalProperties": {} } } ] }, "stream": { "type": "boolean" }, "metadata": { "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": {} } }, "required": [ "messages", "max_tokens" ], "additionalProperties": {} }, "output": { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string", "const": "message" }, "role": { "type": "string", "const": "assistant" }, "content": { "type": "array", "items": { "type": "object", "properties": { "type": { "type": "string" }, "text": { "type": "string" } }, "required": [ "type" ], "additionalProperties": {} } }, "model": { "type": "string" }, "stop_reason": { "type": [ "string", "null" ] }, "usage": { "type": "object", "properties": { "input_tokens": { "type": "number" }, "output_tokens": { "type": "number" }, "cache_creation_input_tokens": { "type": [ "number", "null" ] }, "cache_read_input_tokens": { "type": [ "number", "null" ] }, "speed": { "type": [ "string", "null" ] } }, "required": [ "input_tokens", "output_tokens" ], "additionalProperties": {} } }, "required": [ "id", "type", "role", "content", "model", "stop_reason", "usage" ], "additionalProperties": {} } } }