Python ChatGPT 调用脚本:快速构建聊天机器人
import requests
GPT-3 API URL
url = 'https://api.openai.com/v1/engines/davinci/completions'
GPT-3 API headers
headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer your-gpt-3-api-key' }
Request payload
data = { 'prompt': 'Hi, I'm looking for a chatbot to help me with my customer service.', 'max_tokens': 256 }
Make the API request
response = requests.post(url, headers=headers, json=data)
Display the response
print(response.json())
原文地址: https://www.cveoy.top/t/topic/lmdG 著作权归作者所有。请勿转载和采集!