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

# Prompt Optimizer AI 指南：保留使用者意圖和指定原文

> 準備 Prompt Optimizer 請求時，需提供精確的文本提取、忠實的創意簡報、有序的參考資料和完整的 AI 呼叫範例。

使用與普通呼叫者相同的[Prompt Optimizer端點](https://apixo.ai/docs/zh-hant/models/text/prompt-optimizer.md)。使用 `request_type` 選擇輪詢、回呼傳遞或同步等待。`protected_text` 和 `creative_brief` 是 AI 助手、MCP 用戶端和呼叫插件的可選輸入。它們不需要單獨的身份或端點。一般使用者可以在 `prompt` 和 `reference_notes` 中表達自己的需求。

## 準備請求

對於標籤必須為 `SPRING TEA` 的產品影像，請在原始提示中傳送標籤措辭，並在 `protected_text` 中保留該確切字串。首先放置產品圖片，然後放置背景參考。使用 `reference_notes` 表示哪個影像提供標籤，哪個影像僅提供設定。 [完整的編輯請求](#ai-assisted-editing-with-exact-text)顯示了這些欄位如何組合在一起。在將傳回的提示傳遞給影像模型之前檢查其拼字。

1. 在 `prompt` 中保留使用者的完整請求，包括約束、例外、數量和允許的編輯。不要透過將需求轉移到高階領域來縮短它。
2. 選擇所需的`target_model`和`generation_mode`。接受未知的目標名稱；明確為未知影片目標選擇影片模式。優化傳回文字並且不開始媒體生成。
3. 僅透過有序 `image_urls`（最多 4 個公開 HTTPS URL）附加參考素材。使用從 1 開始的影像編號。僅描述`reference_notes`中已知的參考用途；不要猜測影像內容或更改它們的權限。
4. 僅在適當時將使用者所需的準確措辭提取到 `protected_text` 中。
5. 可選擇組織 `creative_brief` 中已規定的創意要求。留下缺失的訊息。
6. 提交一次。直接讀取最終結果，輪詢回傳的任務 ID 或等待回呼。讀 `data.state` 解析之前 `data.resultJson`。在單獨請求媒體產生之前檢查輸出。

## 帶有 protected\_text 的精確文本

使用此可選陣列來表示對話、歌詞、可見字母、標籤、標題或用戶需要逐字記錄的其他措辭。每個最多 32 個字串必須是非空白、最多 1000 個字元，並且恰好出現在 `prompt` 中。

* 複製實際的子字串及其原始大小寫、間距、標點符號和語言。不要翻譯或解釋它。
* 不要發明缺少的名稱或標籤、鎖定普通描述或保護整個提示以避免做出決定。
* 如果不存在精確文字要求，則省略該欄位。提取後將完整的原始需求保留在`prompt`中。
* 對於`Keep the cup label SPRING TEA unchanged`，保護項目是`SPRING TEA`。

保留準確的措詞並不能保證整個輸出在語意上是正確的；還要檢查所有限制。

## 具有 creative\_brief 的現有要求

此可選物件僅接受以下字串欄位，每個欄位最多 1000 個字元：

| 欄位 | 提取什麼 |
| - | - |
| `scene` | 規定的設置和環境。 |
| `camera` | 規定的取景、視點或攝影機移動。 |
| `style` | 規定的視覺風格。 |
| `action_details` | 規定的行動、順序和資格細節。 |
| `audio` | 規定的聲音或對話要求。 |

不要添加設定、鏡頭、風格、動作、聲音或情節事件來填入未使用的欄位。保持這些欄位與`prompt`和`reference_notes`一致。不要把局部或有條件的限制變成全球性的：不對話並不意味著沉默；沒有背景音樂不會消除環境聲音；沒有附加文字不會刪除現有標籤。

`creative_brief.style` 是受支援的子欄位。普通風格、相機和拍攝要求屬於`prompt`。

## 影像順序和語言

圖片1是`image-to-image`中的編輯基；後續圖片僅作參考。`image-to-video` 有一個起始影格。`first-and-last-frames` 需要剛好兩個按開始/結束順序排列的圖片和顯式模式。單獨的兩個圖片意味著參考生成，而不是端點。註解不能逆轉這些責任。重新排序圖片需要在整個請求中更新圖片編號。

解釋每個參考素材的貢獻，什麼必須保持不變，什麼不能複製。如果未提供圖片，則僅附註不附加圖片。未知的參考用途應保持未指定。

使用 `language` 明確指定所需的描述性輸出語言。保留提供的對話、歌詞、文字標籤、座標標籤和數值約束。請參閱主要指南 [影像語言政策](https://apixo.ai/docs/zh-hant/models/text/prompt-optimizer.md#image-language-selection-and-preservation) 與 [影片語言政策](https://apixo.ai/docs/zh-hant/models/text/prompt-optimizer.md#video-language-selection-and-preservation) 關於 `auto` 的設定。傳回的提示為一個字串；部分目標會使用其中的命名區段。

## 規劃影片拍攝

將使用者的拍攝次數、順序與剪輯時間保留在 `prompt` 中。例如「連續拍攝、不切換」等指令亦應包含其中。若用戶委託規劃拍攝計畫，則不指定次數與剪輯時間。針對 Wan 3.0 LoRA，請將 `target_model` 設為 `wan-3-0-video-LoRA`。

## 完整的請求範例

將每個請求提交至 `POST https://api.apixo.ai/api/v1/generateTask/prompt-optimizer`，並附帶 `Authorization: Bearer YOUR_API_KEY` 與 `Content-Type: application/json`。將佔位符 URL 替換為可存取的檔案和您自己的回呼接收器。

### 最小影像提示

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "optimizer",
    "prompt": "A ceramic cup on a wooden table in soft window light."
  }
}
```

### AI-精確文字輔助編輯

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "optimizer",
    "prompt": "Use image 1 as the editing base. Replace only the background with the wooden table environment in image 2. Keep the cup shape, color and label SPRING TEA unchanged. Use natural photography, a fixed camera and a medium shot. Do not add people or text.",
    "target_model": "generic-image",
    "generation_mode": "image-to-image",
    "language": "en",
    "image_urls": [
      "https://images.example.com/cup.png",
      "https://images.example.com/table.png"
    ],
    "reference_notes": "Image 1 is the editing base; preserve the cup and its label. Image 2 supplies only the table background; do not copy its people or lettering.",
    "protected_text": [
      "SPRING TEA"
    ],
    "creative_brief": {
      "camera": "Fixed camera, medium shot",
      "style": "Natural photography"
    }
  }
}
```

### 帶有範圍音訊說明的影片參考

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.example.com/optimization-result",
  "input": {
    "mode": "optimizer",
    "prompt": "Use the cup in image 1 as the product reference. Show the cup on a wooden table for 6 seconds with one continuous fixed-camera shot. Keep the label SPRING TEA unchanged. No dialogue or background music; retain the ambient rain sound.",
    "target_model": "generic-video",
    "generation_mode": "reference-to-video",
    "language": "en",
    "duration": 6,
    "image_urls": [
      "https://images.example.com/cup.png"
    ],
    "reference_notes": "Image 1 supplies only the cup appearance and label; it is not a required starting frame.",
    "protected_text": [
      "SPRING TEA"
    ],
    "creative_brief": {
      "scene": "Cup on a wooden table",
      "camera": "One continuous fixed-camera shot",
      "audio": "No dialogue or background music; retain ambient rain sound"
    }
  }
}
```

### 顯式的第一影格和最後一影格

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "optimizer",
    "prompt": "Start at image 1 and end at image 2. Show the door opening slowly while keeping the camera fixed.",
    "target_model": "generic-video",
    "generation_mode": "first-and-last-frames",
    "image_urls": [
      "https://images.example.com/door-closed.png",
      "https://images.example.com/door-open.png"
    ],
    "reference_notes": "Image 1 is the starting frame; image 2 is the ending frame."
  }
}
```

### 兩次射擊的同步 Wan LoRA

```json theme={null}
{
  "request_type": "sync",
  "input": {
    "mode": "optimizer",
    "prompt": "Use image 1 as the starting frame. Exactly two shots over 8 seconds: from 0 to 3 seconds, hold a fixed medium shot as the blue toy train rolls to the center. At 3 seconds, hard cut to an overhead close-up and keep the train still through 8 seconds. No subtitles or music.",
    "target_model": "wan-3-0-video-LoRA",
    "generation_mode": "image-to-video",
    "language": "en",
    "duration": 8,
    "image_urls": [
      "https://images.example.com/toy-train.png"
    ]
  }
}
```

如果任務在同步等待期間完成，回應將包含最佳化的提示。解析 `data.resultJson` 一次並讀取 `outputs[0]`。

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_video_example",
    "state": "success",
    "resultJson": "{\"outputs\":[\"8 seconds. Shot 1 (0–3s): Fixed medium shot from the supplied first frame. The blue toy train rolls to the center. Shot 2 (3–8s): Hard cut to an overhead close-up of the stationary train. No subtitles or music.\"]}"
  }
}
```

如果伺服器停止等待時任務仍在運行，則使用傳回的 `data.taskId` 來查詢相同的任務。將僅包含任務 ID 的回應視為接受並查詢它。

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_video_example",
    "state": "processing"
  }
}
```

```bash theme={null}
curl 'https://api.apixo.ai/api/v1/statusTask/prompt-optimizer?taskId=task_video_example' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

## 讀取結果

節省 `data.taskId` 從提交。如果同步回應已經有 `data.state: "success"`，直接讀取結果。否則，查詢 `GET /api/v1/statusTask/prompt-optimizer?taskId={taskId}` 使用同一帳戶的 API 金鑰，或根據要求等待回呼。處理期間，請勿重新提交。成功後，解析 `data.resultJson` 一次並讀取 `outputs[0]`。如果失敗，請讀取 `failCode` 和 `failMsg`；外層 `code=200` 並非成功的優化結果。

約 5 秒後輪詢，間隔 5 秒或更長時間。超時不能證明任務未被創建。提交替換前應先檢查是否存在現有任務。媒體生成仍為獨立操作。


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