画像・音声・動画・検索の統合

これらの機能もチャットと同じ Base URL と bearer キーを使用しますが、エンドポイントとペイロードは機能ごとに異なります。以下のモデル ID は動作例です。本番導入前に コンソール → モデル で最新のモデル一覧を確認してください。

画像生成

POST /v1/images/generations

JSON 形式でプロンプトを送信します。生成結果は data[0].url、選択したモデルが base64 を返す場合は data[0].b64_json から取得します。

主要パラメータ: promptmodel は必須です。解像度は size、画像数は n、返却形式は response_formaturl または b64_json)で指定します。qualitystyle はモデル固有です。一般的な値には standardhdauto があります。

curl · image
curl https://api.chinaapi.ai/v1/images/generations \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-4-5-251128",
    "prompt": "A cinematic skyline at blue hour",
    "size": "1024x1024",
    "response_format": "url",
    "n": 1
  }'

Gemini 画像生成

POST /v1/chat/completions

Gemini 画像モデルは OpenAI Chat Completions 形式を使用します。生成された Markdown 画像は choices[0].message.content から取得します。画像ペイロードは data:image/... URL です。

主要パラメータ: ログイン後のカタログに表示されるモデル ID を model に、画像プロンプトを messages に指定します。このモデルを /v1/images/generations に送信しないでください。

curl · Gemini image chat
curl https://api.chinaapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<GEMINI_IMAGE_MODEL>",
    "messages": [
      {
        "role": "user",
        "content": "Generate a cinematic skyline at blue hour"
      }
    ],
    "stream": false
  }'

音声認識

POST /v1/audio/transcriptions

音声ファイルを multipart form data でアップロードします。Content-Type ヘッダーは手動で設定しないでください。認識結果は text フィールドで返されます。

主要パラメータ: modelfile を multipart フィールドとして送信します。選択モデルが対応する場合、response_formatjsontextverbose_json を指定できます。

curl · transcription
curl https://api.chinaapi.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -F "model=qwen3-asr-flash" \
  -F "file=@speech.wav" \
  -F "response_format=json"

音声合成

POST /v1/audio/speech

レスポンス本文はバイナリ音声なので、ファイルに保存します。alloy はモデルのデフォルト音声を選択します。モデルによってはプロバイダー固有の音声 ID も使用できます。

主要パラメータ: inputmodelvoice を使用します。response_formatmp3wav などの出力形式を選択します。speedinstructions は選択モデルが対応する場合に利用できます。

curl · speech
curl https://api.chinaapi.ai/v1/audio/speech \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mimo-v2.5-tts",
    "input": "Hello from ChinaAPI.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output speech.mp3

動画生成

POST /v1/video/generations

動画生成は非同期です。1 回だけ送信して返された task_id を保存し、成功または失敗するまで GET /v1/video/generations/{task_id} をポーリングします。タスクの作成はクォータを消費する場合があります。

主要パラメータ: promptmodel でタスクを開始します。対応モデルでは durationwidthheightfpsn を使用できます。一般的な明瞭度の指定は解像度です。qualityquality_levelnegative_prompt、カメラ設定などの提供元固有パラメータは、そのモデルに掲載されている場合のみ metadata に指定してください。

curl · video
curl https://api.chinaapi.ai/v1/video/generations \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.1-t2v",
    "prompt": "A paper boat crossing a moonlit lake",
    "duration": 5,
    "width": 1280,
    "height": 720
  }'

curl https://api.chinaapi.ai/v1/video/generations/$TASK_ID \
  -H "Authorization: Bearer $CHINAAPI_KEY"