格式化输出
POST https://aiapi.winfull.top/v1beta/models/gemini-2.5-pro:generateContent 官方文档:https://ai.google.dev/gemini-api/docs/structured-output?hl=zh-cn
请求参数
Authorization 在 Header 添加参数 Authorization ,其值为在 Bearer 之后拼接 Token 示例: Authorization: Bearer ******************** Query 参数 生成代码 Header 参数 生成代码 Body 参数application/json 生成代码 示例
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "List a few popular cookie recipes, and include the amounts of ingredients."
}
]
}
],
"generationConfig": {
"responseMimeType": "application/json",
"responseSchema": {
"type": "ARRAY",
"items": {
"type": "OBJECT",
"properties": {
"recipeName": {
"type": "STRING"
},
"ingredients": {
"type": "ARRAY",
"items": {
"type": "STRING"
}
}
},
"propertyOrdering": [
"recipeName",
"ingredients"
]
}
}
}
}请求示例代码
Shell JavaScript Java Swift Go PHP Python HTTP C C# Objective-C Ruby OCaml Dart R 请求示例请求示例 Shell JavaScript Java Swift cURLcURL-WindowsHttpiewgetPowerShell
curl --location -g --request POST 'https://aiapi.winfull.top/v1beta/models/gemini-2.5-pro:generateContent?key=' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "List a few popular cookie recipes, and include the amounts of ingredients."
}
]
}
],
"generationConfig": {
"responseMimeType": "application/json",
"responseSchema": {
"type": "ARRAY",
"items": {
"type": "OBJECT",
"properties": {
"recipeName": {
"type": "STRING"
},
"ingredients": {
"type": "ARRAY",
"items": {
"type": "STRING"
}
}
},
"propertyOrdering": [
"recipeName",
"ingredients"
]
}
}
}
}'返回响应
🟢200成功 application/json生成代码 Body 生成代码 示例
{}修改于 2025-12-01 17:06:13
