メインコンテンツへスキップ
Gemini 互換の連携には /v1beta/models/{model}:generateContent を使用します。
curl https://apiany.ai/v1beta/models/gemini-3.5-flash:generateContent \
  -H "Authorization: Bearer $APIANY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [
          { "text": "メディア生成タスクが非同期処理に向いている理由を説明してください。" }
        ]
      }
    ]
  }'
パス中の model は APIAny.AI の公開モデル ID です。

ストリーミング

パス中の :generateContent:streamGenerateContent に置き換えると、Gemini の SSE ストリーム (増分の candidates をチャンクごとに返す)を取得できます。
curl https://apiany.ai/v1beta/models/gemini-3.5-flash:streamGenerateContent \
  -H "Authorization: Bearer $APIANY_API_KEY" \
  -H "Content-Type: application/json" -N \
  -d '{ "contents": [ { "parts": [ { "text": "こんにちは" } ] } ] }'

構造化出力

generationConfig.responseMimeType: "application/json"responseSchema と組み合わせると、 JSON 出力が得られます:
{
  "contents": [{ "parts": [{ "text": "名前と年齢を抽出する" }] }],
  "generationConfig": {
    "responseMimeType": "application/json",
    "responseSchema": {
      "type": "object",
      "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }
    }
  }
}

パラメータ

対応している generationConfigtemperaturetopPtopKmaxOutputTokensstopSequencesresponseMimeTyperesponseSchemaresponseModalitiesIMAGE を含めると画像を返します)。さらにトップレベルの tools(functionDeclarations)と systemInstruction にも対応しています。