開発者 API は現在もベータ段階であり、いつでも変更される可能性があります。現段階では個人でのテストや試用に適しており、本番環境での使用はまだ推奨していません。
この環境で有効な 59 個の機能を REST から呼び出すか、MCP 対応の AI ツールで直接利用できます。有効なサブスクリプションが必要です。
Codex MCP、REST、Claude Code、Cursor、手動 MCP クライアントは専用 API キーを使用します。Codex は静的な Authorization ヘッダーをユーザー設定に保存します。キーをチャットやシェル履歴に送信しないでください。
すべてのリクエストは、サブスクリプションに紐づく API キーで認証されます。
Authorization: Bearer YOUR_API_KEY契約が失効すると 403 が返り、更新後は既存の Key を再び利用できます。VidMage への再ログインで解決する 401 は ACCOUNT_SESSION_REFRESH_REQUIRED だけです。その他の 401 は個別の復旧手順に従ってください。
短時間のみ有効でサイズが固定されたURLを使い、画像・動画・音声をストレージへ直接アップロードします。ファイル本体はVidMageアプリケーションサーバーを経由しません。
curl -X POST "https://vidmage.ai/api/v1/files/upload" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "capability": "video-upscaler", "parameter": "videoURL", "duration": 7.25, "fileName": "input.mp4", "localPath": "./input.mp4", "contentType": "video/mp4", "fileSize": 12345678 }'
# -> { "uploadCommand": "curl ...", "fileUrl": "https://..." }
# Run uploadCommand once, then use fileUrl in the generation request.# ~/.codex/config.toml
# Direct, persistent user-level MCP registration; this is not a plugin install.
# Replace any existing [mcp_servers.vidmage] table; do not append a duplicate.
[mcp_servers.vidmage]
url = "https://vidmage.ai/api/mcp"
http_headers = { Authorization = "Bearer YOUR_API_KEY" }
enabled = true
required = true
startup_timeout_sec = 30
tool_timeout_sec = 120
# Save this file, then confirm persistence with: codex mcp get vidmage
# Restrict the user-level file after saving: chmod 600 ~/.codex/config.toml
# Diagnose this direct server from VidMage startup errors; a remote Plugins catalog 401 is unrelated.
# Fully restart Codex, create a new task, and call list_capabilities.最初に list_capabilities を呼び出します。生成には新しく安定した idempotencyKey を使い、submit_task は 1 回だけ呼び出して、同じ taskId をポーリングします。応答を失った場合は先に get_recent_tasks を呼び出し、同じ送信の通信再試行に限って元のキーを再利用します。
list_models → estimate_model_creditsすべてのリクエストは、サブスクリプションに紐づく API キーで認証されます。
list_capabilities(テキストから画像)
→ describe_capability
→ submit_task + 新しく安定した idempotencyKey(1 回のみ)
→ get_task_result(同じタスクをポーリング)
→ get_recent_tasks(送信応答を失った場合のみ)
→ ネイティブ画像結果すべての AI タスクは非同期です。各機能に 2 つのエンドポイントがあります。
| エンドポイント | 説明 |
|---|---|
| GET /api/v1/capabilities | すべてのリクエストは、サブスクリプションに紐づく API キーで認証されます。 |
| GET /api/v1/openapi.json | すべてのリクエストは、サブスクリプションに紐づく API キーで認証されます。 |
| POST /api/v1/files/upload | ローカルメディア用の制限付き一時ダイレクトアップロードURLを作成します。 |
| GET /api/v1/tasks/recent | タイムアウト、切断、応答の消失後に最近のタスク ID を復元します。 |
| POST /api/v1/<capability>/submit | タスクを開始し、タスク ID をすぐに返します。 |
| POST /api/v1/<capability>/query | ID でタスクを確認し、完了時に状態と結果 URL を返します。 |
curl -X POST "https://vidmage.ai/api/v1/face-swap/submit" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"targetImageUrl":"https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp","referenceFaceImageUrl":"https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"}'
# -> { "success": true, "taskId": "...", "creditsRequired": ..., "creditsConsumed": 0, "usageDeferred": true }curl -X POST "https://vidmage.ai/api/v1/face-swap/query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "taskId": "TASK_ID_FROM_SUBMIT" }'
# -> { "success": true, "data": { "status": "...", "imageUrl": "https://..." } }機能カタログと OpenAPI 3.1 は、実際の入力検証と同じ契約から生成されます。Postman、Insomnia、Bruno、API クライアント生成ツールに読み込めます。
curl -H "Authorization: Bearer YOUR_API_KEY" "https://vidmage.ai/api/v1/capabilities"curl -H "Authorization: Bearer YOUR_API_KEY" "https://vidmage.ai/api/v1/openapi.json" --output vidmage-openapi.jsoncurl -H "Authorization: Bearer YOUR_API_KEY" "https://vidmage.ai/api/v1/tasks/recent?limit=10"以下の例ではタスクを一度だけ送信し、完了まで同じタスク ID をポーリングします。同じ送信を再試行するときは、idempotency key を変更しないでください。
const submitResponse = await fetch('https://vidmage.ai/api/v1/face-swap/submit', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDMAGE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"targetImageUrl": "https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp",
"referenceFaceImageUrl": "https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp"
}),
})
const submitted = await submitResponse.json()
if (!submitResponse.ok || !submitted.success) {
throw new Error(submitted.message ?? submitted.error ?? 'Task submission failed')
}
const taskId = submitted["taskId"]
if (!taskId) throw new Error('Submit succeeded without a task id')
while (true) {
await new Promise(resolve => setTimeout(resolve, 5000))
const queryResponse = await fetch('https://vidmage.ai/api/v1/face-swap/query', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VIDMAGE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ taskId: taskId }),
})
const queried = await queryResponse.json()
if (!queryResponse.ok || !queried.success) {
throw new Error(queried.message ?? queried.error ?? 'Task query failed')
}
const data = queried.data ?? queried
const status = String(data.status ?? '').toLowerCase()
if (['success', 'succeeded', 'completed'].includes(status)) {
console.log(queried.result ?? queried["imageUrl"] ?? data["imageUrl"])
break
}
if (['failed', 'error'].includes(status)) {
throw new Error(data.errorDetail ?? data.error ?? 'Task failed')
}
}import os
import time
import requests
submit_response = requests.post(
"https://vidmage.ai/api/v1/face-swap/submit",
headers={
"Authorization": f"Bearer {os.environ['VIDMAGE_API_KEY']}",
},
json={
"targetImageUrl": "https://vidmage.ai/assets/images/samples/blue-eyed-woman-sunlight.webp",
"referenceFaceImageUrl": "https://vidmage.ai/assets/images/samples/smiling-man-sweater.webp",
},
timeout=60,
)
submitted = submit_response.json()
if not submit_response.ok or not submitted.get("success"):
raise RuntimeError(submitted.get("message") or submitted.get("error") or "Task submission failed")
task_id = submitted["taskId"]
if not task_id:
raise RuntimeError("Submit succeeded without a task id")
while True:
time.sleep(5)
query_response = requests.post(
"https://vidmage.ai/api/v1/face-swap/query",
headers={"Authorization": f"Bearer {os.environ['VIDMAGE_API_KEY']}"},
json={"taskId": task_id},
timeout=60,
)
queried = query_response.json()
if not query_response.ok or not queried.get("success"):
raise RuntimeError(queried.get("message") or queried.get("error") or "Task query failed")
data = queried.get("data") or queried
status = str(data.get("status") or "").lower()
if status in {"success", "succeeded", "completed"}:
print(queried.get("result") or queried.get("imageUrl") or data.get("imageUrl"))
break
if status in {"failed", "error"}:
raise RuntimeError(data.get("errorDetail") or data.get("error") or "Task failed")HTTP ステータスで処理を分岐し、errorType に応じて復旧してください。すべての REST レスポンスには、追跡とサポート用の X-Request-Id が含まれます。
| ステータス | 主な errorType | 推奨対応 |
|---|---|---|
| 400 | INVALID_JSON / VALIDATION_ERROR | details の項目を修正してください。同じ入力のまま再試行しないでください。 |
| 401 | AUTHENTICATION_REQUIRED | VidMage に認証情報が届いていません。Codex のユーザー設定または対象クライアントに Authorization を追加してください。チャットで Key を求めたり貼り付けたりしないでください。 |
| 401 | AUTHORIZATION_HEADER_INVALID | Authorization Header を正確に Bearer <API_KEY> に修正してください。タスクは送信されていません。 |
| 401 | API_KEY_INVALID_OR_REVOKED | 新しい API キーを作成し、既存設定の Authorization だけを置き換えてください。Codex を再起動し、新しいタスクで確認します。 |
| 401 | API_KEY_INVALID_CREDENTIAL | 新しい API キーを作成し、対象クライアントの認証情報を置き換えてください。現在の認証情報は復号できません。 |
| 401 | ACCOUNT_SESSION_REFRESH_REQUIRED | VidMage に一度ログインしてください。既存の API Key に内包されたバックエンドのアカウント認証情報が更新され、クライアント設定は変わりません。 |
| 401 REST | NEED_API_KEY | REST 互換用のみです。API キーを指定してください。 |
| 402 | NEED_PURCHASE_CREDITS | クレジットを追加するか、消費量の少ない処理を選択してください。 |
| 403 | NEED_SUBSCRIBE | アカウントのサブスクリプションを開始または更新してください。 |
| 404 | CAPABILITY_NOT_ENABLED | 機能一覧を再取得してください。この環境では機能が無効、または未提供の可能性があります。 |
| 409 | UPLOAD_NOT_READY / IDEMPOTENCY_CONFLICT / IDEMPOTENCY_IN_PROGRESS | 送信が処理中の場合は指定時間待ち、同じ idempotencyKey を再利用します。別の生成リクエストに限って新しいキーを作成してください。 |
| 410 | UPLOAD_EXPIRED | 新しい一時アップロードを作成してください。以前のファイル URL は期限切れです。 |
| 429 | RATE_LIMITED | Retry-After の時間だけ待ち、上限付き指数バックオフで再試行してください。 |
| 503 | CREDENTIAL_STORAGE_UNAVAILABLE | Retry-After に従って 1 回だけ再試行してください。続く場合は停止し、requestId を報告して、運用担当者に Developers MySQL readiness の復旧を依頼してください。API キーは保持し、再送信しないでください。 |
| 503 / MCP | SUBMISSION_OUTCOME_UNKNOWN / BILLING_OUTCOME_UNKNOWN / REFUND_OUTCOME_UNKNOWN | まず recovery に従ってください。GET_RECENT_TASKS は get_recent_tasks の呼び出し、QUERY_TASK_ID_OR_CONTACT_SUPPORT は同じ taskId の照会またはサポートへの連絡、CONTACT_SUPPORT_WITH_IDEMPOTENCY_KEY_AND_BUSINESS_ID は idempotencyKey と businessId を添えたサポートへの連絡を意味します。新しい idempotencyKey の作成、再送信、再返金は絶対に行わないでください。 |
| 503 / MCP | TASK_PERSISTENCE_UNCERTAIN | taskId を保持して再送信せず、問題が続く場合は taskId を添えてサポートへ連絡してください。 |
| MCP | TASK_QUERY_INTERRUPTED | 同じ taskId のポーリングを再開してください。別のタスクを送信しないでください。 |
| MCP | RESULT_MISSING | 同じ taskId のポーリングを続けてください。タスクを再送信しないでください。 |
| 404 / MCP | TASK_NOT_FOUND | 再試行の前に get_recent_tasks を呼び出してください。有料タスクを再送信しないでください。 |
| 502 / MCP | BILLING_INVARIANT_FAILED | 再試行、API キーの交換、元の Idempotency-Key の変更、再送信をしないでください。taskId が表示されていればそれと capability、元の Idempotency-Key を添えてサポートに連絡し、REST の場合は X-Request-Id も伝えてください。 |
| 5xx | *_SERVICE_UNAVAILABLE / UPSTREAM_* | その他の 5xx は上限付き指数バックオフで再試行し、タスク ID を保持してください。この手順は CREDENTIAL_STORAGE_UNAVAILABLE には適用しません。 |
以下のパラメーターは submit のリクエスト本文です。query のポーリングには同じタスク ID フィールドを使用します。