OpenAI shares a method for creating a streaming response assistant using Python or Node.js, but not with cURL. Does anyone know which endpoints are used for streaming responses with cURL, without using Python or Node.js?
You need to the -N
for curl to retrieve steamed responses:
curl -N https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"stream": true
}'
Thank you for your help! However, this cURL command is used for regular models. I need to stream the assistant’s response. If you check the OpenAI website where they share the documentation for their API, the assistant’s streaming response isn’t shown for curl. In regular models, the responses are delivered in chunks, where each chunk contains a token. With HTTP, we receive two chunks per request, so we just need to iterate through the chunks. However, the assistant doesn’t operate in this manner. Therefore, I need to know if someone has discovered how the library works to use the direct WebSocket from OpenAI
This is what I am trying to find as well. I converted all these Assistant API’s cURL to Apex Programming Language but the final step “Streaming” is still pending as no CURL is available.
I suppose the only solution is to pay for a VPS in order to create a WebSocket that can be used in the frontend. Therefore, in addition to paying for OpenAI’s API, we also need to pay for the backend server. That’s bad…
Did you find the solution?