Create and Run a Text-to-Image Workflow in Coze: Step-by-Step Guide

This tutorial walks you through logging into Coze, building a text‑to‑image workflow with start, image generation, and end nodes, testing and publishing it, then generating a personal access token and invoking the workflow via the Coze API to retrieve the image URL.

AI Software Product Manager
AI Software Product Manager
AI Software Product Manager
Create and Run a Text-to-Image Workflow in Coze: Step-by-Step Guide

First, log into Coze (https://www.coze.cn/), go to Workspace / Resource Library, and create a new workflow named text2image (English only) with a description.

Create workflow screen
Create workflow screen

The workflow consists of a start node and an end node.

Workflow nodes diagram
Workflow nodes diagram

2.1 Add Image Generation Node

Add image generation node
Add image generation node

2.2 Connect Nodes

Link the start node to the image generation node and then to the end node.

Connect nodes
Connect nodes

2.3 Configure Image Generation Node

Model: portrait

Aspect ratio: 1:1

Input: add a variable and select “Start” as its value

Prompt: use {{variable_name}} to reference the variable

Configure image node
Configure image node

2.4 Configure End Node

Set the output to return the data field from the image generation node.

Configure end node
Configure end node

3 Test the Workflow

Run the workflow to verify it works. Adjust the input prompt (e.g., “a long‑haired woman in yoga pants standing next to a golf car”) until the generated image matches the description. If the output is empty, the generation failed and you should retry.

Test workflow result
Test workflow result

4 Publish the Workflow

After publishing, the workflow details page shows the workflow ID, for example workflow_id=7529898597627412506.

Published workflow details
Published workflow details

5 Coze API

5.1 Add Personal Access Token

Create a token by giving it a name, setting an expiration time, choosing the required permissions, and selecting the workspace. Copy the generated token (e.g.,

pat_b4hgp9Rn6iMYZUSmbTZih6YHdEkvNwZTm5SLja2aUIrdhL4jkIFvVvOKOGMmfZox

) because it cannot be retrieved later.

Create personal access token
Create personal access token

5.2 Run the API

Send a request containing the token, the workflow ID, and the required input parameters for the start node. The API returns a JSON object whose data field contains the image URL.

API request example
API request example
{
  "code":0,
  "cost":"0",
  "data":"{output":"https://s.coze.cn/t/WkLTawwU0H4/"}",
  "debug_url":"https://www.coze.cn/work_flow?execute_id=7529910616715886601&space_id=7529344229806686244&workflow_id=7529898597627412506&execute_mode=2",
  "msg":"Success",
  "token":0
}

Paste the output URL into a browser to view the generated image.

AItext-to-imageAPICoze
AI Software Product Manager
Written by

AI Software Product Manager

Daily updates of Xiaomi's latest AI internal materials

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.