File size: 4,329 Bytes
61e31a5
66b053e
 
61e31a5
66b053e
61e31a5
 
 
 
66b053e
61e31a5
 
4ba0b46
66b053e
4ba0b46
66b053e
4ba0b46
66b053e
4ba0b46
 
 
 
66b053e
4ba0b46
66b053e
4ba0b46
 
 
 
66b053e
4ba0b46
 
 
 
 
 
66b053e
4ba0b46
 
66b053e
4ba0b46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66b053e
4ba0b46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66b053e
 
4ba0b46
66b053e
4ba0b46
66b053e
4ba0b46
 
66b053e
4ba0b46
66b053e
4ba0b46
 
 
 
 
 
 
 
 
 
 
 
66b053e
4ba0b46
66b053e
 
 
 
 
 
4ba0b46
66b053e
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
title: HunyuanImage-3.0
emoji: 🎨
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 5.44.0
app_file: app.py
pinned: false
short_description: Text-to-Image generation using Tencent HunyuanImage-3.0
---

# 🎨 HunyuanImage-3.0 Text-to-Image with Inference API

This Space provides an interface for the **Tencent HunyuanImage-3.0** model using Hugging Face Inference API (paid from your account balance).

## βœ… What's New

- **Real image generation** using HF Inference API
- **n8n integration** via REST API endpoint
- **Base64 image output** for easy integration
- **Automatic token-based authentication**

## πŸ”§ Setup Instructions

### 1. Get Your HF Token
1. Go to [Hugging Face Settings > Access Tokens](https://huggingface.co/settings/tokens)
2. Create a new token with `write` permissions
3. Copy the token (starts with `hf_...`)

### 2. Set Your Token in Space
1. Go to [Settings](https://huggingface.co/spaces/Alae65/HunyuanImage-3/settings)
2. Find "Variables and secrets" section
3. Click "Replace" next to HF_TOKEN
4. Paste your actual token (replace the placeholder)
5. Click "Save"

### 3. Restart the Space
After setting the token, click "Restart space" in Settings.

## πŸ“‘ API Endpoint for n8n Integration

### Using the Gradio API

The Space provides a REST API that can be called from n8n using the HTTP Request node.

**Endpoint URL:**
```
https://alae65-hunyuanimage-3.hf.space/gradio_api/call/api_generate
```

### n8n HTTP Node Configuration

1. Add an **HTTP Request** node in n8n
2. Configure as follows:

**Method:** POST

**URL:**
```
https://alae65-hunyuanimage-3.hf.space/gradio_api/call/api_generate
```

**Body (JSON):**
```json
{
  "data": [
    "A serene mountain landscape with a crystal clear lake",
    42,
    50
  ]
}
```

**Parameters:**
- `data[0]` (string): Your image prompt
- `data[1]` (integer): Seed number (for reproducibility)
- `data[2]` (integer): Number of inference steps (10-100)

**Response Format:**
The API returns a JSON with:
```json
{
  "success": true,
  "image_base64": "iVBORw0KGgoAAAANSUhEUg...",
  "seed": 42,
  "status": "Success!",
  "prompt": "A serene mountain landscape..."
}
```

### Example n8n Workflow

1. **Trigger** β†’ Webhook or Schedule
2. **HTTP Request** β†’ Call HunyuanImage API
3. **Code** β†’ Decode base64 image if needed
4. **Save or Send** β†’ Store image or send via email/Slack

### Python Example

```python
import requests
import base64
from PIL import Image
from io import BytesIO

url = "https://alae65-hunyuanimage-3.hf.space/gradio_api/call/api_generate"

payload = {
    "data": [
        "A beautiful sunset over the ocean",
        42,
        50
    ]
}

response = requests.post(url, json=payload)
result = response.json()

if result.get("success"):
    # Decode base64 image
    image_data = base64.b64decode(result["image_base64"])
    image = Image.open(BytesIO(image_data))
    image.save("output.png")
    print("Image saved successfully!")
```

## 🎯 Features

- 🎯 Advanced prompt understanding
- πŸ–ΌοΈ Multiple resolution support
- 🎲 Seed control for reproducibility
- βš™οΈ Configurable diffusion steps (10-100)
- πŸ“ Example prompts included
- πŸ”Œ REST API for n8n and automation
- πŸ“¦ Base64 image encoding

## πŸ’° Pricing

This Space uses the **Hugging Face Inference API** which is billed based on usage:
- Cost is deducted from your HF account balance
- You mentioned having $9 credit available
- Check [Billing Settings](https://huggingface.co/settings/billing) for details

## πŸ“š Model Information

- **Model:** [tencent/HunyuanImage-3.0](https://huggingface.co/tencent/HunyuanImage-3.0)
- **Architecture:** Autoregressive MoE (64 experts)
- **Parameters:** 80B total, 13B active per token
- **License:** tencent-hunyuan-community
- **Paper:** [arXiv:2509.23951](https://arxiv.org/abs/2509.23951)

## πŸ”— Links

- [Official Website](https://hunyuan.tencent.com/image)
- [GitHub Repository](https://github.com/Tencent-Hunyuan/HunyuanImage-3.0)
- [Technical Paper](https://arxiv.org/pdf/2509.23951)
- [Model Card](https://huggingface.co/tencent/HunyuanImage-3.0)

## πŸ“ Citation

```bibtex
@article{cao2025hunyuanimage,
  title={HunyuanImage 3.0 Technical Report},
  author={Cao, Siyu and Chen, Hangting and others},
  journal={arXiv preprint arXiv:2509.23951},
  year={2025}
}
```