# Seedream 4.5 API เอกสารอ้างอิง API ฉบับสมบูรณ์สำหรับโมเดล Seedream 4.5 โดย ByteDance. ## ตัวเลือกโมเดล API นี้รองรับโมเดล 2 ตัวเลือก: | โมเดล | ID | คำอธิบาย | |-------|-----|-------------| | **Seedream 4.5** | `seedream-v4.5` | การสร้าง text-to-image แบบมีสไตล์อย่างรวดเร็ว | | **Seedream 4.5 Edit** | `seedream-v4.5-edit` | การแก้ไขรูปภาพและการจัดองค์ประกอบหลายรูปภาพ | ## เปรียบเทียบอย่างรวดเร็ว | ฟีเจอร์ | Seedream 4.5 | Seedream 4.5 Edit | |---------|--------------|-------------------| | อินพุต | พรอมต์ข้อความ | รูปภาพ + พรอมต์ข้อความ | | ความเร็วการสร้าง | เร็วมาก | เร็ว | | ตัวเลือกความละเอียด | 2K, 4K | 2K, 4K | | อัตราส่วนภาพ | 9 ตัวเลือก | 9 ตัวเลือก | | อินพุตรูปภาพ | ❌ ไม่ | ✅ ใช่ (1-10 รูป) | | เหมาะสำหรับ | อนิเมะ ภาพประกอบ สไตล์ศิลปะ | การถ่ายโอนสไตล์ การจัดองค์ประกอบรูปภาพ | ### อัตราส่วนภาพที่รองรับ ทั้งสองโมเดลรองรับอัตราส่วนภาพ 9 แบบ: - `21:9`, `16:9`, `4:3`, `3:2`, `1:1`, `2:3`, `3:4`, `9:16`, `9:21` ## Seedream 4.5 (ข้อความเป็นรูปภาพ) ### จุดเชื่อมต่อ ``` POST /api/v1/image/task ``` ### พารามิเตอร์คำขอ #### จำเป็น | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น `"seedream-v4.5"` | | `prompt` | string | พรอมต์สำหรับสร้างรูปภาพ | | `width` | number | ค่าอัตราส่วนความกว้าง (เช่น 16 สำหรับ 16:9) | | `height` | number | ค่าอัตราส่วนความสูง (เช่น 9 สำหรับ 16:9) | | `resolution` | string | ความละเอียดเอาต์พุต: `"2k"` หรือ `"4k"` | **หมายเหตุ:** อัตราส่วน width:height ต้องเป็นหนึ่งใน: "21:9", "9:21", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "1:1" ### ตัวอย่างคำขอ ```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-v4.5', prompt: 'A magical girl in a fantasy forest, anime style', width: 16, height: 9, resolution: '2k' }) }); const { data } = await response.json(); const taskId = data.task_id; // Poll for results const pollResponse = await fetch( `https://api.flaq.ai/api/v1/image/${taskId}`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const result = await pollResponse.json(); console.log(result.data.task_result.images[0].url); ``` ## Seedream 4.5 Edit (การแก้ไขรูปภาพ) ### จุดเชื่อมต่อ ``` POST /api/v1/image/task ``` ### พารามิเตอร์คำขอ #### จำเป็น | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น "seedream-v4.5-edit" | | `prompt` | string | คำอธิบายการแก้ไขที่ต้องการ | | `image_url_list` | string[] | อาร์เรย์ URL รูปภาพสำหรับแก้ไข (1-10 รูป) | #### ไม่บังคับ | พารามิเตอร์ | ประเภท | Default | คำอธิบาย | |-----------|------|---------|-------------| | `width` | number | - | ค่าอัตราส่วนความกว้าง (เช่น 16 สำหรับ 16:9) | | `height` | number | - | ค่าอัตราส่วนความสูง (เช่น 9 สำหรับ 16:9) | | `resolution` | string | `"2k"` | ความละเอียดเอาต์พุต: `"2k"`, `"4k"` | ### ตัวอย่างการแก้ไขรูปภาพเดียว ```javascript { model_name: 'seedream-v4.5-edit', image_url_list: ['https://example.com/photo.jpg'], prompt: 'Convert to anime art style with vibrant colors', width: 16, height: 9, resolution: '2k' } ``` ### ตัวอย่างการจัดองค์ประกอบหลายรูปภาพ ```javascript { model_name: 'seedream-v4.5-edit', image_url_list: [ 'https://example.com/image1.jpg', 'https://example.com/image2.jpg' ], prompt: 'Blend these images into a cohesive anime-style illustration', width: 16, height: 9, resolution: '2k' } ``` ## รูปแบบการตอบกลับ ### การตอบกลับเริ่มต้น ทั้งสองโมเดลส่งคืน `task_id` สำหรับการ Poll: ```json { "code": 0, "data": { "task_id": "{task_id}", "task_status": "submitted", "response_url": "https://api.flaq.ai/api/v1/image/{task_id}" }, "message": "success" } ``` ### การตอบกลับจากการ Poll Poll `/api/v1/image/{taskId}` เพื่อตรวจสอบสถานะ: ```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": 0.0997, "images": [ { "url": "https://example.com/generated-image.jpeg" } ] } }, "message": "success" } ``` ### ค่าสถานะ - `submitted`: รับงานแล้ว - `processing`: กำลังสร้าง - `succeed`: สร้างสำเร็จ - `failed`: สร้างล้มเหลว ## เวลาประมวลผล Seedream 4.5 ถูกปรับให้เหมาะกับความเร็ว: - **Text-to-Image**: ~10-30 วินาที - **Image Edit**: ~15-40 วินาที ## แนวทางปฏิบัติที่ดี 1. **เน้นอนิเมะและภาพประกอบ**: Seedream ทำได้ดีในงานอนิเมะ มังงะ และศิลปะมีสไตล์ 2. **วนปรับได้เร็ว**: เวลาในการสร้างที่ต่ำลงช่วยให้ทดลองได้รวดเร็ว 3. **การแก้ไขหลายรูปภาพ**: รวมรูปภาพได้สูงสุด 10 รูปสำหรับองค์ประกอบที่ซับซ้อน 4. **การเลือกความละเอียด**: 2K เพียงพอสำหรับกรณีใช้งานส่วนใหญ่ ส่วน 4K เหมาะกับคุณภาพสูงสุด 5. **สไตล์พรอมต์**: ใส่คีย์เวิร์ดสไตล์ศิลปะ (anime, manga, illustration) เพื่อผลลัพธ์ที่ดีที่สุด ## ตัวอย่างกรณีใช้งาน ### การสร้างตัวละครอนิเมะ ```javascript { model_name: 'seedream-v4.5', prompt: 'Anime girl with blue hair, magical powers, detailed eyes, studio lighting', width: 9, height: 16, resolution: '2k' } ``` ### การถ่ายโอนสไตล์ ```javascript { model_name: 'seedream-v4.5-edit', image_url_list: ['photo.jpg'], prompt: 'Transform into vibrant anime art style with bold colors', resolution: '2k' } ``` ### คอลลาจหลายรูปภาพ ```javascript { model_name: 'seedream-v4.5-edit', image_url_list: ['img1.jpg', 'img2.jpg', 'img3.jpg'], prompt: 'Create a manga-style panel layout with these images', width: 16, height: 9, resolution: '2k' } ```