Open jiangweiatgithub opened 2 weeks ago
It should be: curl -X POST "http://localhost:8001/v1/chat/completions" -H "Content-Type: application/json" -H "Authorization: Bearer abcd" -d "{\"model\": \"gpt-4o\", \"messages\": [{\"role\": \"user\", \"content\": \"你好,你好吗?\"}], \"stream\": false}" {"id":"chatcmpl-de4f38d8-9703-4fe1-8366-d9f728a18b57","object":"chat.completion","created":1725145718,"model":"gpt-4o","choices":[{"index":0,"message":{"role":"assistant","content":"你好!我很好,谢谢。你呢?"},"finish_reason":"stop"}],"usage":null}
You're right, you need to add 'Bearer' to the Authorization header. This reverse service is designed to match the OpenAI chat interface, so the parameters and headers are consistent with those of OpenAI.
docker run -p 8001:8001 -e APP_SECRET=abcd yeschat2api INFO: Started server process [1] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit) INFO: 172.17.0.1:46756 - "POST /v1/chat/completions HTTP/1.1" 403 Forbidden INFO: 172.17.0.1:46760 - "POST /v1/chat/completions HTTP/1.1" 403 Forbidden INFO: 172.17.0.1:46764 - "POST /v1/chat/completions HTTP/1.1" 403 Forbidden INFO: 172.17.0.1:46768 - "POST /v1/chat/completions HTTP/1.1" 403 Forbidden INFO: 172.17.0.1:46772 - "POST /v1/chat/completions HTTP/1.1" 403 Forbidden
curl -X POST "http://localhost:8001/v1/chat/completions" -H "Content-Type: application/json" -H "Authorization: abcd" -d "{\"model\": \"gpt-4o\", \"messages\": [{\"role\": \"user\", \"content\": \"你好,你好吗?\"}], \"stream\": false}" {"detail":"Not authenticated"}