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

立即开始

Windsurf 现在可以生成图像了

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

从实际示例开始

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

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

示例提示词 01

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

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

示例提示词 02

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

将这片高山湖泊画成松散的水彩画。保留山峰和倒影,柔化松树,并让晨光更温暖。

示例提示词 03

将这片高山湖泊画成松散的水彩画。保留山峰和倒影,柔化松树,并让晨光更温暖。

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

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

你会得到什么

一项复制粘贴技能

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

本地文件已处理

智能体通过 multip 请求上传你项目中的一张照片,然后将返回的 id 传入生成流程。JPEG、PNG 和 WebP 格式的上限为 30 MB。位于仓库中的文件无需先获得公开 URL。

图像和视频,一个密钥

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

比聊天更持久的职位

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

简明英语请求

请求生成方形产品图或竖版社交短片。该技能会将你的描述映射到模型、分辨率、时长和宽高比,然后在花费前核对实时价格矩阵。当任务有需要时,你仍然可以指定精确设置。智能体会将所选设置反馈给你,这让意外结果更容易诊断。

一份价格表

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

工作原理

1

创建并导出密钥

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

2

粘贴技能

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

3

说出你需要什么

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

4

投票并使用结果

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

将 DreamUtopia Skill 粘贴到 Windsurf 中

复制下面的技能并粘贴到 Windsurf 聊天中。此后在整个对话中,代理就能了解 API 接口、错误规则以及何时不应重试。

Paste into Windsurf
Download
> Paste this into the Windsurf 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/windsurf.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服务器才能在Windsurf中使用DreamUtopia吗?

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

技能文件在 Windsurf 中应该放在哪里?

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

Windsurf 可以上传本地图片吗?

▼
是的。让它使用项目中的文件。代理会发送一个 multipart 上传,收到一个上传 id,并在生成过程中使用该 id。接受 JPEG、PNG 和 WebP,最大 30 MB。

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

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

积分是如何扣除的?

▼
任务创建时会扣除积分,若任务失败则会返还。实时价格矩阵位于 GET /v1/models,当你询问费用时,该 skill 会查询它。创建密钥前需要拥有付费账户。

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

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

撤销密钥安全吗?

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

给 Windsurf 一个媒体工具

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