zsodur / chatgpt-api-by-browser-script

This project runs on users' browsers through the Tampermonkey script and converts the web version of ChatGPT operations into an API interface. This way, you can use GPT-4 in chatgpt web pages to play things like Auto-GPT. / 该项目通过Tampermonkey脚本在用户的浏览器上运行,并将ChatGPT操作的Web版本转换为API接口。这样,您就可以使用chatgpt网页中的GPT-4来玩Auto-GPT等内容。
195 stars 40 forks source link

如何调用这段api到其他的程序中??? #4

Open femnn opened 1 year ago

femnn commented 1 year ago

之前调用api的语句是:import openai

openai.api_key = 'your-api-key'或者:set OPENAI_API_KEY=your-api-key

这种。但是现在这个网址应该怎么调用?在不同类型的代码中应该如何进行调用

zsodur commented 1 year ago

import requests

response = requests.post("http://localhost:8766/v1/chat/completions", json={"messages": messages, "model": model, "newChat": False}).json()

content = response["choices"][0]["message"]["content"]

无法使用openai官方库, 不需要设置api_key, 参考以上python代码调用

femnn commented 1 year ago

好的十分感谢,我这就试试看