跳转到主要内容
POST
/
v1beta
/
models
/
{model}
:generateContent
curl --request POST \
  --url https://api.shuyou.ai/v1beta/models/{model}:generateContent \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Please introduce yourself."
        }
      ]
    }
  ]
}
'
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Hello! How can I help you today?"
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 12,
    "candidatesTokenCount": 18,
    "totalTokenCount": 30
  },
  "modelVersion": "gemini-3.5-flash",
  "responseId": "resp_example"
}

授权

Authorization
string
header
必填

Authorization: Bearer YOUR_API_KEY

路径参数

model
string
必填

Model ID in Google Native API format (e.g. gemini-3.5-flash, gemini-2.5-flash).

示例:

"gemini-3.5-flash"

请求体

application/json
contents
object[]
必填

Conversation contents. Supports multi-turn dialogue and multimodal input.

Minimum array length: 1
systemInstruction
object

System instruction (optional). Use text parts only.

generationConfig
object

Generation parameters (sampling, length, structured output, modalities, thinking, etc.).

tools
object[]

Tools the model may call (function calling, search, code execution, etc.).

toolConfig
object

Tool configuration shared across all tools in the request.

safetySettings
object[]

Per-request safety settings for candidates.

cachedContent
string

Cached content resource name, e.g. cachedContents/{id}.

响应

Content generated successfully

candidates
object[]
promptFeedback
object
usageMetadata
object
modelVersion
string
responseId
string