{ "model_id": "anthropic/claude-fable-5.2", "provider_id": "anthropic", "name": "Claude Fable 5.2", "description": "Claude Fable 5.2 is built for demanding reasoning and long-horizon agentic work, with adaptive thinking, a 1M token context window, and up to 128K output tokens.", "task": "Text Generation", "tags": [ "LLM", "Coding", "Reasoning", "Enterprise", "Agentic" ], "context_length": 1000000, "max_output_tokens": 128000, "schema_version": "1.0.0", "pricing": { "Input tokens (per 1M)": 8, "Cached input tokens (per 1M)": 0.2, "Cache creation tokens (per 1M)": 10, "Output tokens (per 1M)": 40 }, "examples": [ { "name": "With System Message", "description": "Set context with a system message", "input": { "max_tokens": 1024, "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": "Use the built-in `json` module:\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\n`json.load()` parses the file into Python objects: JSON objects become `dict`s, arrays become `list`s, and strings, numbers, booleans, and `null` become `str`, `int`/`float`, `bool`, and `None`.\n\n**Accessing the data**\n\n```python\n# Given: {\"name\": \"Alice\", \"skills\": [\"Python\", \"SQL\"]}\nprint(data[\"name\"]) # Alice\nprint(data[\"skills\"][0]) # Python\n```\n\n**Handling common errors**\n\n```python\nimport json\n\ntry:\n with open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\nexcept FileNotFoundError:\n print(\"File not found.\")\nexcept json.JSONDecodeError as e:\n print(f\"Invalid JSON: {e}\")\n```\n\n**Tips**\n\n- Use `json.load(f)` for a file object and `json.loads(s)` for a string.\n- To write JSON back to a file, use `json.dump(data, f, indent=2)`.\n- If your file has one JSON object per line (JSON Lines, `.jsonl`), parse it line by line:\n\n ```python\n with open(\"data.jsonl\", encoding=\"utf-8\") as f:\n records = [json.loads(line) for line in f]\n ```" }, "raw_response": { "model": "claude-fable-5-2", "id": "msg_011CgsuBy7YD3SdLFBeFswvH", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "", "signature": "CAQSrwUKEAgTGAI4AUIIdGhpbmtpbmcSDKSIJLl+xWkT9SHrMxoMG4TBjLreVuPOFLKpIjCmvEYg45oRWbtnwo7Cl4w2BAnhnuajXGMmXrEtS0oZqlgNyoiMoDdPeNnC0XlLKyQqzARe2l67RwLuKchg1RsCy5Src7C+V+Tz52I2UkHz3vbKNDxC5KgEkj7V7X7golGAUf6Tcx0gUBLbyQiqJBuyWLqcKieM/QfcWaMoNbJ4VtS5sXZiD3pAl2EPkJh4e/E4Yppq4O/MjMlKlTg5lxwWJ4bpDP1qyMFbmAQM7EfDByWKaRZap+1lPYm7f7JKLtTZM+5Q+b/LNWAF1d5UkaQPbX485JjiQNX2GNqxGoAg/IAypOjp3U5FQP9OIj+HGXtQOIArV/eBqrQUgQu6En0ecOFxAv6kIHM0MSaLb3V3cLmBqAPCzf4+PEYqYUrO9wZ75nxvl6QZConTpPW+llA8v2181t7mpkMT6Z5Gspj6r50jNMDqwj0IASz/38cpBcvao5ao7C2QoK3aDuJBXsilfIeZzhmj0NTstS4Y2B3VhkzVuWrbJIosJ7dnfCCuAQUbha3VS2DZ43Hmv4tvMZ2Sx/1vGLZ1Wou7QhmWXsOWj9ncLfir3FGT0NuQy+AqLLW/lZzzjvoOcj29LpRSUwg8rmFNak2ljC66IbmD8fBmuk58BVzDiYJU/uj9796ApVZ8Azk2JXd0uSEMyFJXpUxuetqkV8+gm6Hn0oVvuml+YYCpSci7GxTpf8hY5d22vgepSx2Nhx+icIbdXzOPjdLpgoai1i/vMRZ9iXwjed//0ExsQlpV/6e4h+OtiT7XZTBo3IaRfDOYQnIHB1q4VUtSBk0YJPtqiI3h8D62dJ/1Qw7D8RFBfQjgyp1JaSVMTlH+Jf98Zki8LA4oiSEnO+cYAQ==" }, { "type": "text", "text": "Use the built-in `json` module:\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\n`json.load()` parses the file into Python objects: JSON objects become `dict`s, arrays become `list`s, and strings, numbers, booleans, and `null` become `str`, `int`/`float`, `bool`, and `None`.\n\n**Accessing the data**\n\n```python\n# Given: {\"name\": \"Alice\", \"skills\": [\"Python\", \"SQL\"]}\nprint(data[\"name\"]) # Alice\nprint(data[\"skills\"][0]) # Python\n```\n\n**Handling common errors**\n\n```python\nimport json\n\ntry:\n with open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\nexcept FileNotFoundError:\n print(\"File not found.\")\nexcept json.JSONDecodeError as e:\n print(f\"Invalid JSON: {e}\")\n```\n\n**Tips**\n\n- Use `json.load(f)` for a file object and `json.loads(s)` for a string.\n- To write JSON back to a file, use `json.dump(data, f, indent=2)`.\n- If your file has one JSON object per line (JSON Lines, `.jsonl`), parse it line by line:\n\n ```python\n with open(\"data.jsonl\", encoding=\"utf-8\") as f:\n records = [json.loads(line) for line in f]\n ```" } ], "container": null, "stop_reason": "end_turn", "stop_sequence": null, "stop_details": null, "usage": { "input_tokens": 40, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "cache_creation": { "ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0 }, "output_tokens": 491, "output_tokens_details": { "thinking_tokens": 24 }, "service_tier": "standard", "inference_geo": "global", "speed": "standard" }, "diagnostics": null }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'anthropic/claude-fable-5.2',\n {\n max_tokens: 1024,\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-fable-5.2\",\n \"max_tokens\": 1024,\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}'" } ] }, { "name": "Multi-turn Conversation", "description": "Continue a conversation with prior assistant context", "input": { "max_tokens": 1024, "messages": [ { "content": "I need help planning a road trip from San Francisco to Los Angeles.", "role": "user" }, { "content": "I'd be happy to help! The drive is about 380 miles and takes roughly 5-6 hours. Would you like suggestions for scenic routes or interesting stops along the way?", "role": "assistant" }, { "content": "Yes, what are some good places to stop?", "role": "user" } ] }, "output": { "text": "The best stops depend on which route you take.\n\n**Highway 1 along the coast (9-10 hours of driving, best split over two days)**\n\nThis is the scenic route. From north to south:\n\n- **Santa Cruz**: a classic beach boardwalk and a good first coffee stop.\n- **Monterey and Carmel**: the Monterey Bay Aquarium, Cannery Row, and Carmel's walkable village and beach.\n- **Big Sur**: the highlight of the drive, with Bixby Bridge, McWay Falls, and Pfeiffer Beach.\n- **San Simeon**: Hearst Castle tours (book ahead) and the elephant seal rookery, which is free and right off the highway.\n- **Morro Bay and San Luis Obispo**: good places to stay overnight, with solid food in downtown SLO.\n- **Santa Barbara**: the Spanish mission, State Street, and the waterfront.\n- **Malibu**: a last beach stop before LA, such as El Matador or Zuma.\n\nCheck Caltrans road conditions before you go, because the Big Sur stretch of Highway 1 sometimes closes for landslides.\n\n**US-101 (about 7 hours)**\n\nThis is a middle ground. It skips Big Sur but still passes through San Luis" }, "raw_response": { "model": "claude-fable-5-2", "id": "msg_011CgsuCQmtMxj7JPEhCLZZq", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "", "signature": "CAQSzA8KEAgTGAI4AUIIdGhpbmtpbmcSDCKAuQ5IWOEHmUrb0BoMjvQ5bNM4n7i+ILKrIjAncoSGfyb5wwdM7xljs9+UvAJLxdZ/c36A3yBGLb4K/5zHQ5Z5NdpqPkKWdRqapmcq6Q4kMfjWRNxcIPgOzeysnqgFwx3K+1C4/BB3KXZO7xVGajsbkKyAHJtL6M0u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MdJbFyvHvjaIhG+r8bvXbebBQnwdbyZfxXcZonLW5YwvM/oNssKsZndPSY9E2e3Fg97zs9w2mEzqZN1AxrK7u1VioK0GuDtrAHlvElHyOgyThy77rIsn21ZajU89fjzd2ENML560DTbiFKemCSbiS2IK8FHpmIR28Gi/5a0mgh7GxUUjbpmoPtJjo2NPiuNxaWdVt4PN7WKT8KW/Ts1iD6pR3b4HIruWOE+36EChU/6CvV/tHYDJfarCNwYrWmpRqmufuHCvqm1McYZbU8PaSvg8cilWLYZCKNQ/muNSDzGAE=" }, { "type": "text", "text": "The best stops depend on which route you take.\n\n**Highway 1 along the coast (9-10 hours of driving, best split over two days)**\n\nThis is the scenic route. From north to south:\n\n- **Santa Cruz**: a classic beach boardwalk and a good first coffee stop.\n- **Monterey and Carmel**: the Monterey Bay Aquarium, Cannery Row, and Carmel's walkable village and beach.\n- **Big Sur**: the highlight of the drive, with Bixby Bridge, McWay Falls, and Pfeiffer Beach.\n- **San Simeon**: Hearst Castle tours (book ahead) and the elephant seal rookery, which is free and right off the highway.\n- **Morro Bay and San Luis Obispo**: good places to stay overnight, with solid food in downtown SLO.\n- **Santa Barbara**: the Spanish mission, State Street, and the waterfront.\n- **Malibu**: a last beach stop before LA, such as El Matador or Zuma.\n\nCheck Caltrans road conditions before you go, because the Big Sur stretch of Highway 1 sometimes closes for landslides.\n\n**US-101 (about 7 hours)**\n\nThis is a middle ground. It skips Big Sur but still passes through San Luis" } ], "container": null, "stop_reason": "max_tokens", "stop_sequence": null, "stop_details": null, "usage": { "input_tokens": 105, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "cache_creation": { "ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0 }, "output_tokens": 1024, "output_tokens_details": { "thinking_tokens": 604 }, "service_tier": "standard", "inference_geo": "global", "speed": "standard" }, "diagnostics": null }, "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'anthropic/claude-fable-5.2',\n {\n max_tokens: 1024,\n messages: [\n {\n content: 'I need help planning a road trip from San Francisco to Los Angeles.',\n role: 'user',\n },\n {\n content:\n \"I'd be happy to help! The drive is about 380 miles and takes roughly 5-6 hours. Would you like suggestions for scenic routes or interesting stops along the way?\",\n role: 'assistant',\n },\n { content: 'Yes, what are some good places to stop?', role: 'user' },\n ],\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-fable-5.2\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"I need help planning a road trip from San Francisco to Los Angeles.\",\n \"role\": \"user\"\n },\n {\n \"content\": \"I'\\''d be happy to help! The drive is about 380 miles and takes roughly 5-6 hours. Would you like suggestions for scenic routes or interesting stops along the way?\",\n \"role\": \"assistant\"\n },\n {\n \"content\": \"Yes, what are some good places to stop?\",\n \"role\": \"user\"\n }\n ]\n}'" } ] }, { "name": "Streaming Response", "description": "Stream a response for real-time output", "input": { "max_tokens": 1024, "messages": [ { "content": "Explain the concept of recursion with a simple example.", "role": "user" } ], "stream": true }, "output": { "text": [ "Recursion is when", " a function sol", "ves a problem by calling it", "self on a smaller version of", " the same problem, until the", " problem is small", " enough to answ", "er directly.\n\nEvery rec", "ursive function need", "s two parts:\n\n1", ". **Base case:", "** a simple input", " that it", " answers directly, without", " calling itself. This", " stops the recursion.", "\n2. **Recursive case", ":** the function calls itself", " with an", " input that", " moves closer to the base case", ".\n\n## Example: factor", "ial\n\nThe factorial of a", " number `", "n` (written `n!`", ") is the product of all", " wh", "ole numbers from 1 ", "to `n`. For example,", " `4! = 4", " \u00d7 3 \u00d7 2", " \u00d7 1 = 24", "`.", "\n\nNotice that `4! = ", "4 \u00d7 3!`,", " and `3! = 3 ", "\u00d7 2!`, and so", " on. The problem cont", "ains a", " smaller cop", "y of itself, which makes", " it a nat", "ural fit for recursion:", "\n\n```python\ndef factorial", "(n):\n if n <", "= 1: # base case", "\n return 1\n return", " n * factorial(n -", " 1) # recursive", " case\n```\n\n## What happens", " when you call `factorial(", "4)`\n\nEach call wa", "its for the one", " below it to finish:\n\n```", "\nfactorial(4)", "\n=", " 4 *", " factorial(3)\n=", " 4 * (3 *", " factorial(2))\n=", " 4 * (3 *", " (2 * factorial(", "1)))\n= 4 ", "* (3 * (2 ", "* 1)) ", "\u2190 base case re", "ached,", " now the results", " multiply back up\n= ", "4 * (3 * ", "2)\n= 4 *", " 6\n= 24\n```", "\n\nWithout the base case, the", " function would call itself forever (", "in", " practice, until", " the program crashes with a st", "ack overflow error)." ] }, "raw_response": [ { "type": "message_start", "message": { "model": "claude-fable-5-2", "id": "msg_011CgsuDKd7HCjnpqvQic3mi", "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": 6, "service_tier": "standard", "inference_geo": "global", "speed": "standard" }, "diagnostics": null } }, { "type": "content_block_start", "index": 0, "content_block": { "type": "thinking", "thinking": "", "signature": "" } }, { "type": "ping" }, { "type": "content_block_delta", "index": 0, "delta": { "type": "thinking_delta", "thinking": "" } }, { "type": "content_block_delta", "index": 0, "delta": { "type": "signature_delta", "signature": "CAQSqQYKEAgTGAI4AUIIdGhpbmtpbmcSDEibGJxPDgsozaF2/BoMFxi7mSNX9tKoA3WlIjAlRA7PhHdvKEEnM5bhLd5uj0HAWC+iOOong2P8thME12SJoV004q6YpU50IzdkycQqxgXsBOH+wD8n39APiFzx7cZGtm3akRosu6riE0eOaFi5uOxzRQnZw3Zeq37tQpTIRFEzQgqj54BDyVoE5aUZbd4Lmi3pG6xdp/ZuaYjBgwZyTBOGHtceRHdVCgGemm1ZvYm9J/VsxOid5E1eOq9R1Bh9CYpUf6gnF2fJItsfVBGrxQaJm0v7fLCtTV7NmUioRbcIZnMr2KCOJca+jbeTvk2GxflgqBpSP7u/KhQBglyoUEdMy6bRvRJLEKjZ5CVzxQ6BK2Sw5rrbZUGVsTMBzBo9ZIcgUfLAS145zmTBJNJKqipG7AWJw6byD3RvlIKrE52oqF8CkFbW8OhVtzlO+4w3LR9uDpLS7XjfVQfM6bElv4ehgoTTkkFs8f4UmTADMoTF7fIwH7axxPTQuztOLc8EpohGAjou96Xbvzaw2eJuMaPUZpqaVRRXnEDuMhJ/41/g5brcivhBfVcqKISGSS+Ud34+32l9dZcbxbkE9M/CvwNukdX3KWZBPM9XXKgn59R1kSCBTkQPZArp0nMI4bJ7+BfnV3fF3k/bzFvnVd5WMzJdoRzXAtDb6wfCI+meW9KEBYVJQdf7akSwtyN9vjBD5ljMJcQihaNdwNZQ3OGITXH5WNtbyvp+m16DXoHVe7Oo4V7hFgr86yqDfjxm2AXQA3ny1IoKeIbwMN7aoy9ydQg71Ahcq/NKWljyZNVBHsWS8Fd7l7QcGRUCgaa/zFpcRJtpzhTlwSe3x00yjkC1axs853M5MiR4gkoSfZ8GdoElCtJRXrowhTAL8HPYzIx0yi4a7ks+qB9zknON/AZNMgdRa8NyxZpEQnDbATklDxvIh6FBCi95qA5b9IBHjtRFFin0hFXt3yPbBi6htz8zhorkuJsLpYk0y1wUyIVAGSlKCLHciY7ozIzMgzxusSdKLwHBBKeEwSEZolFo1z2xQlqkQdEL2xgB" } }, { "type": "content_block_stop", "index": 0 }, { "type": "content_block_start", "index": 1, "content_block": { "type": "text", "text": "" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "Recursion is when" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " a function sol" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ves a problem by calling it" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "self on a smaller version of" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " the same problem, until the" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " problem is small" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " enough to answ" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "er directly.\n\nEvery rec" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ursive function need" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "s two parts:\n\n1" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": ". **Base case:" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "** a simple input" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " that it" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " answers directly, without" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " calling itself. This" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " stops the recursion." } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n2. **Recursive case" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": ":** the function calls itself" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " with an" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " input that" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " moves closer to the base case" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": ".\n\n## Example: factor" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ial\n\nThe factorial of a" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " number `" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "n` (written `n!`" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": ") is the product of all" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " wh" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ole numbers from 1 " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "to `n`. For example," } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " `4! = 4" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " \u00d7 3 \u00d7 2" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " \u00d7 1 = 24" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "`." } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n\nNotice that `4! = " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "4 \u00d7 3!`," } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " and `3! = 3 " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\u00d7 2!`, and so" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " on. The problem cont" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ains a" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " smaller cop" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "y of itself, which makes" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " it a nat" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ural fit for recursion:" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n\n```python\ndef factorial" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "(n):\n if n <" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "= 1: # base case" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n return 1\n return" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " n * factorial(n -" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " 1) # recursive" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " case\n```\n\n## What happens" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " when you call `factorial(" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "4)`\n\nEach call wa" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "its for the one" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " below it to finish:\n\n```" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\nfactorial(4)" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n=" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " 4 *" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " factorial(3)\n=" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " 4 * (3 *" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " factorial(2))\n=" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " 4 * (3 *" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " (2 * factorial(" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "1)))\n= 4 " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "* (3 * (2 " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "* 1)) " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\u2190 base case re" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ached," } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " now the results" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " multiply back up\n= " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "4 * (3 * " } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "2)\n= 4 *" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " 6\n= 24\n```" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "\n\nWithout the base case, the" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " function would call itself forever (" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "in" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " practice, until" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": " the program crashes with a st" } }, { "type": "content_block_delta", "index": 1, "delta": { "type": "text_delta", "text": "ack overflow error)." } }, { "type": "content_block_stop", "index": 1 }, { "type": "message_delta", "delta": { "stop_reason": "end_turn", "stop_sequence": null, "stop_details": null, "container": null }, "usage": { "input_tokens": 24, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 555, "output_tokens_details": { "thinking_tokens": 60 } } }, { "type": "message_stop" } ], "code_snippets": [ { "label": "typescript", "language": "typescript", "code": "const response = await env.AI.run(\n 'anthropic/claude-fable-5.2',\n {\n max_tokens: 1024,\n messages: [{ content: 'Explain the concept of recursion with a simple example.', role: 'user' }],\n stream: true,\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-fable-5.2\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Explain the concept of recursion with a simple example.\",\n \"role\": \"user\"\n }\n ],\n \"stream\": true\n}'" } ] } ], "default_example": null, "code_snippets": [], "supports_async": false, "zdr": true, "zdr_comment": null, "external_info": "https://platform.claude.com/docs/en/models/fable-5-2/overview", "terms": "https://www.anthropic.com/legal/commercial-terms", "cover_image_url": null, "metadata": { "Adaptive Thinking": "Yes", "Architecture": "Transformer" }, "request_formats": [ "anthropic-messages" ], "providers": null, "provider_details": [ { "id": "anthropic", "pricing": { "input_tokens": 8, "input_cached_tokens": 0.2, "input_cache_creation_tokens": 10, "output_tokens": 40 } } ], "banner": null, "created_at": "2026-11-10 19:22:16", "schema": { "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", "oneOf": [ { "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": {} } } ] }, "temperature": { "type": "number", "minimum": 0, "maximum": 1 }, "top_p": { "type": "number", "minimum": 0, "maximum": 1 }, "top_k": { "type": "number", "exclusiveMinimum": 0 }, "stream": { "type": "boolean" }, "metadata": { "type": "object", "propertyNames": { "type": "string" }, "additionalProperties": {} } }, "required": [ "messages", "max_tokens" ], "additionalProperties": {}, "title": "Messages" }, { "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "role": { "type": "string", "enum": [ "system", "developer", "user", "assistant", "tool" ] }, "content": { "anyOf": [ { "type": "string" }, { "type": "null" }, { "type": "array", "items": {} } ] } }, "required": [ "role" ], "additionalProperties": {} } }, "temperature": { "type": "number", "minimum": 0, "maximum": 2 }, "max_tokens": { "type": "number", "exclusiveMinimum": 0 }, "max_completion_tokens": { "type": "number", "exclusiveMinimum": 0 }, "top_p": { "type": "number", "minimum": 0, "maximum": 1 }, "frequency_penalty": { "type": "number", "minimum": -2, "maximum": 2 }, "presence_penalty": { "type": "number", "minimum": -2, "maximum": 2 }, "stream": { "type": "boolean" }, "stream_options": { "type": "object", "properties": { "include_usage": { "type": "boolean" } }, "additionalProperties": false }, "tools": { "type": "array", "items": {} }, "tool_choice": {}, "response_format": {}, "modalities": { "type": "array", "items": { "type": "string", "enum": [ "text", "audio" ] } }, "audio": { "type": "object", "properties": { "voice": { "type": "string", "enum": [ "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse" ] }, "format": { "type": "string", "enum": [ "wav", "mp3", "flac", "opus", "pcm16" ] } }, "additionalProperties": false }, "reasoning_effort": { "description": "Optional reasoning control; availability and accepted values are model-dependent.", "type": [ "string", "null" ] } }, "required": [ "messages" ], "additionalProperties": {}, "title": "Chat Completions" }, { "type": "object", "properties": { "input": { "anyOf": [ { "type": "string" }, { "type": "array", "items": {} } ] }, "instructions": { "type": "string" }, "temperature": { "type": "number", "minimum": 0, "maximum": 2 }, "max_output_tokens": { "type": "number", "exclusiveMinimum": 0 }, "top_p": { "type": "number", "minimum": 0, "maximum": 1 }, "stream": { "type": "boolean" }, "tools": { "type": "array", "items": {} }, "tool_choice": {}, "text": { "type": "object", "properties": { "format": {} }, "additionalProperties": {} }, "reasoning": { "type": "object", "properties": { "effort": { "description": "Reasoning effort; availability and accepted values are model-dependent.", "type": "string", "enum": [ "none", "low", "medium", "high", "xhigh", "max" ] } }, "additionalProperties": {} } }, "required": [ "input" ], "additionalProperties": {}, "title": "Responses" } ] }, "output": { "$schema": "https://json-schema.org/draft/2020-12/schema", "oneOf": [ { "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": {}, "title": "Messages" }, { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string" }, "created": { "type": "number" }, "model": { "type": "string" }, "choices": { "type": "array", "items": { "type": "object", "properties": { "index": { "type": "number" }, "message": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": [ "string", "null" ] }, "tool_calls": { "anyOf": [ { "type": "array", "items": {} }, { "type": "null" } ] }, "audio": { "anyOf": [ { "type": "object", "properties": { "id": { "type": "string" }, "data": { "type": "string" }, "expires_at": { "type": "number" }, "transcript": { "type": "string" } }, "additionalProperties": {} }, { "type": "null" } ] } }, "required": [ "role" ], "additionalProperties": {} }, "finish_reason": { "type": [ "string", "null" ] } }, "required": [ "index", "message", "finish_reason" ], "additionalProperties": {} } }, "usage": { "type": "object", "properties": { "prompt_tokens": { "type": "number" }, "completion_tokens": { "type": "number" }, "total_tokens": { "type": "number" } }, "required": [ "prompt_tokens", "completion_tokens", "total_tokens" ], "additionalProperties": {} } }, "required": [ "id", "object", "created", "model", "choices" ], "additionalProperties": {}, "title": "Chat Completions" }, { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string", "const": "response" }, "created_at": { "type": "number" }, "model": { "type": "string" }, "output": { "type": "array", "items": {} }, "output_text": { "type": "string" }, "status": { "type": "string", "enum": [ "in_progress", "completed", "failed", "incomplete" ] }, "usage": { "type": "object", "properties": { "input_tokens": { "type": "number" }, "output_tokens": { "type": "number" }, "total_tokens": { "type": "number" } }, "required": [ "input_tokens", "output_tokens", "total_tokens" ], "additionalProperties": {} } }, "required": [ "id", "object", "created_at", "model", "output" ], "additionalProperties": {}, "title": "Responses" } ] } } }