跳转到主要内容
使用 /v1beta/models/{model}:generateContent 调用 Gemini 兼容接口。
curl https://api.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://api.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" } }
    }
  }
}

参数

支持 generationConfigtemperaturetopPtopKmaxOutputTokensstopSequencesresponseMimeTyperesponseSchemaresponseModalities (含 IMAGE 时返回图片)。另支持顶层 tools(functionDeclarations)与 systemInstruction