image generation

Qwen LogoQwen Image

Ultra-realistic text-to-image model by Qwen

Model details

View repository

Example usage

The Qwen Image model is a diffusion-based text-to-image model that can generate high-quality images from text prompts. The model outputs a base64 string which can be saved locally.

Input
1import httpx
2import os
3import base64
4from PIL import Image
5from io import BytesIO
6
7# Replace with your model ID and API key
8model_id = "your-model-id"
9baseten_api_key = os.environ["BASETEN_API_KEY"]
10
11def b64_to_pil(b64_str):
12    """Convert base64 string to PIL image"""
13    return Image.open(BytesIO(base64.b64decode(b64_str)))
14
15# Example 1: English prompt
16english_data = {
17    "prompt": "A fashionably dressed man on the streets of New York City holds a sign that says `Qwen Image on Baseten`",
18    "width": 1664,
19    "height": 928,
20    "num_inference_steps": 50,
21    "seed": 42
22}
23
24# Example 2: Chinese prompt
25chinese_data = {
26    "prompt": "一只可爱的小猫坐在花园里,阳光明媚",
27    "width": 1024,
28    "height": 1024,
29    "num_inference_steps": 50
30}
31
32# Call the model with extended timeout for image generation
33print("Generating image... This may take a moment.")
34response = httpx.post(
35    f"https://model-{model_id}.api.baseten.co/development/predict",
36    headers={"Authorization": f"Api-Key {baseten_api_key}"},
37    json=english_data,
38    timeout=httpx.Timeout(120.0)
39)
40
41# Get the result
42result = response.json()
43image_b64 = result.get("data")
44
45# Convert to image and save
46image = b64_to_pil(image_b64)
47image.save("generated_image.jpg")
48print("Image generated successfully! Saved as 'generated_image.jpg'")
JSON output
1{
2    "data": "base64_string"
3}
Preview
Qwen Image on Baseten

image generation models

See all
Qwen Logo
Image generation

Qwen Image

Text-to-Image
Fotographer AI
Image generation

ZenCtrl

Custom Server - H100
ByteDance logo
Image generation

SDXL Lightning

1.0 - Lightning - A100

Qwen models

See all
Qwen Logo
Image generation

Qwen Image

Text-to-Image
Qwen Logo
Model API
LLM

Qwen3 235B 2507

2507
Qwen Logo
Model API
LLM

Qwen3 Coder 480B

🔥 Trending models