🎉 每个积分包首次购买都有免费生成好礼 —— 最高 20 个 Lite 视频 + 20 张 Lite 图片 + 10 个 Medium 视频 + 10 张 Pro 图片 + 2 个 Pro 视频。

立即开始

Cursor 现在可以生成图像了

Cursor 已经在编辑你的代码。借助 DreamUtopia REST API,同一个会话可以创建主视觉图像、重塑产品图的风格,或将一张静态图变成一段八秒的视频。粘贴一个技能文件,用自然语言提出需求,智能体便会处理上传、请求和轮询。

从实际示例开始

这些是本页示例所使用的提示词。打开生成器,选择一个示例,然后逐一调整细节。

请将这片暴风雨中的海岸重新绘制成黄昏景象。保留灯塔和黑色礁石,让光束穿过海雾,并加深风暴云层。

示例提示词 01

请将这片暴风雨中的海岸重新绘制成黄昏景象。保留灯塔和黑色礁石,让光束穿过海雾,并加深风暴云层。

把这个厨房台面变成一个舒适的秋日场景。保留白色马克杯和木质台面,添加散落的肉桂棒、一块亚麻布,以及更温暖的低角度阳光。

示例提示词 02

把这个厨房台面变成一个舒适的秋日场景。保留白色马克杯和木质台面,添加散落的肉桂棒、一块亚麻布,以及更温暖的低角度阳光。

将这处高山湖泊画成 loose watercolor。保留山峰和倒影,柔化松树,并让晨光更温暖。

示例提示词 03

将这处高山湖泊画成 loose watercolor。保留山峰和倒影,柔化松树,并让晨光更温暖。

光标图像生成,无需离开编辑器

当 agent 可以直接调用媒体 API 时,Cursor 图像生成就变成了编码会话中的常规部分。编码 agent 擅长运行命令、读取响应并智能重试,而这正是媒体 API 所需要的。你不必离开编辑器去打开一个 Web 应用,而是可以在同一段对话中向 Cursor 请求一张 16:9 的页眉图片,并拿回一个结果 URL。正因如此,我们把 DreamUtopia API 构建为纯 REST。无需配置 MCP 服务器,也无需安装插件。技能文件会教会 agent 基础 URL、认证头、multipart 上传、两个创建端点、轮询循环以及错误规则。粘贴一次技能文件、设置一个环境变量,就是全部配置。同一个密钥也可用于你自己的脚本,这意味着 agent 和你的构建流水线共享同一套集成和同一个额度余额。当一项设计任务从聊天开始、到部署脚本结束时,这一点很重要:两端之间的请求形态不会改变。该工作流也契合编码 agent 已有的工作方式:请求就是一条普通的 shell 命令,失败就是一个普通的 HTTP 状态码,长任务就是一个普通的待轮询 id。这意味着 Cursor 可以用它解释失败测试时同样的口吻来解释一次失败,并且可以把生成的素材放在引用它的代码旁边。对于一个设计密集的仓库来说,这种差别是实际性的,而非表面性的:编写组件的人同时也是能够产出所需图片的人,无需切换工具,也不会丢失变更的上下文。Cursor 可以运行请求、读取 JSON 响应并解释失败,而无需离开你正在编辑的文件。这个反馈循环正是关键所在:agent 已经知道如何运行命令并解读结果,因此媒体生成就成了它可以使用的又一个工具。

你会得到什么

一项复制粘贴技能

将下面的技能块粘贴到 Cursor 聊天中。智能体在接下来的对话中会按照该配方执行,无需额外提示。文本足够短,可以一次性读完,也足够具体,智能体不会自行编造字段名。它明确说明每个字段接受的确切值,因此格式错误的请求会在到达 API 之前被纠正。不会向你的仓库写入任何内容,也不会安装任何东西。

本地文件已处理

代理通过多部分请求上传您项目中的照片,然后将返回的 id 传入生成过程。JPEG、PNG 和 WebP 的限制为 30 MB。位于仓库中的文件永远不需要先获得公共 URL。

图像和视频,一个密钥

文生图、图生图、文生视频、图生视频以及首尾帧过渡都使用同一个密钥和同一个积分余额。你无需为静态图像和动态视频分别管理账户,而且该技能可以将一张已完成的图像串联到下一个视频请求中。

比聊天更持久的职位

每次生成都在我们的服务器上运行。如果会话结束,代理可以按 id 列出最近的作业,并在稍后收集结果。签名后的结果链接有效期为七天,足以将其下载或复制到构建产物中。

通俗易懂的请求

要求提供方形产品图或竖版社交短片。该技能会将你的描述映射到模型、分辨率、时长和宽高比,然后在花费之前检查实时价格矩阵。当任务需要时,你仍然可以指定确切的设置。代理会向你回报所选的设置,这让意外结果更容易诊断。

一份价格表

API 和 Web 应用扣除相同的积分。GET /v1/models 返回实时的分辨率、时长和积分矩阵,因此智能体可以在创建任何内容之前,比较五秒片段与十秒片段。

工作原理

1

创建并导出密钥

打开 Profile,然后打开 API keys,并创建一个有名称的密钥。在启动 Cursor 的 shell 中将其导出为 DREAMUTOPIA_API_KEY。密钥仅对付费账户可用,只显示一次,并且可以在不影响其他集成的情况下撤销。

2

粘贴技能

复制下面的内容块并粘贴到 Cursor 聊天中。代理随后会知道该对话的端点、字段名和轮询规则。该技能还说明了不该做什么:不要重试被拒绝的任务,也不要把密钥粘贴到对话中。在新的会话中重复粘贴;不会向你的仓库添加任何内容。

3

说出你需要什么

写一个普通请求:生成一张雪地中红狐的 2K 图像,或将 ./photo.png 转换为带缓慢推镜的 720p 片段。智能体会选择设置,可以先检查 /v1/models,并在源为本地文件时处理上传。如果请求含义不明确,它会提出一个简短问题,而不是猜测时长或宽高比。

4

投票并使用结果

该代理轮询 GET /v1/generations/{id},直到任务成功,然后返回带签名的结果 URL。它在每次轮询之间进行退避,并在遇到编辑器故障时停止,而不是重试内容策略拒绝或已耗尽的 credit 余额。最终答案既包含 job id 也包含链接,因此即使对话已不存在,结果仍可再次找到。

将 DreamUtopia Skill 粘贴到 Cursor 中

复制下面的技能,并将其粘贴到 Cursor 聊天中。此后,代理便能在本次对话的剩余时间内了解 API 接口面、错误规则以及何时不应重试。

Paste into Cursor
Download
> Paste this into the Cursor chat. It teaches the agent the DreamUtopia API for the
> rest of the conversation. Keep the `DREAMUTOPIA_API_KEY` in your shell environment,
> not in the pasted text.

# DreamUtopia media generation

Use this skill when the user asks you to generate an image or a video with DreamUtopia.

## Prerequisites

- **API access requires a paid account.** Keys cannot be minted by a free account.
- The user sets their key in the environment:

  ```sh
  export DREAMUTOPIA_API_KEY="du_live_..."
  ```

  If `DREAMUTOPIA_API_KEY` is unset, **stop and ask the user to set it**. Never write the key
  into a project file, a commit, or a message.
- Base URL: `https://api.dreamutopia.net/v1`
- Every request sends `Authorization: Bearer $DREAMUTOPIA_API_KEY`.

## Keeping this skill current

This skill is served by the product and can change without notice. If a request fails in a way
this document does not describe — an unknown field, an unexpected status or error code, or a
route that returns `404` — the skill may be stale. Re-fetch it, paste the new version into the
conversation, and re-read it before retrying:

```sh
curl -fsSL https://dreamutopia.net/skills/dreamutopia/cursor.md
```

Do not invent request fields from memory. The re-fetched file is the current contract; the copy
in the conversation is only a snapshot.

## 1. Upload a local reference image (optional)

Only needed when the user has a local file. A previous generation's `result.url` can be used
directly instead.

```sh
curl -sS -X POST https://api.dreamutopia.net/v1/uploads \
  -H "Authorization: Bearer $DREAMUTOPIA_API_KEY" \
  -F "file=@/path/to/photo.png"
```

Response `201`:

```json
{ "id": "<upload_id>",
  "url": "<upload_url>",
  "expires_at": "2026-10-31T12:00:00Z" }
```

Use `id` (not `url`) in the next request. Accepted: JPEG, PNG, WebP, up to 30 MB.
`id` only works for the account that uploaded it.

## 2. Create an image

```sh
curl -sS -X POST https://api.dreamutopia.net/v1/images/generations \
  -H "Authorization: Bearer $DREAMUTOPIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "lite",
    "prompt": "a red fox in fresh snow, cinematic",
    "resolution": "2k",
    "aspect_ratio": "1:1"
  }'
```

| Field | Values |
|---|---|
| `model` | `lite`, `pro` |
| `resolution` | `2k`, `4k` (`lite` accepts `2k` only) |
| `aspect_ratio` | `1:1`, `4:3`, `3:4`, `16:9`, `9:16`, `3:2`, `2:3`, `adaptive` |
| `reference_images` | array of upload ids or DreamUtopia URLs; 0–3 for `lite`, 0–14 for `pro` |
| `prompt` | non-empty, up to 8000 characters |

`adaptive` requires at least one reference image. `resolution` defaults to `2k` and
`aspect_ratio` to `1:1`.

Response `202`:

```json
{ "id": "3f2b…", "type": "image", "status": "queued", "created_at": "2026-10-24T12:00:00Z" }
```

## 3. Create a video

```sh
curl -sS -X POST https://api.dreamutopia.net/v1/videos/generations \
  -H "Authorization: Bearer $DREAMUTOPIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "medium",
    "prompt": "the fox turns and looks at the camera",
    "image": "<upload_id>",
    "resolution": "720p",
    "duration": 8
  }'
```

| Field | Values |
|---|---|
| `model` | `lite`, `medium`, `pro` |
| `resolution` | `480p`, `720p`, `1080p` (`lite` cannot use `1080p`) |
| `duration` | 5–10 seconds (`lite`), 5–15 (`medium`), 5–30 (`pro`) |
| `image` | first-frame upload id or DreamUtopia URL (omit for text-to-video) |
| `last_frame_image` | requires `image`; not supported by `lite` |
| `generate_audio` | `pro` only, and the account must hold premium; `lite` and `medium` are rejected |

Response `202` with `type: "video"`.

## 4. Poll until it finishes

```sh
curl -sS https://api.dreamutopia.net/v1/generations/$MID \
  -H "Authorization: Bearer $DREAMUTOPIA_API_KEY"
```

`status` is one of `queued`, `processing`, `succeeded`, `failed`.

- Poll every 3–5 seconds, backing off to 10 seconds. Give up after about 10 minutes.
- On `succeeded`, download `result.url`. The link is valid for 7 days.
- On `failed`, report `error.message` to the user and stop. A failed job is terminal; do
  **not** submit it again automatically.
- If an id is lost, `GET /generations?limit=20` lists recent jobs, newest first.

Terminal response:

```json
{
  "id": "3f2b…",
  "type": "video",
  "status": "succeeded",
  "model": "medium",
  "credits_used": 12,
  "created_at": "2026-10-24T12:00:00Z",
  "updated_at": "2026-10-24T12:02:10Z",
  "result": { "url": "<result_url>" },
  "error": null
}
```

## 5. Check credits and prices

```sh
curl -sS https://api.dreamutopia.net/v1/account -H "Authorization: Bearer $DREAMUTOPIA_API_KEY"
curl -sS https://api.dreamutopia.net/v1/models
```

`/models` is public and returns every tier's allowed resolutions and durations plus the
`resolution → duration → credits` matrix. Check it before choosing settings when the user
cares about cost.

## Errors

Every error body is exactly:

```json
{ "error": { "code": "insufficient_credits", "message": "You need more credits to generate." } }
```

| HTTP | Meaning |
|---|---|
| 400 | invalid input (`invalid_request`, `prompt_too_long`, `invalid_reference_image`, …) |
| 401 | missing, malformed, revoked or removed-account key |
| 402 | not enough credits |
| 403 | unpaid key creation, or audio requested without premium |
| 404 | unknown job, or a job belonging to another account |
| 409 | `Idempotency-Key` reused with a different body, or still in flight |
| 413 / 415 | upload too large / not a supported image |
| 429 | rate limited; read `Retry-After` |
| 500 / 503 | internal; retry later |

Retry only HTTP `429`, `timeout` and `internal` responses. Never retry
`insufficient_credits`, and never resubmit a job that already finished as `failed`.

## Idempotency

Send `Idempotency-Key: <unique value>` on a create request. A retry with the same key and
body returns the existing job (`200`) instead of creating and charging a second one. Use a
fresh value for every genuinely different request.

## Complete example

```sh
#!/usr/bin/env bash
set -euo pipefail
: "${DREAMUTOPIA_API_KEY:?set DREAMUTOPIA_API_KEY first}"
API="https://api.dreamutopia.net/v1"

ID=$(curl -sS -X POST "$API/images/generations" \
  -H "Authorization: Bearer $DREAMUTOPIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"lite","prompt":"a red fox in fresh snow","resolution":"2k","aspect_ratio":"1:1"}' \
  | jq -r .id)

while :; do
  BODY=$(curl -sS "$API/generations/$ID" -H "Authorization: Bearer $DREAMUTOPIA_API_KEY")
  STATUS=$(jq -r .status <<<"$BODY")
  case "$STATUS" in
    succeeded) jq -r .result.url <<<"$BODY"; break ;;
    failed)    jq -r .error.message <<<"$BODY" >&2; exit 1 ;;
    *)         sleep 4 ;;
  esac
done
```

探索相关工具

选择适合你下一步创作的工具。

常见问题

由DreamUtopia团队 · 更新于 2026年11月15日

我需要 MCP 服务器才能在 Cursor 中使用 DreamUtopia 吗?

▼
不。该 API 是纯 HTTP 的,而该技能教 Cursor 用 curl 调用它。你不需要 MCP 服务器、CLI 二进制文件或插件。唯一的设置就是粘贴该技能和环境变量。

技能文件应该放在 Cursor 的什么位置?

▼
将技能块粘贴到 Cursor 聊天中。它对该对话生效;在新会话中请重复粘贴。不会向你的代码库添加任何内容,也无需创建任何文件。请将 API 密钥以 DREAMUTOPIA_API_KEY 的形式保存在 shell 环境中,不要放在粘贴的文本中。

Cursor 可以上传本地图片吗?

▼
可以。让它使用项目中的文件。智能体会发送多部分上传,接收一个上传 ID,并在生成中使用该 ID。接受 JPEG、PNG 和 WebP,最大 30 MB。

该技能是否既能生成视频也能生成图像?

▼
是的。同一个密钥涵盖文生视频和图生视频,时长从五秒到十五秒不等,具体取决于模型层级。首尾帧过渡在更高层级上可用。

积分是如何扣除的?

▼
任务创建时扣费,失败时退还。实时价格矩阵位于 GET /v1/models,当你询问费用时该技能会检查它。创建密钥前需要拥有付费账户。

如果我关闭会话会发生什么?

▼
任务会在我们的服务器上继续运行。使用 GET /v1/generations/{id} 并传入该 id,或用 GET /v1/generations?limit=20 列出最近的任务。已签名的结果 URL 有效期为七天。

撤销密钥安全吗?

▼
是的。撤销会立即阻止新请求,且不影响正在运行的任务。一个账户可以持有多个密钥,因此可以停用某个集成而不影响其他集成。

给 Cursor 一个媒体工具

创建密钥,粘贴技能,然后请求你的第一张图片。API 文档涵盖每个字段、状态和错误代码。