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

# 快速开始

> 5 分钟跑通你的第一个 Ace Data Cloud API 请求。

本文以 **Midjourney 文生图** 为例，演示注册 → 获取 Token → 调 API → 拿到结果的全流程。

## 1. 注册账号并领取额度

1. 打开 [platform.acedata.cloud](https://platform.acedata.cloud) 注册
2. 进入「Midjourney」服务详情页，购买套餐或领取试用额度
3. 在「凭证」标签里点击「创建凭证」，复制返回的 Token

<Warning>
  Token 是密钥级别的字符串，**不要**贴到前端 / 移动端代码或公开仓库——请用环境变量或密钥管理服务。
</Warning>

## 2. 发起请求

把 Token 设到环境变量：

```bash theme={null}
export ACEDATACLOUD_API_TOKEN="your-token-here"
```

调一次文生图：

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.acedata.cloud/midjourney/imagine \
    -X POST \
    -H "Authorization: Bearer $ACEDATACLOUD_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "A cute cat sitting on a wooden table, soft lighting"
    }'
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.post(
      "https://api.acedata.cloud/midjourney/imagine",
      headers={
          "Authorization": f"Bearer {os.environ['ACEDATACLOUD_API_TOKEN']}",
          "Content-Type": "application/json",
      },
      json={"prompt": "A cute cat sitting on a wooden table, soft lighting"},
      timeout=300,
  )
  print(resp.json())
  ```

  ```javascript Node.js theme={null}
  const res = await fetch("https://api.acedata.cloud/midjourney/imagine", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.ACEDATACLOUD_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      prompt: "A cute cat sitting on a wooden table, soft lighting",
    }),
  });
  console.log(await res.json());
  ```
</CodeGroup>

## 3. 读取响应

`/midjourney/imagine` 会**等到生成完成再返回**（约几十秒），所以可以直接拿到结果：

```json theme={null}
{
  "success": true,
  "task_id": "27a1128f-14b5-440e-a82d-510c81e6fcd4",
  "image_id": "1211290228438868029",
  "image_url": "https://midjourney.cdn.acedata.cloud/.../image.png",
  "image_width": 1024,
  "image_height": 1024,
  "actions": ["upscale1", "upscale2", "variation1", "variation2", "..."]
}
```

* `image_url` 就是生成的 4 格大图，可直接展示或下载
* `actions` 列出后续可对此图执行的操作（放大、变体）
* `task_id` 用于后续操作（例如 upscale / variation）

如果请求失败，响应会变成形如下面的错误结构（**没有** `success` 字段）：

```json theme={null}
{
  "error": {
    "code": "invalid_token",
    "message": "The specified token is invalid or wrong."
  },
  "trace_id": "..."
}
```

完整错误码表见 [响应格式](/concepts/responses)。

## 4. 异步：长视频 / 长音乐

视频与音乐生成耗时更长，通常**只先返回 `task_id`**，结果通过轮询或 Webhook 拿。详见 [异步任务模型](/concepts/async-tasks)。

## 5. 后续

<CardGroup cols={2}>
  <Card title="API 参考" icon="code" href="/api-reference">
    所有接口的交互式文档
  </Card>

  <Card title="网关与认证" icon="key" href="/authentication">
    Token、域名、错误码
  </Card>

  <Card title="价格总览" icon="dollar-sign" href="/pricing/overview">
    各品类计费方式
  </Card>

  <Card title="MCP 接入" icon="plug" href="/mcp/overview">
    在 Claude / Cursor 里直接调用
  </Card>
</CardGroup>
