Skip to content

OpenAI engine: requests over ~300 s fail with openai >= 5, whatever the timeout #59

Closed

Description

@lordrip

engines.openai() cannot wait more than about 5 minutes for a clip when the installed openai SDK is version 5 or newer, whatever timeout the SDK is given.

From v5 the SDK uses Node's built-in fetch (undici), whose headersTimeout is 300 s by default. The SDK's own timeout (10 minutes by default) does not raise it, so a request that has not received response headers after 300 s fails with APIConnectionTimeoutError. With v4 (node-fetch) there is no such limit.

OpenAI's own API answers well within that, so this mostly affects self-hosted OpenAI-compatible servers (see the baseUrl option in #58): on CPU a long sentence can take several minutes. The peer range is openai: ">=4", so a fresh install gets v6 and hits it.

Reproduce

A stub server that answers after 320 s:

// stub.mjs
import http from 'node:http';
http.createServer((req, res) => {
  req.resume();
  setTimeout(() => { res.writeHead(200, { 'content-type': 'audio/pcm' }); res.end(Buffer.alloc(480)); }, 320_000);
}).listen(9902);
// call.mjs
import { OpenAI } from 'openai';
const client = new OpenAI({ apiKey: 'unused', baseURL: 'http://127.0.0.1:9902/v1', timeout: 1_800_000, maxRetries: 0 });
await client.audio.speech.create({ model: 'm', voice: 'v', input: 'x', response_format: 'pcm' });

Measured on Node 24, Windows:

openai Result
4.104.0 ok after 320 s
6.49.0 APIConnectionTimeoutError: Request timed out. after 304 s

Possible fixes (maintainer's call)

  1. Let callers pass a fetch (or fetchOptions) through engines.openai(), e.g. one using an undici Agent with a larger headersTimeout. No new dependency in Argo.
  2. Have the engine create an undici Agent from timeoutMs itself. Works out of the box, adds undici as a dependency.
  3. Keep the documented limit (the README mentions it as of feat(tts): OpenAI engine talks to any OpenAI-compatible server #58).

Acceptance criteria

  • A request through engines.openai() with openai >= 5 can wait longer than 300 s for a response when configured to, or the README states the limit and how to work around it.
  • A test or reproduction shows the chosen behaviour.

Activity

  1. added a commit that references this issue on Oct 28, 2026
    bf387d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions