メインコンテンツへスキップ
Endpoint: POST /projects/cognition/locations/us/publishers/google/models/{model}:generateContent Google Gemini でテキストまたは多モーダル生成を行います。
多くの統合は Create Chat Completion を推奨します。Google ネイティブの generateContent 形式が必要な場合にこのエンドポイントを使ってください。
import requests

url = "https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-1.5-pro-latest:generateContent"

response = requests.post(
    url,
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
        "vendor": "google",
    },
    json={"contents": [{"role": "user", "parts": [{"text": "hello gemini"}]}]},
)
print(response.json())

パラメータ

model
string
必須
使用する Gemini モデル(例: gemini-1.5-pro-latest)。
contents
array
必須
入力テキストやマルチメディア parts。
safetySettings
object
任意のセーフティ設定。

画像入力

画像バイトは inlineData(base64)で渡します。
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
  -H "Authorization: Bearer $YOUROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "vendor: google" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Describe this image in one sentence." },
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "<BASE64_IMAGE>"
            }
          }
        ]
      }
    ]
  }'
全体の導線は マルチモーダル を参照してください。