Output: 3, 2, 1, Blastoff!


## When to Use Recursion

✅ **Good for:**
- Tree/graph traversals
- Mathematical sequences (factorial, Fibonacci)
- Problems that naturally break into similar subproblems

⚠️ **Watch out for:**
- Missing base case (causes infinite recursion)
- Too many recursive calls (can cause stack overflow)
- Problems better solved with iteration (for performance)

## Key Takeaway

Think of recursion like Russian nesting dolls – you keep opening smaller dolls until you reach the smallest one (base case), then work your way back out!
````

```json
[
  {
    "choices": [
      {
        "delta": {
          "content": null,
          "reasoning_content": "",
          "role": "assistant"
        },
        "finish_reason": null,
        "index": 0,
        "logprobs": null
      }
    ],
    "created": 1776471147,
    "id": "chatcmpl-a04b3264-a267-9868-80d3-bd0ef7353605",
    "model": "qwen3.5-397b-a17b",
    "object": "chat.completion.chunk",
    "system_fingerprint": null,
    "usage": null
  },
  {
    "choices": [
      {
        "delta": {
          "content": null,
          "reasoning_content": "This"
        },
        "finish_reason": null,
        "index": 0,
        "logprobs": null
      }
    ],
    "created": 1776471147,
    "id": "chatcmpl-a04b3264-a267-9868-80d3-bd0ef7353605",
    "model": "qwen3.5-397b-a17b",
    "object": "chat.completion.chunk",
    "system_fingerprint": null,
    "usage": null
  },
  "... 192 more chunks omitted ...",
  {
    "choices": [],
    "created": 1776471147,
    "id": "chatcmpl-a04b3264-a267-9868-80d3-bd0ef7353605",
    "model": "qwen3.5-397b-a17b",
    "object": "chat.completion.chunk",
    "system_fingerprint": null,
    "usage": {
      "completion_tokens": 656,
      "completion_tokens_details": {
        "reasoning_tokens": 108,
        "text_tokens": 656
      },
      "prompt_tokens": 21,
      "prompt_tokens_details": {
        "text_tokens": 21
      },
      "total_tokens": 677
    }
  }
]

</details>

<details>

<summary>Web Search — Letting Qwen use DashScope's built-in web search via enable_search</summary>

const response = await env.AI.run(
  'alibaba/qwen3.5-397b-a17b',
  {
    enable_search: true,
    max_tokens: 4096,
    messages: [
      {
        content:
          'What were the top news stories about Cloudflare this week? Summarise in three bullets.',
        role: 'user',
      },
    ],
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "alibaba/qwen3.5-397b-a17b",
  "enable_search": true,
  "max_tokens": 4096,
  "messages": [
    {
      "content": "What were the top news stories about Cloudflare this week? Summarise in three bullets.",
      "role": "user"
    }
  ]
}'
Based on the provided knowledge base (current context June 2026), here are the top recent news stories about Cloudflare:

*   **Acquisition of VoidZero:** On June 4, 2026, Cloudflare announced the acquisition of VoidZero to build the future of the AI-native web, marking its latest strategic move in the AI sector.
*   **Secure Sandboxes for Claude Agents:** On May 19, 2026, Cloudflare introduced secure, scalable sandboxes for Claude managed agents, enhancing security for AI agent lifecycles.
*   **Q1 2026 Financial Results:** Cloudflare announced its first-quarter 2026 financial results on May 7, 2026, alongside being named a leader in edge development platforms by an independent research firm.
{
  "id": "chatcmpl-1dcd0242-41e4-9959-b650-2328b2a35e8c",
  "object": "chat.completion",
  "created": 1782161740,
  "model": "qwen3.5-397b-a17b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Based on the provided knowledge base (current context June 2026), here are the top recent news stories about Cloudflare:\n\n*   **Acquisition of VoidZero:** On June 4, 2026, Cloudflare announced the acquisition of VoidZero to build the future of the AI-native web, marking its latest strategic move in the AI sector.\n*   **Secure Sandboxes for Claude Agents:** On May 19, 2026, Cloudflare introduced secure, scalable sandboxes for Claude managed agents, enhancing security for AI agent lifecycles.\n*   **Q1 2026 Financial Results:** Cloudflare announced its first-quarter 2026 financial results on May 7, 2026, alongside being named a leader in edge development platforms by an independent research firm.",
        "reasoning_content": "Thinking Process:\n\n1.  **Analyze the Request:**\n    *   Topic: Top news stories about Cloudflare.\n    *   Timeframe: \"This week\" (relative to the current date provided in the knowledge base).\n    *   Format: Summarize in three bullets.\n    *   Language: The user asked in English, so the response should be in English.\n\n2.  **Determine the Current Date:**\n    *   The knowledge base contains multiple timestamps.\n    *   One source says \"搜索结果收录于 2026 年 6 月 13 日\" (Search results recorded on June 13, 2026).\n    *   Another source says \"撰于 2026 年 6 月 4 日\" (Written on June 4, 2026).\n    *   Another source says \"消息于 2026 年 2 月 8 日发布\" (Message published on February 8, 2026).\n    *   Another source says \"该信息的时间戳是 2026 年 4 月 19 日\" (Timestamp is April 19, 2026).\n    *   Another source says \"资料日期为 2024 年 6 月 18 日\" (Data date is June 18, 2024).\n    *   Another source says \"2026 年 6 月 8 日的资料\" (Data from June 8, 2026).\n    *   The most recent and relevant \"current\" date context seems to be around June 2026, specifically mid-June 2026 (June 13, 2026 is the latest search record date).\n    *   However, looking at the \"Media Overview | Cloudflare\" section, it lists press releases for June 2026.\n    *   The list shows:\n        *   2026 年 6 月 4 日 (June 4, 2026): \"cloudflare acquires voidzero to build the future of the ai-native web\"\n        *   2026 年 5 月 19 日 (May 19, 2026): \"cloudflare brings secure, scalable sandboxes to claude managed agents\"\n        *   2026 年 5 月 7 日 (May 7, 2026): \"cloudflare announces first quarter 2026 financial results\"\n        *   2026 年 5 月 5 日 (May 5, 2026): \"cloudflare named a leader in edge development platforms report...\"\n    *   If \"this week\" refers to the week surrounding the latest data point (June 13, 2026), I need to look for news around early to mid-June 2026.\n    *   The only June 2026 press release listed is June 4, 2026 (\"cloudflare acquires voidzero...\").\n    *   There is also a mention of \"2026 年 6 月 2 日\" (June 2, 2026) in the Spanish section regarding ITBrief about \"vinext\".\n    *   There is a mention of \"2026 年 6 月 8 日的资料\" (June 8, 2026) for the official press releases list.\n    *   Since the search record date is June 13, 2026, \"this week\" would roughly be June 9 - June 15, or perhaps the most recent significant news available in the context of the provided knowledge base (which seems to cluster around early June 2026).\n    *   However, the knowledge base primarily highlights the June 4th acquisition as the top June news.\n    *   Let's look for other recent items. The \"Media Overview\" shows June 2026 has only 1 item listed in the 1-10 range (June 4).\n    *   The Spanish section mentions \"febrero de 2026 26 de febrero de 2026\" for Vinext, but also says \"2026 年 6 月 2 日\" (June 2, 2026) in the header context. Wait, the Spanish text says \"ITBrief Cloudflare unveils vinext... febrero de 2026 26 de febrero de 2026(2026 年 6 月 2 日)\". This is confusing. It might mean the article was accessed June 2, but published Feb 26.\n    *   The most prominent recent news in the provided text for June 2026 is the acquisition of VoidZero.\n    *   Other recent news (May 2026) includes: Secure sandboxes for Claude agents (May 19), Q1 2026 Financial Results (May 7), Leader in Edge Development (May 5).\n    *   If I must strictly adhere to \"this week\" relative to the latest timestamp (June 13, 2026), the June 4th news is the closest significant event (about 1.5 weeks prior). There isn't much else specifically dated June 9-13 in the text.\n    *   However, often in these tasks, \"this week\" implies the most recent news available in the context provided. The context heavily features June 2026 news.\n    *   Let's select the top 3 most recent/significant stories from the provided text that represent the latest \"news cycle\" available (June 2026).\n    *   Story 1: Acquisition of VoidZero (June 4, 2026).\n    *   Story 2: Secure sandboxes for Claude managed agents (May 19, 2026) - This is late May, close to June.\n    *   Story 3: Q1 2026 Financial Results (May 7, 2026) OR Threat Intelligence Report (March 2026) OR Agents Week (April 2026).\n    *   Actually, looking at the \"Media Overview\" for June 2026, it says \"显示 1-10 个,共 17 个\" (Showing 1-10 of 17). But only one is explicitly dated June 4th in the list provided.\n    *   Wait, the text says \"2026 年 6 月 8 日的资料\" (Data from June 8, 2026) for the press release list.\n    *   If today is June 13, 2026 (search record date), the June 4th news is the most recent major announcement.\n    *   I need to find two more recent stories. The May 19th story about Claude agents is the next most recent.\n    *   The May 7th financial results are also recent.\n    *   Alternatively, there is mention of \"Agents Week 2026\" wrapped up around April 19, 2026.\n    *   Let's prioritize the June and May 2026 news as the \"top stories\" relative to the provided knowledge base's \"current\" timeframe (June 2026).\n\n    *   Candidate 1: Cloudflare acquires VoidZero to build the AI-native web (June 4, 2026).\n    *   Candidate 2: Cloudflare brings secure, scalable sandboxes to Claude managed agents (May 19, 2026).\n    *   Candidate 3: Cloudflare announces First Quarter 2026 Financial Results (May 7, 2026) OR Cloudflare named a leader in edge development platforms (May 5, 2026).\n    *   Let's pick the Financial Results as it's usually a top story.\n    *   Wait, is there anything else? The Spanish section mentions \"ITBrief Cloudflare unveils vinext... 2026 年 6 月 2 日\". This might be interpreted as a June 2nd news item about Vinext (Vite-based Next.js rival). This is closer to \"this week\" (June 13) than May 7.\n    *   So:\n        1.  Acquisition of VoidZero (June 4).\n        2.  Unveiling Vinext (June 2 - based on the header date context though the text says Feb 26, the header says June 2. I should be careful. The text says \"febrero de 2026 26 de febrero de 2026(2026 年 6 月 2 日)\". This likely means the article was accessed/recorded on June 2, but published Feb 26. I should probably stick to the clearly dated June 4 press release).\n        3.  Secure sandboxes for Claude (May 19).\n\n    *   Actually, looking closely at the first block: \"2026 年 6 月 显示 1-10 个,共 17 个\". It lists \"cloudflare acquires voidzero...\" on June 4. It doesn't list others for June.\n    *   So the top stories are likely the June 4 acquisition, and the late May stories.\n    *   Let's formulate the bullets based on the most recent significant announcements available in the text (June 2026 context).\n\n    *   Bullet 1: Acquisition of VoidZero (June 4, 2026).\n    *   Bullet 2: Secure sandboxes for Claude agents (May 19, 2026).\n    *   Bullet 3: Q1 2026 Financial Results (May 7, 2026) OR Being named a leader in edge development (May 5, 2026). Financial results are usually more significant.\n    *   Wait, the prompt asks for \"this week\". If the current date is June 13, 2026, June 4 is la
... response truncated ...

</details>

Parameters

Schema variant

Chat CompletionsResponses

▶messages[]

arrayrequired

temperature

numberminimum: 0maximum: 2

max_tokens

numberexclusiveMinimum: 0

max_completion_tokens

numberexclusiveMinimum: 0

top_p

numberminimum: 0maximum: 1

frequency_penalty

numberminimum: -2maximum: 2

presence_penalty

numberminimum: -2maximum: 2

stream

boolean

▶stream_options{}

object

▶tools[]

array

tool_choice

response_format

▶modalities[]

array

▶audio{}

object

reasoning_effort

stringOptional reasoning control; availability and accepted values are model-dependent.

▶input

one ofrequired

instructions

string

temperature

numberminimum: 0maximum: 2

max_output_tokens

numberexclusiveMinimum: 0

top_p

numberminimum: 0maximum: 1

stream

boolean

▶tools[]

array

tool_choice

▶text{}

object

▶reasoning{}

object

id

string

object

string

created

number

model

string

▶choices[]

array

▶usage{}

object

id

string

object

stringconst: response

created_at

number

model

string

▶output[]

array

output_text

string

status

stringenum: in_progress, completed, failed, incomplete

▶usage{}

object

API Schemas (Raw)

Input Open Download

Output Open Download

Was this helpful?

YesNo

On this page

Output: 3, 2, 1, Blastoff! - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/alibaba/qwen3.5-397b-a17b/#page","headline":"Qwen 3.5 397B A17B","description":"Alibaba's Qwen 3.5 is a 397B-parameter mixture-of-experts model with 17B active parameters, offering strong reasoning capabilities with efficient inference.","url":"https://developers.cloudflare.com/ai/models/alibaba/qwen3.5-397b-a17b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Alibaba's Qwen 3.7 Max is the largest and most capable model in the Qwen3.7 series, a next-generation flagship built for the agent-centric era with deep strengths in programming, office and productivity tasks, and long-term autonomous execution, served via DashScope's OpenAI-compatible endpoint. title: Qwen 3.7 Max image: https://developers.cloudflare.com/og-docs.png


Skip to content

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

Alibaba logo