Vision(画像入力)ガイド
POST /v1/chat/completionsのmessagesに 画像を渡して解析できます(OpenAI 互換)。 追加のエンドポイントはありません。scopellmの API キーがそのまま使えます。
必要な scope
api.aicu.ai の API キーには scope(権限区分)があり、エンドポイント群ごとに必要な scope が異なります。
| scope | 使えるもの | Vision に必要? |
|---|---|---|
llm | /v1/chat/completions(テキストも画像入力も) | ✅ |
images | /v1/images/*(画像生成) | 不要 |
tts | /v1/tts/*・/v1/audio/transcriptions(音声合成・文字起こし) | 不要 |
- Vision は「チャット補完に画像を渡す」機能なので
llmscope だけで使えます。imagesは画像を作るときの scope です - ダッシュボードで発行したキーは既定で
llm/tts/imagesが付きます - 業務発行キー(最小権限運用)で
403が返る場合は scope 不足です。発行元に scope 追加を依頼してください
叩き方(curl・画像URL)
curl -X POST https://api.aicu.ai/v1/chat/completions \
-H "Authorization: Bearer $AICU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "この画像を日本語で説明して"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}],
"max_tokens": 300
}'
content を文字列ではなく 配列にし、type: "image_url" のパートを混ぜるのがポイントです。
messages はプロバイダへそのまま転送されるため、OpenAI の Vision 仕様がそのまま通ります。
叩き方(Python・ローカル画像を base64 で)
import base64, os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AICU_API_KEY"],
base_url="https://api.aicu.ai/v1",
)
b64 = base64.b64encode(open("frame.jpg", "rb").read()).decode()
res = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "この画像の見どころを1行で"},
{"type": "image_url", "image_url": {
"url": f"data:image/jpeg;base64,{b64}",
"detail": "low",
}},
],
}],
max_tokens=300,
)
print(res.choices[0].message.content)
detail:low(低解像度・低コスト) /high(タイル分割・高精度) /auto。大量のフレーム解析はlow推奨
対応モデルと料金
- Vision 対応:
gpt-4o-mini(推奨・低単価) /gpt-4o deepseek-v3などテキスト専用モデルにimage_urlを渡すとエラーになります- 画像はトークンに換算されて課金されます(OpenAI 準拠。
detail: low1枚 ≈ 85 tokens。gpt-4o-miniはトークン数が約33倍で数えられる代わりに単価が安く、コストはほぼ同等 — 実測: low 1枚 + 短文で ≈ 2,900 tokens)。モデル別 AP 単価はGET /v1/chat/modelsを参照
トラブルシュート
| 症状 | 原因 |
|---|---|
403 Forbidden | キーに llm scope がない → 発行元に追加依頼 |
401 Unauthorized | キー無効・期限切れ |
| 画像取得エラー | URL が非公開・認証つき → base64(data URL)で送る |
OpenAI 公式ドキュメント(互換仕様の一次情報)
- Images and vision ガイド: https://platform.openai.com/docs/guides/images-vision
- Chat Completions API リファレンス: https://platform.openai.com/docs/api-reference/chat/create
© 2026 AICU Inc.