# API ของ Seedream 5.5 เอกสารอ้างอิง API ฉบับสมบูรณ์สำหรับโมเดล Seedream 5.5 ของ ByteDance ## รุ่นของโมเดล API นี้รองรับโมเดลสองรุ่น: | โมเดล | ID | คำอธิบาย | |-------|-----|-------------| | **Seedream 5.5** | `seedream-v5.5` | สร้างภาพคุณภาพสูงจากข้อความ | | **Seedream 5.5 Edit** | `seedream-v5.5-edit` | แก้ไขภาพโดยใช้ภาพอ้างอิง | ## ตารางเปรียบเทียบ | คุณสมบัติ | Seedream 5.5 | Seedream 5.5 Edit | |---------|------------------|-----------------------| | ข้อมูลนำเข้า | พรอมต์ข้อความ | ภาพอย่างน้อยหนึ่งภาพ + พรอมต์ข้อความ | | อัตราส่วนภาพ | 8 ตัวเลือก | 8 ตัวเลือก | | ความละเอียด | 1K, 1.5K, 2K | 1K, 1.5K, 2K | | ภาพนำเข้า | ไม่รองรับ | จำเป็น (1–10 ภาพ) | ### อัตราส่วนภาพที่รองรับ `16:9`, `4:3`, `3:2`, `1:1`, `2:3`, `3:4`, `9:16`, `21:9` ## Seedream 5.5 (สร้างภาพจากข้อความ) ### เอนด์พอยต์ ``` POST /api/v1/image/task ``` ### พารามิเตอร์คำขอ #### พารามิเตอร์ที่จำเป็น | พารามิเตอร์ | ชนิดข้อมูล | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น `"seedream-v5.5"` | | `prompt` | string | พรอมต์สำหรับสร้างภาพ ความยาวสูงสุด 5000 อักขระ | | `resolution` | string | ความละเอียดของภาพผลลัพธ์: `"1k"`, `"1.5k"` หรือ `"2k"` ไม่มีค่าเริ่มต้น | | `width` | integer | ค่าสัดส่วนด้านกว้าง (เช่น 16 สำหรับอัตราส่วน 16:9) ต้องระบุคู่กับ `height` ไม่มีค่าเริ่มต้น | | `height` | integer | ค่าสัดส่วนด้านสูง (เช่น 9 สำหรับอัตราส่วน 16:9) ต้องระบุคู่กับ `width` ไม่มีค่าเริ่มต้น | **หมายเหตุ:** อัตราส่วนความกว้างต่อความสูงต้องเป็นค่าใดค่าหนึ่งต่อไปนี้: `16:9`, `4:3`, `3:2`, `1:1`, `2:3`, `3:4`, `9:16`, `21:9` #### พารามิเตอร์เสริม | พารามิเตอร์ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย | |-----------|------|---------|-------------| | `background` | string | `"auto"` | โหมดพื้นหลัง: `"auto"` (อัตโนมัติ), `"transparent"` หรือ `"opaque"` | ### ตัวอย่างคำขอ ```javascript const response = await fetch('https://api.flaq.ai/api/v1/image/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'seedream-v5.5', prompt: 'Editorial fashion portrait, soft window light, muted palette', resolution: '1.5k', width: 16, height: 9, background: 'auto' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Seedream 5.5 Edit (แก้ไขภาพ) ### เอนด์พอยต์ ``` POST /api/v1/image/task ``` ### พารามิเตอร์คำขอ #### พารามิเตอร์ที่จำเป็น | พารามิเตอร์ | ชนิดข้อมูล | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น `"seedream-v5.5-edit"` | | `prompt` | string | คำอธิบายการแก้ไขที่ต้องการ ความยาวสูงสุด 5000 อักขระ | | `image_url_list` | string[] | อาร์เรย์ของ URL ภาพที่ต้องการแก้ไข (1–10 ภาพ) คิด 80 เครดิตต่อรายการที่ไม่ว่าง รวมถึงรายการที่ใช้ URL ซ้ำ | | `resolution` | string | ความละเอียดของภาพผลลัพธ์: `"1k"`, `"1.5k"` หรือ `"2k"` ไม่มีค่าเริ่มต้น | | `width` | integer | ค่าสัดส่วนด้านกว้าง (เช่น 16 สำหรับอัตราส่วน 16:9) ต้องระบุคู่กับ `height` ไม่มีค่าเริ่มต้น | | `height` | integer | ค่าสัดส่วนด้านสูง (เช่น 9 สำหรับอัตราส่วน 16:9) ต้องระบุคู่กับ `width` ไม่มีค่าเริ่มต้น | **หมายเหตุ:** อัตราส่วนความกว้างต่อความสูงต้องเป็นค่าใดค่าหนึ่งต่อไปนี้: `16:9`, `4:3`, `3:2`, `1:1`, `2:3`, `3:4`, `9:16`, `21:9` #### พารามิเตอร์เสริม | พารามิเตอร์ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย | |-----------|------|---------|-------------| | `background` | string | `"auto"` | โหมดพื้นหลัง: `"auto"` (อัตโนมัติ), `"transparent"` หรือ `"opaque"` | ### ตัวอย่างคำขอ ```javascript const response = await fetch('https://api.flaq.ai/api/v1/image/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'seedream-v5.5-edit', prompt: 'Change the hairstyle', image_url_list: [ 'https://img.bestimage.ai/test/2026/7/1/ad8e011a-3e9b-49f0-9397-282bf51e2e45_162640331.jpeg' ], resolution: '1.5k', width: 16, height: 9, background: 'auto' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ### ตัวอย่างการแก้ไขภาพเดียว ```javascript { model_name: 'seedream-v5.5-edit', image_url_list: ['https://img.bestimage.ai/test/2026/7/1/ad8e011a-3e9b-49f0-9397-282bf51e2e45_162640331.jpeg'], prompt: 'Change the hairstyle', resolution: '1.5k', width: 16, height: 9, background: 'auto' } ``` ### ตัวอย่างการแก้ไขหลายภาพ ```javascript { model_name: 'seedream-v5.5-edit', image_url_list: [ 'https://example.com/image1.jpg', 'https://example.com/image2.jpg' ], prompt: 'Blend these images into a cohesive composition', resolution: '1.5k', width: 16, height: 9, background: 'auto' } ``` ## รูปแบบการตอบกลับ ### การตอบกลับเบื้องต้น ```json { "code": 0, "message": "success", "data": { "task_id": "0ca5f379-327b-4d49-ba19-e38782ceb2f0", "response_url": "https://api.flaq.ai/api/v1/image/0ca5f379-327b-4d49-ba19-e38782ceb2f0", "task_status": "submitted" } } ``` ### การตอบกลับเมื่อตรวจสอบสถานะ เรียก `GET /api/v1/image/{task_id}` เป็นระยะเพื่อตรวจสอบสถานะ: ```json { "code": 0, "data": { "task_id": "{task_id}", "task_status": "succeed", "task_status_msg": null, "response_url": "https://api.flaq.ai/api/v1/image/{task_id}", "task_result": { "credit": 200, "images": [ { "url": "https://example.com/generated-image.png" } ] } }, "message": "success" } ``` ### การตอบกลับเมื่อเกิดข้อผิดพลาด ```json { "code": 1201, "message": "[width, height] Invalid parameter (e.g. wrong key or value)", "data": null } ``` ### ค่าสถานะ - `submitted`: ระบบรับงานแล้ว - `processing`: กำลังสร้างภาพ - `succeed`: สร้างภาพเสร็จแล้ว - `failed`: สร้างภาพไม่สำเร็จ ## ระยะเวลาประมวลผล ตรวจสอบเป็นระยะจนกว่าสถานะงานจะเป็น `succeed` หรือ `failed` หากเพิ่งส่งงานหรือระบบกำลังประมวลผล ข้อมูลตอบกลับอาจยังไม่มีภาพผลลัพธ์ ## แนวทางปฏิบัติที่แนะนำ 1. **รายละเอียดของพรอมต์**: อธิบายภาพที่ต้องการให้ละเอียดเพื่อให้ได้ผลลัพธ์ที่ดีขึ้น 2. **อัตราส่วนภาพ**: เลือกอัตราส่วนให้เหมาะกับการใช้งานก่อนสร้างภาพ 3. **คุณภาพการแก้ไขภาพ**: ใช้ภาพต้นฉบับที่มีความละเอียดสูงและมีแสงเพียงพอ