文本生成

POST /v1beta/models/gemini-2.5-pro:generateContent

MethodPOST
Path/v1beta/models/gemini-2.5-pro:generateContent
Typehttp
Status1
Module2102810
Folder61214320

说明

概览

MethodPOST
Path/v1beta/models/gemini-2.5-pro:generateContent
Typehttp
Status1
Module2102810
Folder61214320

参数

{
  "query": [
    {
      "name": "key",
      "required": true,
      "description": "",
      "id": "b4inb5ENt1",
      "type": "string",
      "enable": false,
      "sampleValue": "{{YOUR_API_KEY}}"
    }
  ],
  "header": [
    {
      "name": "Content-Type",
      "required": true,
      "description": "",
      "id": "fuFf2peRev",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "contents": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "parts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "required": [
      "contents"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\n  \"systemInstruction\": {\n    \"parts\": [\n      {\n        \"text\": \"你是一直小猪.你会在回复开始的时候 加一个'哼哼'\"\n      }\n    ]\n  },\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"你是谁?\"\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"temperature\": 1,\n    \"topP\": 1,\n    \"thinkingConfig\": {\n      \"includeThoughts\": true,\n      \"thinkingBudget\": 26240\n    }\n  }\n}",
      "name": "示例"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 691307655,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]