request
curl https://api.openai.com/v1/chat/completions \
-X POST \
-H "Content-Type: application/json" \
--proxy-pass "127.0.0.1:7890" "https://api.openai.com" \
-H "Authorization: Bearer {your key}" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Say this is a test!"}],
"temperature": 0.7
}'
response
$ curl https://api.openai.com/v1/chat/completions \
> -X POST \
> -H "Content-Type: application/json" \
> --proxy-pass "127.0.0.1:7890" "https://api.openai.com" \
> -H "Authorization: Bearer {your key}" \
> -d '{
> "model": "gpt-3.5-turbo",
> "messages": [{"role": "user", "content": "Say this is a test!"}],
> "temperature": 0.7
> }'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:21 --:--:-- 0
curl: (28) Failed to connect to api.openai.com port 443 after 21051 ms: Timed out
curl: (3) URL using bad/illegal format or missing URL
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:21 --:--:-- 0
curl: (28) Failed to connect to api.openai.com port 443 after 21041 ms: Timed out
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
我本地在使用 clash for windows ,链接的是新加坡节点。
请问我应该如何做,才能够在本地可以正常的请求呢。
1
sillydaddy 2023-03-31 12:25:39 +08:00
直接改成
curl https://api.openai.com/v1/chat/completions \ -X POST \ -H "Content-Type: application/json" \ --proxy "127.0.0.1:7890" -H "Authorization: Bearer {your key}" \ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }' 呢。你的本地代理还需要用户名密码吗?我试了一下我的可以成功。我用的 shadowsocks ,不知道 clash 是怎么开的代理。 |
2
maltoze 2023-03-31 12:35:27 +08:00
```bash
https_proxy=http://127.0.0.1:7890 curl https://api.openai.com/v1/chat/completions \ -X POST \ -H "Content-Type: application/json" \ --proxy-pass "127.0.0.1:7890" "https://api.openai.com" \ -H "Authorization: Bearer {your key}" \ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }' ``` |
3
RedBeanIce OP @sillydaddy 好像不行,,奇怪
``` $ curl https://api.openai.com/v1/chat/completions \ > -X POST \ > -H "Content-Type: application/json" \ > --proxy "127.0.0.1:7890" \ > -H "Authorization: Bearer {your key}" \ > -d '{ > "model": "gpt-3.5-turbo", > "messages": [{"role": "user", "content": "Say this is a test!"}], > "temperature": 0.7 > }' bash: curl https://api.openai.com/v1/chat/completions -X: No such file or directory ``` |
4
RedBeanIce OP @maltoze
``` $ https_proxy=http://127.0.0.1:7890 curl openapi 的地址 \ > --X POST \ > -H "Content-Type: application/json" \ > --proxy-pass "127.0.0.1:7890" "openai 的地址" \ > -H "Authorization: Bearer {your key}" \ > -d '{ > "model": "gpt-3.5-turbo", > "messages": [{"role": "user", "content": "Say this is a test!"}], > "temperature": 0.7 > }' % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 414 100 300 100 114 64 24 0:00:04 0:00:04 --:--:-- 89{"id":"chatcmpl-700qIbFXszd2jF1O9EOaqaStAYRlx","object":"chat.completion","created":1680237594,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":14,"completion_tokens":5,"total_tokens":19},"choices":[{"message":{"role":"assistant","content":"This is a test!"},"finish_reason":"stop","index":0}]} % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 247 100 133 100 114 76 65 0:00:01 0:00:01 --:--:-- 142{ "error": { "message": "Invalid URL (POST /)", "type": "invalid_request_error", "param": null, "code": null } } ``` 好像可以!!!!感谢。。。。。 虽然第二个失败了 |
5
RedBeanIce OP https_proxy=http://127.0.0.1:7890 curl --raw -----/v1/chat/completions \
-X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {your key}" \ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "how match now date"}], "temperature": 0.7 }' 这样子就 ok 了。请将---替换一下。 |
6
RedBeanIce OP @sillydaddy 发现了,。是我的问题。。是可以的。
|