# alibaba/qwen-image-2-1-pro

Source: https://docs.sociaro.com/models/alibaba-qwen-image-2-1-pro/

Qwen Image 2.1 Pro text-to-image AND image editing. prompt (required); image_urls (1-10 public https images to edit or combine; the first is "Image 1"); size ("width\*height", total pixels between 512x512 and 2048x2048); n (the vendor's own count, 1-6 — the charge follows the number of images it reports producing, and the poll lists every one of them in media_urls; media_url is the first); prompt_extend (def true); prompt_extend_mode direct (def) | agent; enable_thinking (def true); seed; watermark (def false).

Parameters the vendor accepts pass through; one it refuses is refused in its own words.

One flat price per image, whatever the size.

Served via the relay: POST /v1/alibaba/generations, poll GET /v1/alibaba/generations/{task_id}. Per-image pricing billed by the relay from the number of images the vendor reports.

|  |  |
| --- | --- |
| Slug | `alibaba/qwen-image-2-1-pro` |
| Kind | image |
| Vendor | alibaba |
| Endpoint | `POST /v1/alibaba/generations` |

[View pricing and billing conditions](https://docs.sociaro.com/models/alibaba-qwen-image-2-1-pro/#pricing)

## Example request

cURL

```bash
curl https://api.sociaro.com/v1/alibaba/generations \
  -H "Authorization: Bearer $SOCIARO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "alibaba/qwen-image-2-1-pro",
        "prompt": "a paper boat on a rain-soaked street"
      }'

# then poll the job id it returns:
curl https://api.sociaro.com/v1/alibaba/generations/JOB_ID \
  -H "Authorization: Bearer $SOCIARO_API_KEY"
```

Python

```python
# Requires Python 3 and requests (pip install requests).
import os
import time
import requests

payload = {'model': 'alibaba/qwen-image-2-1-pro',
 'prompt': 'a paper boat on a rain-soaked street'}

response = requests.post(
    'https://api.sociaro.com/v1/alibaba/generations',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
    },
    json=payload,
    timeout=120,
)
response.raise_for_status()
submitted = response.json()
job_id = submitted['job_id']
print(submitted)

# then poll the job id it returns:
while True:
    response = requests.get(
        'https://api.sociaro.com/v1/alibaba/generations/' + job_id,
        headers={
            'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        },
        timeout=120,
    )
    response.raise_for_status()
    result = response.json()
    status = result['status']
    if status == 'completed':
        break
    if status not in ('submitted', 'processing'):
        raise RuntimeError(result)
    time.sleep(5)
print(result)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.
let jobId;
let result;

{
  const payload = {
    "model": "alibaba/qwen-image-2-1-pro",
    "prompt": "a paper boat on a rain-soaked street"
  };
  
  const response = await fetch("https://api.sociaro.com/v1/alibaba/generations", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const submitted = await response.json();
  jobId = submitted.job_id;
  console.log(submitted);
}

// then poll the job id it returns:
{
  while (true) {
    const response = await fetch("https://api.sociaro.com/v1/alibaba/generations/" + jobId, {
      headers: {
        "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
      },
    });
    if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    result = await response.json();
    const status = result.status;
    if (status === "completed") break;
    if (!["submitted", "processing"].includes(status)) throw new Error(JSON.stringify(result));
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
  console.log(result);
}
```

## Parameters

- `prompt`
- `image_urls`
- `size`
- `n`
- `watermark`
- `seed`
- `prompt_extend`
- `prompt_extend_mode`
- `enable_thinking`

The endpoint rejects unknown request fields.

## Pricing

| Billable unit and options | Rate (USD) |
| --- | --- |
| per image | $0.04 |

[View this model in the pricing catalogue](https://sociaro.com/pricing?model=alibaba%2Fqwen-image-2-1-pro). Your [billing logs](https://docs.sociaro.com/billing/index.md) show the actual charge for each request.
