diff --git a/src/content/catalog-models/google-gemini-3.7-flash.json b/src/content/catalog-models/google-gemini-3.7-flash.json new file mode 100644 index 00000000000..50253b9e0ff --- /dev/null +++ b/src/content/catalog-models/google-gemini-3.7-flash.json @@ -0,0 +1,765 @@ +{ + "model_id": "google/gemini-3.7-flash", + "provider_id": "google", + "name": "Gemini 3.7 Flash", + "description": "Gemini 3.7 Flash is a highly capable, natively multimodal reasoning model optimized for agentic workflows and real-world tasks.", + "task": "Text Generation", + "tags": [ + "LLM", + "Fast", + "Multimodal", + "Reasoning", + "Agentic", + "Coding" + ], + "context_length": 1048576, + "max_output_tokens": 65536, + "schema_version": "1.0.0", + "examples": [ + { + "name": "Simple Question", + "description": "Basic generateContent request", + "input": { + "contents": [ + { + "parts": [ + { + "text": "What are the three laws of thermodynamics?" + } + ], + "role": "user" + } + ] + }, + "output": { + "text": "The **laws of thermodynamics** define fundamental physical quantities (like temperature, energy, and entropy) and describe how they behave under various circumstances. \n\nWhile there are historically **three** main laws, scientists later added a foundational law called the **Zeroth Law**. Here are all four, clearly explained:\n\n---\n\n### **1. The First Law (Law of Conservation of Energy)**\n> **\"Energy cannot be created or destroyed; it can only change forms.\"**\n\n* **What it means:** The total amount of energy in an isolated system (like the universe) remains constant. When heat is added to a system, it either increases the system's internal energy or does work on the surroundings.\n* **Equation:** $\\Delta U = Q - W$ \n *(Change in internal energy = Heat added to the system $-$ Work done by the system)*\n* **Everyday Example:** A car engine converts the *chemical energy* stored in gasoline into *thermal energy* (heat) and *mechanical energy* (motion). No new energy is created.\n\n---\n\n### **2. The Second Law (Law of Entropy)**\n> **\"The entropy of an isolated system always increases over time.\"**\n\n* **What it means:** Natural processes are irreversible. Heat will spontaneously flow from hotter objects to colder objects, but never the reverse on its own. **Entropy** is a measure of disorder or unusable energy; because some energy is always lost as heat in any transfer, the universe becomes increasingly disordered.\n* **Consequence:** It is impossible to build a machine that is 100% efficient (a perpetual motion machine).\n* **Everyday Example:** If you drop an ice cube into a cup of hot coffee, the heat moves from the coffee to the ice, melting it. You will never see a cup of warm coffee spontaneously separate into boiling coffee and an ice cube.\n\n---\n\n### **3. The Third Law (Absolute Zero)**\n> **\"The entropy of a pure crystalline substance approaches zero as the temperature approaches absolute zero.\"**\n\n* **What it means:** **Absolute zero** (0 Kelvin, or $-273.15^\\circ\\text{C} / -459.67^\\circ\\text{F}$) is the point where all atomic motion stops. At this temperature, a perfect crystal would have zero disorder (zero entropy). \n* **Consequence:** It is physically impossible to cool any object down to absolute zero in a finite number of steps, though scientists can get within billionths of a degree close.\n\n---\n\n### *Bonus: The Zeroth Law (Thermal Equilibrium)*\n*(Formulated after the first two, but deemed so fundamental it was placed before them.)*\n\n> **\"If System A is in thermal equilibrium with System B, and System B is in thermal equilibrium with System C, then System A is also in thermal equilibrium with System C.\"**\n\n* **What it means:** \"Thermal equilibrium\" simply means no heat flows between two objects because they are the same temperature. This law defines the concept of **temperature** and allows us to use **thermometers**.\n\n---\n\n### **A Common Memory Trick (Ginsberg\u2019s Analogy)**\nA humorous way physicists summarize the laws of thermodynamics:\n1. **First Law:** You can't win; you can only break even (energy is conserved).\n2. **Second Law:** You can't break even (entropy always increases, so energy is lost as unusable heat).\n3. **Third Law:** You can't get out of the game (you can never reach absolute zero)." + }, + "raw_response": { + "candidates": [ + { + "content": { + "role": "model", + "parts": [ + { + "text": "The **laws of thermodynamics** define fundamental physical quantities (like temperature, energy, and entropy) and describe how they behave under various circumstances. \n\nWhile there are historically **three** main laws, scientists later added a foundational law called the **Zeroth Law**. Here are all four, clearly explained:\n\n---\n\n### **1. The First Law (Law of Conservation of Energy)**\n> **\"Energy cannot be created or destroyed; it can only change forms.\"**\n\n* **What it means:** The total amount of energy in an isolated system (like the universe) remains constant. When heat is added to a system, it either increases the system's internal energy or does work on the surroundings.\n* **Equation:** $\\Delta U = Q - W$ \n *(Change in internal energy = Heat added to the system $-$ Work done by the system)*\n* **Everyday Example:** A car engine converts the *chemical energy* stored in gasoline into *thermal energy* (heat) and *mechanical energy* (motion). No new energy is created.\n\n---\n\n### **2. The Second Law (Law of Entropy)**\n> **\"The entropy of an isolated system always increases over time.\"**\n\n* **What it means:** Natural processes are irreversible. Heat will spontaneously flow from hotter objects to colder objects, but never the reverse on its own. **Entropy** is a measure of disorder or unusable energy; because some energy is always lost as heat in any transfer, the universe becomes increasingly disordered.\n* **Consequence:** It is impossible to build a machine that is 100% efficient (a perpetual motion machine).\n* **Everyday Example:** If you drop an ice cube into a cup of hot coffee, the heat moves from the coffee to the ice, melting it. You will never see a cup of warm coffee spontaneously separate into boiling coffee and an ice cube.\n\n---\n\n### **3. The Third Law (Absolute Zero)**\n> **\"The entropy of a pure crystalline substance approaches zero as the temperature approaches absolute zero.\"**\n\n* **What it means:** **Absolute zero** (0 Kelvin, or $-273.15^\\circ\\text{C} / -459.67^\\circ\\text{F}$) is the point where all atomic motion stops. At this temperature, a perfect crystal would have zero disorder (zero entropy). \n* **Consequence:** It is physically impossible to cool any object down to absolute zero in a finite number of steps, though scientists can get within billionths of a degree close.\n\n---\n\n### *Bonus: The Zeroth Law (Thermal Equilibrium)*\n*(Formulated after the first two, but deemed so fundamental it was placed before them.)*\n\n> **\"If System A is in thermal equilibrium with System B, and System B is in thermal equilibrium with System C, then System A is also in thermal equilibrium with System C.\"**\n\n* **What it means:** \"Thermal equilibrium\" simply means no heat flows between two objects because they are the same temperature. This law defines the concept of **temperature** and allows us to use **thermometers**.\n\n---\n\n### **A Common Memory Trick (Ginsberg\u2019s Analogy)**\nA humorous way physicists summarize the laws of thermodynamics:\n1. **First Law:** You can't win; you can only break even (energy is conserved).\n2. **Second Law:** You can't break even (entropy always increases, so energy is lost as unusable heat).\n3. **Third Law:** You can't get out of the game (you can never reach absolute zero).", + "thoughtSignature": "AY89a19XdC4x/f+U8hCl13sukl2kjv7cr4AAfyhSwG6PrM0gqQI0UzuL58Cyc42V2aoktYrBm9y3PV9o8xeqfFmrMsWLhF+VRtKFVTFy0R1uAZksXMeolxKfpKEa1DQS+j7gJUzvuZ9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F7XWEeL29M+QYvrNjhjAcKHk1+Z6mu3on0ONd087rTyjl+TXjW/dGZEL5MqWh8F8TeCvb+NsRFnKou+malXbUHjTtft8Du/M/0XcmH+7rM0VeUTvEiu9Xr5xzuichY0zO7w6eYBbcPrNVKBCxzamwBKCPNoaK3bQTzFhecucJDbPZuUvmp9qYZss8iPvyCNiA36xV49tvnycbKTI8KVTeTccYxqouN5js/fZvHbzQfoj5C7eWtlZlQqgrTGxNxcJ6eRuAwdQ1sytW9BTAahQjEZlSN5yOSTlg9iRoAx8LWyI=" + } + ] + }, + "finishReason": "STOP" + } + ], + "usageMetadata": { + "promptTokenCount": 8, + "candidatesTokenCount": 752, + "totalTokenCount": 1433, + "trafficType": "ON_DEMAND", + "promptTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 8 + } + ], + "candidatesTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 752 + } + ], + "thoughtsTokenCount": 673 + }, + "modelVersion": "gemini-3.7-flash", + "createTime": "2026-08-13T18:07:02.084997Z", + "responseId": "xgd-aoWYBeumrb8Pht-PuQw" + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'google/gemini-3.7-flash',\n { contents: [{ parts: [{ text: 'What are the three laws of thermodynamics?' }], role: 'user' }] },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-3.7-flash\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"What are the three laws of thermodynamics?\"\n }\n ],\n \"role\": \"user\"\n }\n ]\n }\n}'" + } + ] + }, + { + "name": "With System Instruction", + "description": "Using a system instruction to set an agentic coding persona", + "input": { + "contents": [ + { + "parts": [ + { + "text": "Write a Python function that merges two sorted lists into one sorted list." + } + ], + "role": "user" + } + ], + "generationConfig": { + "temperature": 0.2 + }, + "systemInstruction": { + "parts": [ + { + "text": "You are an expert software engineering agent. Write concise, correct, well-documented code." + } + ] + } + }, + "output": { + "text": "Here is a clean, efficient Python function using the two-pointer approach, running in $O(n + m)$ time and space complexity:\n\n```python\nfrom typing import TypeVar\n\nT = TypeVar(\"T\")\n\n\ndef merge_sorted_lists(list1: list[T], list2: list[T]) -> list[T]:\n \"\"\"Merges two pre-sorted lists into a single sorted list.\n\n Args:\n list1: A sorted list of elements.\n list2: Another sorted list of elements (same comparable type).\n\n Returns:\n A new sorted list containing all elements from both lists.\n\n Complexity:\n Time: O(n + m) where n and m are lengths of list1 and list2.\n Space: O(n + m) for the resulting merged list.\n \"\"\"\n merged: list[T] = []\n i, j = 0, 0\n len1, len2 = len(list1), len(list2)\n\n # Compare elements from both lists and append the smaller one\n while i < len1 and j < len2:\n if list1[i] <= list2[j]:\n merged.append(list1[i])\n i += 1\n else:\n merged.append(list2[j])\n j += 1\n\n # Append any remaining elements\n merged.extend(list1[i:])\n merged.extend(list2[j:])\n\n return merged\n\n\n# Example usage:\nif __name__ == \"__main__\":\n a = [1, 3, 5, 8]\n b = [2, 4, 6, 7, 9, 10]\n print(merge_sorted_lists(a, b))\n # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n```\n\n### Alternative: Standard Library (`heapq.merge`)\nIf you prefer a built-in generator approach that handles large streams without loading everything into memory upfront:\n\n```python\nimport heapq\n\n\ndef merge_sorted_lists_lazy(list1: list, list2: list) -> list:\n return list(heapq.merge(list1, list2))\n```" + }, + "raw_response": { + "candidates": [ + { + "content": { + "role": "model", + "parts": [ + { + "text": "Here is a clean, efficient Python function using the two-pointer approach, running in $O(n + m)$ time and space complexity:\n\n```python\nfrom typing import TypeVar\n\nT = TypeVar(\"T\")\n\n\ndef merge_sorted_lists(list1: list[T], list2: list[T]) -> list[T]:\n \"\"\"Merges two pre-sorted lists into a single sorted list.\n\n Args:\n list1: A sorted list of elements.\n list2: Another sorted list of elements (same comparable type).\n\n Returns:\n A new sorted list containing all elements from both lists.\n\n Complexity:\n Time: O(n + m) where n and m are lengths of list1 and list2.\n Space: O(n + m) for the resulting merged list.\n \"\"\"\n merged: list[T] = []\n i, j = 0, 0\n len1, len2 = len(list1), len(list2)\n\n # Compare elements from both lists and append the smaller one\n while i < len1 and j < len2:\n if list1[i] <= list2[j]:\n merged.append(list1[i])\n i += 1\n else:\n merged.append(list2[j])\n j += 1\n\n # Append any remaining elements\n merged.extend(list1[i:])\n merged.extend(list2[j:])\n\n return merged\n\n\n# Example usage:\nif __name__ == \"__main__\":\n a = [1, 3, 5, 8]\n b = [2, 4, 6, 7, 9, 10]\n print(merge_sorted_lists(a, b))\n # Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n```\n\n### Alternative: Standard Library (`heapq.merge`)\nIf you prefer a built-in generator approach that handles large streams without loading everything into memory upfront:\n\n```python\nimport heapq\n\n\ndef merge_sorted_lists_lazy(list1: list, list2: list) -> list:\n return list(heapq.merge(list1, list2))\n```", + "thoughtSignature": "AY89a1/7DiGkUrOuttOAy7k+sp7leERYwo5R3cg8S3yxDA+Tnd3ssAiNYC4uxqEr3xMAISGixJES6CVe74Cy/DiRvl2HSM0SiU4TmHHyAd3eUcNt3BKORH5fSqzgLyyUtHkzhDnFjO1VQT9///WfxmS8BLlIDp9dXaF44o4sr67Kw8Qi+3GMlh61cUPhmoYWYdeSI7d6CdDBw5Dw6kPR1NuFDbvo3serTTbyTOPptFmW2L5VgqS+gYz0RPHbLF3kp9fGVMfkmBIZpT3Mk4iJcGDXcMPS27T0HiBAVbZMTUjaaaYimCA1V8GQ1XrIMwbWz2T+S2/EeqTTtRY4uwWGd9sknn0v4SF33qjOykzkNucZSxEzEf4G6sXK21aVN/hoD4GDwE/WxLmc3Vr+stIjP54jr5KR9qaMyNro7PFS1S4VRvYbiygNq/E8y9qUqw3JAp+2er2LF4rVrdEsltxCxOW7LwRbM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4zltdXAuEwSrLMJI5gKarpfGyeprJNwM23lzyJ8nYU8o8ROnBboniHLMv+LgtxIcomIPTOzsz" + } + ] + }, + "finishReason": "STOP" + } + ], + "usageMetadata": { + "promptTokenCount": 32, + "candidatesTokenCount": 517, + "totalTokenCount": 1114, + "trafficType": "ON_DEMAND", + "promptTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 32 + } + ], + "candidatesTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 517 + } + ], + "thoughtsTokenCount": 565 + }, + "modelVersion": "gemini-3.7-flash", + "createTime": "2026-08-13T19:07:35.820040Z", + "responseId": "9xV-asiGMqyo3dAP3oHS-Qw" + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'google/gemini-3.7-flash',\n {\n contents: [\n {\n parts: [\n { text: 'Write a Python function that merges two sorted lists into one sorted list.' },\n ],\n role: 'user',\n },\n ],\n generationConfig: { temperature: 0.2 },\n systemInstruction: {\n parts: [\n {\n text: 'You are an expert software engineering agent. Write concise, correct, well-documented code.',\n },\n ],\n },\n },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-3.7-flash\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"Write a Python function that merges two sorted lists into one sorted list.\"\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 0.2\n },\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are an expert software engineering agent. Write concise, correct, well-documented code.\"\n }\n ]\n }\n }\n}'" + } + ] + }, + { + "name": "Multi-turn Conversation", + "description": "Continuing a multi-step coding conversation, typical of an agentic loop", + "input": { + "contents": [ + { + "parts": [ + { + "text": "I have a bug where my recursive fibonacci function is too slow for n=40." + } + ], + "role": "user" + }, + { + "parts": [ + { + "text": "That's expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?" + } + ], + "role": "model" + }, + { + "parts": [ + { + "text": "Show me the memoized version." + } + ], + "role": "user" + } + ], + "generationConfig": { + "maxOutputTokens": 2048 + } + }, + "output": { + "text": "Here is how to memoize the recursive Fibonacci function.\n\n### 1. Using a Dictionary / Cache (Explicit)\n\nYou store results of previous calculations in a dictionary and look them up before computing:\n\n```python\ndef fib(n, memo=None):\n if memo is None:\n memo = {}\n\n # Check if already computed\n if n in memo:\n return memo[n]\n\n # Base cases\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n\n # Store result in memo dictionary\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n\n\n# Test\nprint(fib(40)) # Returns 102334155 instantly\n```\n\n---\n\n### 2. Using Python's Built-in `@lru_cache` (Idiomatic Python)\n\nPython has a built-in decorator that handles memoization automatically:\n\n```python\nfrom functools import lru_cache\n\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n\n\n# Test\nprint(fib(40)) # Returns 102334155 instantly\n```\n\n---\n\n### Why this fixes the issue:\n* **Naive recursion:** Time complexity is $O(2^n)$ because it recomputes identical values millions of times.\n* **Memoized recursion:** Time complexity drops to $O(n)$ because each Fibonacci number from $0$ to $n$ is calculated only once. Space complexity is $O(n)$ to store the cache and recursion stack." + }, + "raw_response": { + "candidates": [ + { + "content": { + "role": "model", + "parts": [ + { + "text": "Here is how to memoize the recursive Fibonacci function.\n\n### 1. Using a Dictionary / Cache (Explicit)\n\nYou store results of previous calculations in a dictionary and look them up before computing:\n\n```python\ndef fib(n, memo=None):\n if memo is None:\n memo = {}\n\n # Check if already computed\n if n in memo:\n return memo[n]\n\n # Base cases\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n\n # Store result in memo dictionary\n memo[n] = fib(n - 1, memo) + fib(n - 2, memo)\n return memo[n]\n\n\n# Test\nprint(fib(40)) # Returns 102334155 instantly\n```\n\n---\n\n### 2. Using Python's Built-in `@lru_cache` (Idiomatic Python)\n\nPython has a built-in decorator that handles memoization automatically:\n\n```python\nfrom functools import lru_cache\n\n\n@lru_cache(maxsize=None)\ndef fib(n):\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n\n\n# Test\nprint(fib(40)) # Returns 102334155 instantly\n```\n\n---\n\n### Why this fixes the issue:\n* **Naive recursion:** Time complexity is $O(2^n)$ because it recomputes identical values millions of times.\n* **Memoized recursion:** Time complexity drops to $O(n)$ because each Fibonacci number from $0$ to $n$ is calculated only once. Space complexity is $O(n)$ to store the cache and recursion stack.", + "thoughtSignature": "AY89a1+Wv/04SFz0MKQY8n+tFyT0cfnQ+6x5+vRQu2MbyVYQqMErpr6OvgnpAYufyK3yG/BXeedOilTz9V1KgVD1QWF0fywd6r7Yw6Hbfwl+RaCf+zGlEOeM7ZuqPAIjIrQEsfaYbR+THgipFCCvNuP//K5ObnatV7hRrDMt7pqltYwg5NWm/O+0H3YvLp55UZlztXfz8t91zLg4pJKMzutMMaupMh5AAHu/pe40KJg2Id/ZH9QCn0ZqrvwJA/vYoQjUNLmbHRQirXIF5W0o5w0yCF6HBkDHBRnu2OWUi7Ne4DIqAmJJYKv0ePurLSaDJLE09M5XS4WOyd7cSH3sBzVTfxYYRN5OeT5UUGZ16JjPcSc3eaT64u1Ng/erd2fT0NfSa5/P2cWGw9KvxOSsU/19OUoonpBQvhoMhioMg1aL2RyVI9ikxm8cl54JZJbmJpmR60vHsdXPFnBSGdG3DQ3MNv+HKZEr6kXQ1FliGJU8qXGcNOAMkgykbgunAecujeN/vpaC3SBNRdc7yMa6cT1T9FVL1l1Cuxx9OuWSQowkhoniTPsV22uOj6drYlKPU6AJJuhNjv/epFySrCJbB9F1rISGL4wYkAD6mDEmaT0rG15OxjEb97C/8OufUirZpcDDC1jR0sWj7FlS4KCQUsNzdhc5AJhLQPtA3IGgAZzDH3PHvQYhUo29VP6jMhOE5S3fmLa2TSiuKtoYwMaAIzkGdp0xKohPrVFtn9Zajb+7Y6I6TsA0WL7Pg/DTIiooTZBG+dGk49Tt6eFfW/ypKXDy9YErzQF6FTK/V9rgPHEpZdSVvFnOunGZ3I+o02B9esYSqSNQlaBI7Y0/5hpCfgf0Ap9G1sh1WMkuCL40d0jRevBbEZAKqrdG1Gr5whRbjNtWbD/Cx17clPpGT5K3dNq5NJY16xqzPwJyNgj7H9xgNFiJGh5xYzx4PBTN0NsgE1bK6t3BrPkWxG0vB7B4Flyj3HRzGHj43qkT2cRKEoNjsiTGIvvyBaa6QQOYZ5yu2hC6h7mpNntCeU5iaDtQA/NC010PqvELJpqmiGyYM9D9uazoHrelc5STEOyUH6Eei7cfhezFCB0ibUm795StAgZt4WvWpYXif4PMRc/gdsNoWZr9Wo0WhlCm4ivwwoiG71oPbzam8IRp+2PP8evgPm4AogOToIHUQMZFz2OnGXXX8E0I25wMe5D+q9zpLO+st7kOFLl1vITCPvDkjw==" + } + ] + }, + "finishReason": "STOP" + } + ], + "usageMetadata": { + "promptTokenCount": 62, + "candidatesTokenCount": 412, + "totalTokenCount": 698, + "trafficType": "ON_DEMAND", + "promptTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 62 + } + ], + "candidatesTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 412 + } + ], + "thoughtsTokenCount": 224 + }, + "modelVersion": "gemini-3.7-flash", + "createTime": "2026-08-13T19:07:41.574572Z", + "responseId": "_RV-auyII6ip3dAP16iw4Qw" + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'google/gemini-3.7-flash',\n {\n contents: [\n {\n parts: [{ text: 'I have a bug where my recursive fibonacci function is too slow for n=40.' }],\n role: 'user',\n },\n {\n parts: [\n {\n text: \"That's expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?\",\n },\n ],\n role: 'model',\n },\n { parts: [{ text: 'Show me the memoized version.' }], role: 'user' },\n ],\n generationConfig: { maxOutputTokens: 2048 },\n },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-3.7-flash\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"I have a bug where my recursive fibonacci function is too slow for n=40.\"\n }\n ],\n \"role\": \"user\"\n },\n {\n \"parts\": [\n {\n \"text\": \"That'\\''s expected with naive recursion since it recomputes overlapping subproblems exponentially. You can fix it with memoization or an iterative approach. Which would you like to see?\"\n }\n ],\n \"role\": \"model\"\n },\n {\n \"parts\": [\n {\n \"text\": \"Show me the memoized version.\"\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 2048\n }\n }\n}'" + } + ] + }, + { + "name": "Spatial Reasoning", + "description": "Higher thinking budget for a spatial reasoning task", + "input": { + "contents": [ + { + "parts": [ + { + "text": "A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?" + } + ], + "role": "user" + } + ], + "generationConfig": { + "maxOutputTokens": 4096 + } + }, + "output": { + "text": "To find the number of smaller cubes with **exactly two red faces**, we can analyze how the $3 \\times 3 \\times 3$ cube is structured:\n\n1. **Corner cubes (3 painted faces):** There are **8** corners in a cube.\n2. **Edge cubes (excluding corners, 2 painted faces):** A cube has 12 edges. With a $3 \\times 3 \\times 3$ cut, each edge has 1 middle cube with 2 painted faces:\n $$\\text{Number of cubes} = 12 \\times (3 - 2) = 12$$\n3. **Face-center cubes (1 painted face):** There is 1 in the center of each of the 6 faces = **6**.\n4. **Interior cube (0 painted faces):** There is **1** cube completely inside.\n\n*(Check: $8 + 12 + 6 + 1 = 27$ total cubes)*\n\nTherefore, there are **12** smaller cubes with exactly two red faces." + }, + "raw_response": { + "candidates": [ + { + "content": { + "role": "model", + "parts": [ + { + "text": "To find the number of smaller cubes with **exactly two red faces**, we can analyze how the $3 \\times 3 \\times 3$ cube is structured:\n\n1. **Corner cubes (3 painted faces):** There are **8** corners in a cube.\n2. **Edge cubes (excluding corners, 2 painted faces):** A cube has 12 edges. With a $3 \\times 3 \\times 3$ cut, each edge has 1 middle cube with 2 painted faces:\n $$\\text{Number of cubes} = 12 \\times (3 - 2) = 12$$\n3. **Face-center cubes (1 painted face):** There is 1 in the center of each of the 6 faces = **6**.\n4. **Interior cube (0 painted faces):** There is **1** cube completely inside.\n\n*(Check: $8 + 12 + 6 + 1 = 27$ total cubes)*\n\nTherefore, there are **12** smaller cubes with exactly two red faces.", + "thoughtSignature": "AY89a18GhPrAzwD4+OG6wmLOGj2YZE0gv9PY76IqT4vccoHQerNJubk8VCyX0atC0qHPy/28tlQG5WlMvbqfovvGqrSJeNHSVC6RoyKD7SMGVnSOw83d5XDYxirhMa5XgVbtEF6O5t03QYpIyB/ice00yWw9US/osp4NOYRDYTPA6uekMJkCjFH8lNuYP4RnEFmEXHyxBtnlrcXvB2fy9bWxZEw3ck69faKWfJF/Ia0oy27SOdIaQTzcczJum9F+AnjliMkpY4EdIm+5KvOwrZCgcz+QWfNGQBu9SOK9qalhHHiI7diBhU8f4Dans3S1a1A9jKV8mOelXtaNDOXOKSk45muOSxds5JF/wb/2XAdTpgLt2cLE/vOuF4c4WBA+vpV9lvwlHKGMklvwFz7kSwnVOLnxglQwQl9ykyfdcInHzlaWAzfzEu7tq/Zkmp67DBtN7ZeG/teVlPIqm63uwBrQT8MOWVB27Ah59QI57TzclfNs0scwjmTlzFIzrzEKx+uz4Z4ekistTu8yGW12Gk8ypl5HEwZnOS8JpRR/ln20XV95oMb27LA6qnnW71S5SUva8+PdQsRw3NmeIp1FDmjxmuLE43UBcsGn/rj8KymrDRHkC1PHyOU+6je4J+/fma44zwfp4G2YJOit3f8btPUVsjrXH011krTONlK47hfKp08WJO7nCVaw7+gphzRrUMugxl8g7D3kVd5uym1c+lQstrs+FaaXj1VZwM5UUX3p/6ex+gso45qJ+h1OFhmZeOHKF8KTUw86RMdtFC+r1ULthumOSJHmb0nkQKnBqqV7qXdzNVep0rwZHk6rfULTPUQ0XaKAy9dtk8YOeeX7ULaTOHRe044Q9EcZk5eFCF5ktauTBwOG4+7B3R84/TS6DYOKQZSdYukuAQpq9SzlNnZaa1DHc9YLPP0CyPkEJ6yyZjEN78TiLvb+eXW06pPNC/wXVUdx47dq6w8MI16w4CiA8e8r/C7sqKSkD2j0Ksufr+mAq5gwSgOMRQx8vR+SfWp+3i1RvkRHpONZGftNyBuXfPLq1t/Hk6Wci4xkE8k8grwopKdghzHBpknmkz9783YjkeIFQMcoruEgfvzpElGERWmXKg7UqrMaOhY/HNcZ4auUoj8mUMBj+ejiCV/v+YrO6y3TAifJPYJEn4tiV3smbXTIA+UpilF4POrVSoeJkNhb6EVOrDK/UsjP2NNKNclL6F19JurykzmBrQZZs8vVn5KWLxkBXkdkdGMAjtPRdtX9ggfr+hhTNjBYSpo2sxVDjNhOs977Aie8wsRBejfR3a+OUVwyK9PptIaRqpJVQ9YTu0iUe3PcWUSo6YH+6gsOVSRjFrqj+1Ayq0SXfKisu9hF2HOp/vC03Bx0Weqw6XqYMnNvDSjIKEWTImfuGJyx0MK0VS4bvQm/T7T3OmbGnSsqHPx83n10xw==" + } + ] + }, + "finishReason": "STOP" + } + ], + "usageMetadata": { + "promptTokenCount": 31, + "candidatesTokenCount": 228, + "totalTokenCount": 602, + "trafficType": "ON_DEMAND", + "promptTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 31 + } + ], + "candidatesTokensDetails": [ + { + "modality": "TEXT", + "tokenCount": 228 + } + ], + "thoughtsTokenCount": 343 + }, + "modelVersion": "gemini-3.7-flash", + "createTime": "2026-08-13T19:07:45.456897Z", + "responseId": "ARZ-asHxG6mp3dAP9fHcoQ0" + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'google/gemini-3.7-flash',\n {\n contents: [\n {\n parts: [\n {\n text: 'A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?',\n },\n ],\n role: 'user',\n },\n ],\n generationConfig: { maxOutputTokens: 4096 },\n },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"google/gemini-3.7-flash\",\n \"input\": {\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"A cube is painted red on all faces, then cut into 27 equal smaller cubes. How many of the smaller cubes have exactly two red faces?\"\n }\n ],\n \"role\": \"user\"\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 4096\n }\n }\n}'" + } + ] + } + ], + "default_example": null, + "code_snippets": [], + "supports_async": false, + "zdr": false, + "zdr_comment": null, + "external_info": "https://ai.google.dev/gemini-api/docs/models/gemini-3.7-flash", + "terms": "https://ai.google.dev/gemini-api/terms", + "cover_image_url": "https://pub-26f1392c1b674324be6786695bd72257.r2.dev/google/gemini-3.7-flash.png", + "metadata": { + "Architecture": "Transformer (multimodal)", + "Thinking": "Yes" + }, + "request_formats": [ + "chat-completions" + ], + "providers": null, + "banner": null, + "created_at": "2026-08-14 22:33:12", + "schema": { + "input": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "object", + "properties": { + "contents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "role": { + "type": "string", + "enum": [ + "user", + "model" + ] + }, + "parts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "text": { + "type": "string" + } + }, + "additionalProperties": {} + } + } + }, + "required": [ + "parts" + ], + "additionalProperties": {} + } + }, + "systemInstruction": { + "type": "object", + "properties": { + "parts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "text": { + "type": "string" + } + }, + "additionalProperties": {} + } + } + }, + "required": [ + "parts" + ], + "additionalProperties": {} + }, + "generationConfig": { + "type": "object", + "properties": { + "temperature": { + "type": "number" + }, + "topP": { + "type": "number" + }, + "topK": { + "type": "number" + }, + "maxOutputTokens": { + "type": "number" + }, + "candidateCount": { + "type": "number" + }, + "stopSequences": { + "type": "array", + "items": { + "type": "string" + } + }, + "responseMimeType": { + "type": "string" + } + }, + "additionalProperties": {} + }, + "safetySettings": { + "type": "array", + "items": { + "type": "object", + "properties": { + "category": { + "type": "string" + }, + "threshold": { + "type": "string" + } + }, + "required": [ + "category", + "threshold" + ], + "additionalProperties": {} + } + }, + "tools": { + "type": "array", + "items": {} + }, + "toolConfig": {} + }, + "required": [ + "contents" + ], + "additionalProperties": {}, + "title": "Generate Content" + }, + { + "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 + } + }, + "required": [ + "messages" + ], + "additionalProperties": {}, + "title": "Chat Completions" + } + ] + }, + "output": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "oneOf": [ + { + "type": "object", + "properties": { + "candidates": { + "type": "array", + "items": {} + }, + "usageMetadata": { + "type": "object", + "properties": { + "promptTokenCount": { + "type": "number" + }, + "candidatesTokenCount": { + "type": "number" + }, + "totalTokenCount": { + "type": "number" + } + }, + "additionalProperties": {} + }, + "modelVersion": { + "type": "string" + } + }, + "additionalProperties": {}, + "title": "Generate Content" + }, + { + "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": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "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": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "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" + } + ] + } + } +} diff --git a/src/content/catalog-models/xai-grok-imagine-image-2.0.json b/src/content/catalog-models/xai-grok-imagine-image-2.0.json new file mode 100644 index 00000000000..afaa28985da --- /dev/null +++ b/src/content/catalog-models/xai-grok-imagine-image-2.0.json @@ -0,0 +1,258 @@ +{ + "model_id": "xai/grok-imagine-image-2.0", + "provider_id": "xai", + "name": "Grok Imagine Image 2.0", + "description": "xAI's Grok Imagine Image 2.0 is a precise image generation and editing model for creative work, with strong instruction following, typography, layout, and reference-image preservation.", + "task": "Text-to-Image", + "tags": [ + "Image Generation", + "Image Editing", + "Multimodal", + "Text Rendering", + "Typography" + ], + "context_length": null, + "max_output_tokens": null, + "schema_version": "1.0.0", + "examples": [ + { + "name": "Simple Generation", + "description": "Basic text-to-image generation", + "input": { + "prompt": "A concert poster for a synthwave band, bold retro typography, sharp small print", + "response_format": "b64_json" + }, + "output": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/simple-generation.jpg" + }, + "raw_response": { + "state": "Completed", + "result": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/simple-generation.jpg" + }, + "gatewayMetadata": { + "keySource": "Unified" + } + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n { prompt: 'A concert poster for a synthwave band, bold retro typography, sharp small print' },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image-2.0\",\n \"input\": {\n \"prompt\": \"A concert poster for a synthwave band, bold retro typography, sharp small print\"\n }\n}'" + } + ] + }, + { + "name": "Portrait 2K", + "description": "High-resolution image with a controlled aspect ratio", + "input": { + "aspect_ratio": "3:4", + "prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures", + "quality": "medium", + "resolution": "2k", + "response_format": "b64_json" + }, + "output": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/portrait-2k.png" + }, + "raw_response": { + "state": "Completed", + "result": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/portrait-2k.png" + }, + "gatewayMetadata": { + "keySource": "Unified" + } + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n {\n aspect_ratio: '3:4',\n prompt:\n 'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',\n quality: 'medium',\n resolution: '2k',\n },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image-2.0\",\n \"input\": {\n \"aspect_ratio\": \"3:4\",\n \"prompt\": \"A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures\",\n \"quality\": \"medium\",\n \"resolution\": \"2k\"\n }\n}'" + } + ] + }, + { + "name": "Low Quality Draft", + "description": "Fast low-quality draft for iteration", + "input": { + "aspect_ratio": "1:1", + "prompt": "A quiet Japanese garden in morning mist with a stone lantern and koi pond", + "quality": "low", + "resolution": "1k", + "response_format": "b64_json" + }, + "output": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/low-quality-draft.jpg" + }, + "raw_response": { + "state": "Completed", + "result": { + "image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image-2.0/low-quality-draft.jpg" + }, + "gatewayMetadata": { + "keySource": "Unified" + } + }, + "code_snippets": [ + { + "label": "typescript", + "language": "typescript", + "code": "const response = await env.AI.run(\n 'xai/grok-imagine-image-2.0',\n {\n aspect_ratio: '1:1',\n prompt: 'A quiet Japanese garden in morning mist with a stone lantern and koi pond',\n quality: 'low',\n resolution: '1k',\n },\n)\nconsole.log(response)" + }, + { + "label": "curl", + "language": "bash", + "code": "curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \\\n --header \"Authorization: Bearer $CLOUDFLARE_API_TOKEN\" \\\n --header \"Content-Type: application/json\" \\\n --data '{\n \"model\": \"xai/grok-imagine-image-2.0\",\n \"input\": {\n \"aspect_ratio\": \"1:1\",\n \"prompt\": \"A quiet Japanese garden in morning mist with a stone lantern and koi pond\",\n \"quality\": \"low\",\n \"resolution\": \"1k\"\n }\n}'" + } + ] + } + ], + "default_example": null, + "code_snippets": [], + "supports_async": false, + "zdr": false, + "zdr_comment": null, + "external_info": "https://docs.x.ai/developers/model-capabilities/images/generation", + "terms": "https://x.ai/legal/terms-of-service", + "cover_image_url": "https://pub-26f1392c1b674324be6786695bd72257.r2.dev/xai/grok-imagine-image-2.0.png", + "metadata": { + "Aspect Ratios": "1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 9:19.5, 19.5:9, 9:20, 20:9, 2:1, 1:2, auto", + "Max Reference Images": "5", + "Quality": "low, medium", + "Resolutions": "1k, 2k", + "Text Rendering": "Yes" + }, + "request_formats": null, + "providers": null, + "banner": null, + "created_at": "2026-08-14 22:17:39", + "schema": { + "input": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "prompt": { + "type": "string" + }, + "aspect_ratio": { + "type": "string", + "enum": [ + "1:1", + "3:4", + "4:3", + "9:16", + "16:9", + "2:3", + "3:2", + "9:19.5", + "19.5:9", + "9:20", + "20:9", + "1:2", + "2:1", + "auto" + ] + }, + "quality": { + "type": "string", + "enum": [ + "low", + "medium" + ] + }, + "resolution": { + "type": "string", + "enum": [ + "1k", + "2k" + ] + }, + "response_format": { + "type": "string", + "enum": [ + "url", + "b64_json" + ] + }, + "user": { + "type": "string" + }, + "image": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + }, + "images": { + "maxItems": 5, + "type": "array", + "items": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + } + }, + "mask": { + "type": "object", + "properties": { + "url": { + "type": "string" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + } + }, + "required": [ + "prompt" + ], + "additionalProperties": false + }, + "output": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "properties": { + "image": { + "description": "Generated image. Either a base64 data URI (`data:image/png;base64,...`) or an `https://` URL, depending on the upstream `response_format`.", + "type": "string" + } + }, + "required": [ + "image" + ], + "additionalProperties": false + } + } +}