thezakuloGet the newsletter
← All setup guides

Setup guide · 4 steps · about 10 minutes

How to start using Qwen: Qwen4 Max

Qwen4 Max is the flagship model in Alibaba's Qwen4 series that accepts text, image, and video input and returns text, with a 1M-token context window, reasoning on by default, tool calling, and structured outputs.

Built from the official docs: openrouter.ai · Qwen4 Max - API Pricing & Benchmarks · checked 20 November 2026

Through OpenRouter

  1. Get an API key

    Sign up at OpenRouter and create an API key to authenticate your requests.

    https://openrouter.ai/
  2. Call the API directly with cURL

    Send an HTTP POST to the OpenRouter responses endpoint with the model slug qwen/qwen4-max. The HTTP-Referer and X-OpenRouter-Title headers are optional and only affect leaderboard attribution.

    curl https://openrouter.ai/api/v1/responses \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer <OPENROUTER_API_KEY>" \
      -d '{
      "model": "qwen/qwen4-max",
      "input": "What is the meaning of life?"
    }'
  3. Or use the OpenAI SDK as a drop-in

    Point the OpenAI SDK at the OpenRouter base URL to call the model without changing your code structure.

    pip install openai
  4. Call the model from Python

    Set the base URL to OpenRouter, pass your key, and request the qwen/qwen4-max model.

    from openai import OpenAI
    
    client = OpenAI(
      base_url="https://openrouter.ai/api/v1",
      api_key="<OPENROUTER_API_KEY>",
    )
    
    response = client.responses.create(
      model="qwen/qwen4-max",
      input="What is the meaning of life?"
    )
    
    print(response.output_text)

Check it worked

The response JSON has status "completed" and contains a message item whose content includes an output_text with the model's reply.

Try these first

Get every issue by email

One email a week with the written issue. Free, one-click unsubscribe

Subscribe