Hey everyone, I’m working on integrating OpenAI’s API into my website, lewisestimating.com, but I keep hitting some roadblocks. I’ve followed the official documentation to set up the API calls, but I’m getting unexpected errors when trying to pass data to OpenAI’s models.
I’m specifically working on integrating it for a chatbot feature, where users can ask questions related to estimating services, but every time I try a request, the response is either delayed or returns an error message that I can’t quite figure out.
Has anyone here experienced similar issues with API integration? I’ve tried checking the authentication, formatting the data correctly, and making sure the rate limits aren’t being hit, but no luck so far.
Any advice or troubleshooting tips would be greatly appreciated! Thanks in advance!
Thanks for the reply! Yeah, here’s a bit more detail:
When I send a request to the API sometimes I get this:
{
“error”: {
“message”: “The model did not return a response”,
“type”: “server_error”,
“param”: null,
“code”: null
}
}
Other times, the request just hangs for 20–30 seconds before timing out.
I’ve already verified that my API key is valid, and I’m using the correct headers (Content-Type: application/json and Authorization: Bearer <API_KEY>). The payload looks something like this:
{
“model”: “gpt-4o-mini”,
“messages”: [
{“role”: “system”, “content”: “You are an estimating assistant.”},
{“role”: “user”, “content”: “What’s included in a masonry estimate?”}
]
}
I’m running this on a Node.js backend. Everything works fine in Postman, but when I call it from my frontend through my backend route, that’s when the errors start happening.
Could this be something like a CORS problem or maybe a timeout issue? Any ideas would help a lot!
I’ve tried changing the timeout and double-checked the API key. Like I said, it works perfectly in Postman, but calling it through my backend sometimes hangs or gives that “model did not return a response” error.
Do you see anything in this code that could be causing the issue?
btw..i know there is link after
try {
const response = await axios.post(
but I can’t add it here..due to policy