Comments (1)
用法
JavaScript用fetch
const requestOptions = {
method: 'POST',
headers: {
"Authorization": "Bearer sk-xxxxxxxxxxxx",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "hello word"
}
]
})
};
fetch("https://openai.1rmb.tk/v1/chat/completions", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
用python
import requests
url = "https://openai.1rmb.tk/v1/chat/completions"
api_key = 'sk-xxxxxxxxxxxxxxxxxxxx'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
payload = {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "hello word"
}
]
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status() # 抛出异常,如果响应码不是200
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print(f"请求错误: {e}")
except json.JSONDecodeError as e:
print(f"无效的 JSON 响应: {e}")
用nodejs chatgpt库
transitive-bullshit/chatgpt-api
import { ChatGPTAPI } from 'chatgpt'
async function example() {
const api = new ChatGPTAPI({
apiKey: "sk-xxxxxxxxxxxxxx",
// proxy+/v1
apiBaseUrl:"https://openai.1rmb.tk/v1"
})
const res = await api.sendMessage('Hello World!')
console.log(res.text)
}
example()
from chatgptproxyapi.
Related Issues (20)
- 使用digitalocean搭建用不了 HOT 2
- 如何更换api路径? HOT 1
- 已经按照第2种方法设置好cloudfare的page,后续怎样使用访问openai? HOT 1
- 安装第3种方法,打开https://xxx.xxx/api报以下错误 HOT 4
- 能否代理登录接口 HOT 1
- 搭建好了之后如何修改首页的默认页面? HOT 1
- 开头少字如何解决 HOT 2
- 哪里能买到GPT-4 API HOT 1
- 如何在Vercel上部署? HOT 3
- Cloudflare 域名只能用网站上买的吗?怎么添加不了 HOT 1
- 想问下这个走cloudflare与购买静态美国住宅代理IP有什么区别? HOT 3
- 可否使用2个本项目代理调用openai api? HOT 3
- 使用CloudFlare Pages进行中转,通过自定义域的方式遇到报错 HOT 4
- 查询余额api报错 HOT 1
- 可否告知如何打包成docker镜像,需要转到别的网站 HOT 1
- 请问能否改成更加通用的版本?即不光是代理openai,甚至wikipedia,discord等,即用户想要好访问的目标地址,可以作为参数上传? 这是github copilot给的版本,帮忙看看是否能达到效果?
- 无效 HOT 1
- Sorry, you have been blocked HOT 12
- 还是提示连接错误,但是请求是发送到cloudflare的,奇奇怪怪 HOT 3
- 代理不是流式输出的吗,为什么使用了之后要等所有回答文字都返回了才输出
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatgptproxyapi.