HAI Gateway 文档中心

Google

Google Gemini Generate Content

Generates a model response given an input prompt and other parameters.

POSTv1beta/models/{model}:generateContent

Authorizations

x-goog-api-keystringheader

鉴权方式 1 — Header:x-goog-api-key: sk-pat-您的AccessToken

keystringquery

鉴权方式 2 — Query 参数:?key=sk-pat-您的AccessToken

密钥的值使用HAI Gateway的个人访问令牌(以 sk-pat- 开头),无需在Google处单独申请 API Key。两种鉴权方式任选其一即可。

Base URL

Body 参数

请求体格式与 Google Gemini API 完全一致,详细参数说明请参考 Google 官方文档

流式请求

流式接口路径为 :streamGenerateContent,替换 :generateContent 即可。

cURL
cURL:Default
curl https://api.hai.network/google/v1beta/models/gemini-2.5-pro:generateContent \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: sk-pat-您的Access Token" \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Write a story about a magic backpack."
          }
        ]
      }
    ]
  }'