Seeking Help with Excel VBA Script for OpenAI API Access to Custom Assistant - Timeout Issues

Hello everyone,

I’m working on a project that involves integrating OpenAI’s API directly into Excel using a VBA script. My objective is to access a custom assistant I’ve configured with OpenAI, aiming to automate specific tasks within Excel by leveraging AI. I’ve made progress in setting up the API calls from the VBA script to interact with my custom assistant. However, I’ve hit a snag with timeouts, particularly when my script attempts to poll the status of the API call.

Here’s the relevant part of my VBA code that checks the API call status:
’ 4. Poll the run status until it’s complete
startTime = Timer
Do While status = “queued” Or status = “in_progress”
Call SetupHttpRequest(http, “GET”, “https :// api . openai . com / v1 / threads/” & threadId & “/runs/” & runId, OPENAI_API_KEY)
http.send “”
status = ExtractJsonValue(http . responseText, “status”)
If Timer - startTime > 29 Then
askOpenAIAssistant = “Timeout waiting for the run to complete.”
Exit Function
End If
DoEvents
Loop

Despite my efforts to monitor the run status until completion or a 29-second timeout threshold, I frequently face timeouts. This issue has been a significant roadblock in successfully leveraging my custom assistant through Excel.

I’m reaching out for advice or insights from anyone who has successfully set up a similar Excel VBA integration with OpenAI’s API, especially when accessing a custom assistant. How have you managed or avoided these timeout issues? Any tips, strategies, or code examples that could help me refine my VBA script to handle API responses more effectively and avoid these frustrating timeouts would be immensely helpful.

Thank you all for your time and assistance. I’m looking forward to any guidance you can provide!

Hi Leon,

Apologies, I don’t have a solution for this at present.

However, I’d be very interested in seeing your VBA as I’m doing an alike project, which is trying to access my custom assistant with OpenAI. I’m frequently getting issues with it not being able to parse the JSON body of the request.

If you are willing to share your VBA script i would be very thankful.

Kind Regards