You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is a Node library issue and not an underlying OpenAI API issue
This is an issue with the Node library
Describe the bug
Hi,
When attempting to use expo/fetch on Expo Android, I encountered a 400 Bad Request error. It's unlikely that this issue is related to the trailing slash, as I've already reviewed and ruled out that possibility.
Error: 400 <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
]
To Reproduce
Essentially, using the 'fetch' function directly worked fine. However, when I attempted to use it in conjunction with the OpenAI module, it resulted in failure.
Working :
import{fetch}from'expo/fetch';try{constresponse=awaitfetch('https://api.openai.com/v1/chat/completions',{method: 'POST',headers: {'Content-Type': 'application/json','Authorization': `Bearer sk-XXX`,},body: JSON.stringify({model: "gpt-4o-mini",messages: [{role: "user",content: "Hello, how are you?"}],}),});constdata=awaitresponse.json();console.log(data);}catch(error){console.error(error);}
Not working:
import{fetch}from'expo/fetch';constopenai=newOpenAI({apiKey: "XXXX",},{fetch: fetch});try{constresponse=awaitopenai.chat.completions.create({model: "gpt-4o-mini",messages: [{role: "user",content: "Hello, how are you?"}],});console.log(response);}catch(error){console.error(error);}
Do you have any insights into why this issue may be occurring?
Thank you
Code snippets
No response
OS
android
Node version
node
Library version
4.77.0
The text was updated successfully, but these errors were encountered:
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
Hi,
When attempting to use expo/fetch on Expo Android, I encountered a
400 Bad Request
error. It's unlikely that this issue is related to the trailing slash, as I've already reviewed and ruled out that possibility.To Reproduce
Essentially, using the 'fetch' function directly worked fine. However, when I attempted to use it in conjunction with the OpenAI module, it resulted in failure.
Working :
Not working:
Do you have any insights into why this issue may be occurring?
Thank you
Code snippets
No response
OS
android
Node version
node
Library version
4.77.0
The text was updated successfully, but these errors were encountered: