纯文字输入
POST
/v1/models/gemini-pro:generateContentGemini API 还可处理纯文字输入。借助此功能,您可以执行自然语言处理 (NLP) 任务,例如文本补全和摘要。
请求参数
Query 参数
key
string
必需
示例值:
{{API_KEY}}
Header 参数
Content-Type
string
必需
示例值:
application/json
Body 参数application/json
contents
array [object {1}]
必需
parts
array [object {1}]
可选
示例
{
"contents": [
{
"parts": [
{
"text": "广东省的省会是哪里"
}
]
}
]
}
示例代码
返回响应
成功(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
object {0}
示例
{
"candidates": [
{
"content": {
"parts": [
{
"text": "广州市"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
}
最后修改时间: 8 个月前