cd /news/large-language-models/how-i-fixed-openai-assistants-api-ti… · home topics large-language-models article
[ARTICLE · art-44476] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=· neutral

How I Fixed OpenAI Assistants API Timeout Errors in Production

A developer fixed timeout errors in the OpenAI Assistants API by making the timeout configurable. The hardcoded 60-second limit was too short for long sessions, causing premature failures. The solution involved increasing the timeout to 150 seconds and updating the polling loop.

read1 min views1 publishedJun 30, 2026

It was during a live client demo.

The AI was mid-session. The user was answering questions.

Everything was going perfectly.

Then — this:

"Sorry, there was an error processing your request. Please try again."

The client looked at us. My manager looked at me. I looked at my laptop

and wanted to disappear.

First thing I checked: OpenAI dashboard. No failed runs. Nothing.

I checked our server logs. There it was:

run_timeout

— after exactly 60 seconds

But here's the thing — the run wasn't failing. It was just slow.

OpenAI was still processing. Our backend gave up at 60s.

OpenAI finished at 87s.

We quit too early.

The longer a session gets, the more history OpenAI has to process.

Early in a session: 3–5 seconds.

Mid-session (10+ messages): 30–50 seconds.

Long sessions: 60–90+ seconds.

Our hardcoded limit of 60 seconds wasn't matching reality.

Step 1: Made the timeout configurable via environment variable.

  OPENAI_RUN_TIMEOUT_MS=150000

Step 2: Updated the polling loop to use it.

  const TIMEOUT_MS = parseInt(process.env.OPENAI_RUN_TIMEOUT_MS) || 150000;
  const TERMINAL = ['completed', 'failed', 'cancelled', 'expired', 'requires_action'];

  while (!TERMINAL.includes(runStatus.status)) {
    if (Date.now() - startTime >= TIMEOUT_MS) throw new Error('run_timeout');
    await new Promise(r => setTimeout(r, 1000));
    runStatus = await openai.beta.threads.runs.retrieve(threadId, run.id);
  }

Step 3: Deployed. No more errors.

I'm exploring runs.stream()

— streaming responses in real time,

no polling, no timeouts. Will write a follow-up once it's in production.

Have you hit this before? How did you handle it?

Drop it in the comments.

── more in #large-language-models 4 stories · sorted by recency
── more on @openai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-i-fixed-openai-a…] indexed:0 read:1min 2026-06-30 ·