> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rixapi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Midjourney 快速上手

> 生成第一组图，取回结果，再接着放大、变化或做成视频

Midjourney 新建任务的能力各是一个接口：`/midjourney/imagine` 生成、`/midjourney/blend` 融合、`/midjourney/video` 做视频……放大、变化这些加工已有图片的操作统一调 `/midjourney/action`。提交后拿到任务 ID，再查询结果。本文带你跑通第一组图。

## 生成第一组图

提示词照你在 Midjourney 里的习惯写，`--ar`、`--sref`、`--niji` 这些参数直接写在里面。

```bash bash theme={null}
curl https://api.ephone.ai/midjourney/imagine \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a red bicycle leaning on a brick wall, morning light --ar 3:2"
  }'
```

```python imagine.py theme={null}
import requests

resp = requests.post(
    "https://api.ephone.ai/midjourney/imagine",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"prompt": "a red bicycle leaning on a brick wall, morning light --ar 3:2"},
)
task_id = resp.json()["task_id"]
```

```javascript imagine.js theme={null}
const resp = await fetch("https://api.ephone.ai/midjourney/imagine", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "a red bicycle leaning on a brick wall, morning light --ar 3:2",
  }),
});
const { task_id } = await resp.json();
```

返回任务 ID：

```json theme={null}
{
  "task_id": "mj-0cd1cef934d741b4ab3643ed25515a90",
  "action": "imagine",
  "status": "submitted",
  "prompt": "a red bicycle leaning on a brick wall, morning light --ar 3:2 --v 8.2",
  "created_at": 1792154579
}
```

> [!NOTE]
>
> 提示词里没写版本时会补上 `--v 8.2`（Midjourney 现在的默认版本），返回的 `prompt` 就是实际提交的内容。

## 取回结果

生成是异步的，用任务 ID 查询：

```bash theme={null}
curl https://api.ephone.ai/midjourney/task/mj-0cd1cef934d741b4ab3643ed25515a90 \
  -H "Authorization: Bearer $API_KEY"
```

`status` 依次是 `submitted`（排队）、`in_progress`（生成中）、`success` 或 `failure`。快速模式一组图通常一分钟左右。完成后：

```json theme={null}
{
  "task_id": "mj-0cd1cef934d741b4ab3643ed25515a90",
  "action": "imagine",
  "status": "success",
  "prompt": "a red bicycle leaning on a brick wall, morning light --ar 3:2 --v 8.2",
  "images": [
    "https://.../1.png",
    "https://.../2.png",
    "https://.../3.png",
    "https://.../4.png"
  ],
  "seed": 3277589003,
  "actions": ["upscale", "variation", "remix", "zoom", "pan", "inpaint", "video", "reroll"],
  "created_at": 1792154579,
  "finished_at": 1792154629
}
```

* `images` 是四张独立的图，不是拼好的宫格，可以直接下载使用。
* 失败时 `status` 为 `failure`，原因在 `fail_reason`，费用会退回。

不想轮询的话，提交时带上 `notify_hook`（你的接收地址），任务结束后我们会把和查询结果相同的内容 POST 过去。

## 接着加工

`actions` 列出这个任务还能接着做的加工。调 `/midjourney/action`，`action` 填其中一个，再传 `task_id`；对某一张图操作时还要传 `index`（第几张，从 1 开始）：

```bash theme={null}
curl https://api.ephone.ai/midjourney/action \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "upscale",
    "task_id": "mj-0cd1cef934d741b4ab3643ed25515a90",
    "index": 2
  }'
```

返回一个新的任务 ID，查询方式完全相同。新任务完成后也有自己的 `actions`，可以一直接下去：放大第 2 张 → 对放大后的图扩图 → 再做成视频。

> [!TIP]
>
> 不需要像以前那样从按钮里拼 `custom_id`。`actions` 里有的操作就能做，没有的会返回 `unsupported_action`。

## 选择速度

用 `speed` 参数选速度，不填默认 `fast`：

| 取值 | 说明 |
| - | - |
| `relax` | 慢速，要排队，按快速价格的 0.4 倍计费 |
| `fast` | 快速，默认 |
| `turbo` | 极速，出图更快，按快速价格的 2 倍计费 |

```json theme={null}
{ "prompt": "a red bicycle --ar 3:2", "speed": "relax" }
```

也可以照 Midjourney 的习惯在提示词里写 `--relax`、`--fast`、`--turbo`，效果一样；两处都写时以 `speed` 参数为准。视频接口不支持 `relax`。

## 选择版本

在提示词末尾写版本参数，不写时用 V8.2：

| 版本 | 写法 | 说明 |
| - | - | - |
| V8.2 | 不写，或 `--v 8.2` | 默认版本；支持草图 `--draft` 与高清 `--hd` |
| V7 | `--v 7` | 上一代默认版本 |
| V8.1 | `--v 8.1` | 支持草图 `--draft` 与高清 `--hd` |
| V8 | `--v 8` | 出图后只能接着变化、重塑、重跑或做视频 |
| V6.1 / V6 | `--v 6.1` / `--v 6` | 旧版本 |
| Niji 7 / Niji 6 | `--niji 7` / `--niji 6` | 动漫风格，没有草图与高清 |

```json theme={null}
{ "prompt": "a red fox in the snow, cinematic light --ar 3:2 --v 7" }
```

`edit` 只支持 V8.1 与 V8.2（不写用 V8.2），`retexture` 只支持 V7 与 V6 系列。放大、变化这类接着加工的操作沿用原图的版本。

## 两种调用方式

上面用的是直接调用。如果你已经在用 [统一任务接口](https://docs.rixapi.com/docs/cn/guides/task.md)，模型名就是 `midjourney-` 加动作名（如 `midjourney-imagine`、`midjourney-upscale`），参数放进 `input`，不用传 `action`：

```bash theme={null}
curl https://api.ephone.ai/v1/task/submit \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "midjourney-imagine",
    "input": {
      "prompt": "a red bicycle leaning on a brick wall, morning light --ar 3:2"
    }
  }'
```

两种方式的任务 ID 通用：统一接口生成的图，同样可以用 `/midjourney/action` 接着放大，反过来也一样。计费完全一致。

## 下一步

> [card] [Midjourney 能力与参数](https://docs.rixapi.com/docs/cn/guides/midjourney-workflows.md)
>
> 全部接口、提示词参数、视频与计费说明


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.