This skill routes MediaIO OpenAPI requests based on scripts/c_api_doc_detail.json.
It provides a single entry point, Skill.invoke(api_name, params, api_key), covering credits queries, text-to-image, image-to-image, image-to-video, text-to-video, and task result lookups.
| Variable | Required | Description |
|----------|----------|-------------|
| API_KEY | Yes | Media.io OpenAPI key, sent as X-API-KEY header. Apply at
https://openapi.media.io
API_KEY (used as X-API-KEY)
API_KEY in your environment, or pass api_key explicitly to Skill.invoke(...).
The current API definition includes 24 endpoints, grouped by capability:
Credits (query user credit balance)
Task Result (query task status/result by task_id)
Imagen 4
soul_character
Nano Banana
Seedream 4.0
Nano Banana Pro
Wan 2.6 / Wan 2.2 / Wan 2.5
Hailuo 02 / Hailuo 2.3
Kling 2.1 / Kling 2.5 Turbo / Kling 2.6 / Kling 3.0
Vidu Q2 / Vidu Q3
Google Veo 3.1 / Google Veo 3.1 Fast
Motion Control Kling 2.6
Wan 2.6 (Text To Video)
Vidu Q3 (Text To Video)
Wan 2.5 (Text To Video)
api_name: API name (must exactly match the name field in c_api_doc_detail.json)
params: Business parameter dictionary (only include fields defined in api_body)
api_key: API key
{"code": 0, "msg": "", "data": {...}, "trace_id": "..."}
data.task_id
Task Result
pip install requests
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')
api_key from environment variable.
Windows PowerShell�?
$env:API_KEY="your-api-key"
macOS / Linux (bash/zsh):
export API_KEY="your-api-key"
Credits)
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('Credits', {}, api_key=api_key)
print(result)
Imagen 4)
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(
'Imagen 4',
{
'prompt': 'a cute puppy, photorealistic, soft natural light, high detail',
'ratio': '1:1',
'counts': '1'
},
api_key=api_key
)
print(result) # When code=0, data usually contains task_id.
Task Result)
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)
### Task Status Reference
waiting: queued
processing: running
completed: completed successfully
failed: failed
timeout: timed out
required=true in api_body.
ratio, duration, resolution) must use documented values.
Task Result:
task_id, passed as {'task_id': 'xxx'} (path parameters are replaced automatically by the router).
Credits:
params={}.
Imagen 4 or Kling 3.0) to obtain task_id.
Task Result.
completed/succeeded, extract output URLs from data.result.
{"error": "API 'xxx' not found."}
{"error": ""}
{"error": "Invalid response", ...}
374004: not authenticated. Apply for an APP KEY at https://developer.media.io/.
490505: insufficient credits. Recharge before invoking generation APIs.
c_api_doc_detail.json are unique, including text-to-video variants.
name from the JSON definition.
asyncio or threads.
共 2 个版本