赞
踩
请注意,在实际使用中,需要使用 API 密钥,并根据 API 文档中的信息调用正确的端点和参数。
您需要在 API 请求中包含您的 API 密钥以进行身份验证。
请求头(Headers):
Authorization
: Bearer YOUR_API_KEY获取对话记录
/conversations/:conversationId/history
GET
conversationId
: 必选。要获取历史记录的对话 ID。- curl --request GET \
- --url https://api.chatgpt.com/v1/conversations/123456/history \
- --header 'Authorization: Bearer YOUR_API_KEY'
发送消息
/conversations/:conversationId/send
POST
conversationId
: 必选。要发送消息的对话 ID。message
: 必选。发送的消息。- curl --request POST \
- --url https://api.chatgpt.com/v1/conversations/123456/send \
- --header 'Authorization: Bearer YOUR_API_KEY' \
- --header 'Content-Type: application/json' \
- --data '{"message": "hello"}'
生成文本
/models/chatgpt/generate
POST
prompt
: 必选。作为生成文本的提示。max_length
: 可选。生成文本的最大长度。temperature
: 可选。生成文本的温度。- curl --request POST \
- --url https://api.chatgpt.com/v1/models/chatgpt/generate \
- --header 'Authorization: Bearer YOUR_API_KEY' \
- --header 'Content-Type: application/json' \
- --data '{"prompt": "Hello", "max_length": 50, "temperature": 0.5}'
如果API 请求发生错误,ChatGPT OpenAPI 返回以下格式的JSON响应:
- {
- "error": {
- "code": integer,
- "message": string
- }
- }
其中,code
是 HTTP 状态码,message
含有有关该错误的更多详细信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。