This skill provides access to ByteDance Seedream 4.0 through the Media.io OpenAPI. Seedream is a versatile powerhouse supporting 4K generation and advanced editing, ensuring character and style consistency.
Use this skill when you hear:
VariableRequiredDescriptionAPI_KEYYesMedia.io OpenAPI key, sent as X-API-KEY header. Apply at https://developer.media.io/.
Seedream 4.0i2i-seedream-v4-0POST https://openapi.media.io/generation/seedream/i2i-seedream-v4-0ParameterTypeRequiredDescriptionpromptstringYesText description for image generationimagestringNoReference image URL for image-to-imageratiostringNoImage aspect ratiostrengthstringNoHow strongly to follow the reference image (for i2i)
json
{
"code": 0,
"msg": "",
"data": {
"task_id": "..."
},
"trace_id": "..."
}
bash
pip install requests
python
import os
from scripts.skill_router import Skill
skill = Skill('scripts/c_api_doc_detail.json')
api_key = os.getenv('API_KEY', '')
if not api_key:
raise RuntimeError('API_KEY is not set')
Windows PowerShell:
powershell
$env:API_KEY="your-api-key"
macOS / Linux (bash/zsh):
bash
export API_KEY="your-api-key"
python
import os
from scripts.skill_router import Skill
skill = Skill('scripts/c_api_doc_detail.json')
api_key = os.getenv('API_KEY', '')
if not api_key:
raise RuntimeError('API_KEY is not set')
result = skill.invoke(
'Seedream 4.0',
{
'prompt': 'a beautiful landscape painting, vibrant colors, artistic style',
'image': 'https://example.com/reference-image.jpg',
'ratio': '16:9'
},
api_key=api_key
)
print(result) # Returns task_id when code=0
python
import os
import time
from scripts.skill_router import Skill
skill = Skill('scripts/c_api_doc_detail.json')
api_key = os.getenv('API_KEY', '')
if not api_key:
raise RuntimeError('API_KEY is not set')
task_id = 'your-task-id'
for _ in range(24):
r = skill.invoke('Task Result', {'task_id': task_id}, api_key=api_key)
print(r)
status = (r.get('data') or {}).get('status')
if status in ('completed', 'failed', 'succeeded'):
break
time.sleep(5)
waiting: queuedprocessing: runningcompleted: completed successfullyfailed: failedtimeout: timed outError CodeDescription374004Not authenticated. Apply for an APP KEY at https://developer.media.io/490505Insufficient credits. Recharge before invoking generation APIs