Skip to content

Allow configuring AI_API timeout in compiler plugin options #2053

@cloudycotton

Description

@cloudycotton

Problem

The @lingo.dev/compiler Vite plugin uses a hardcoded 60-second timeout (DEFAULT_TIMEOUTS.AI_API = 6e4) for AI translation API calls during build. This timeout is defined in src/utils/timeout.ts and used by the LingoTranslator for both Lingo.dev Engine and LLM-based translations.

In CI/CD environments (e.g., Google Cloud Build with Docker), network latency to OpenAI is often higher than local development. When translating to multiple locales with many entries, individual chunk translations frequently exceed the 60-second limit, causing the build to fail with:

TimeoutError: openai LLM translation to zh timed out after 60000ms

Current workaround

We're patching node_modules in our Dockerfile before build:

RUN sed -i 's/AI_API: 6e4/AI_API: 3e5/' node_modules/@lingo.dev/compiler/build/utils/timeout.mjs \
  && sed -i 's/AI_API: 6e4/AI_API: 3e5/' node_modules/@lingo.dev/compiler/build/utils/timeout.cjs

Proposed solution

Expose an optional timeout (or aiTimeout) field in LingoPluginOptions / PartialLingoConfig:

lingoCompilerPlugin({
  sourceRoot: './src',
  sourceLocale: 'en',
  targetLocales: ['zh', 'de', 'pt', 'uk', 'fil'],
  models: { '*:*': 'openai:gpt-4o-mini' },
  buildMode: 'translate',
  // New option — override default 60s AI API timeout
  aiTimeout: 300_000, // 5 minutes
})

This would allow users in slower network environments or with large translation sets to configure an appropriate timeout without patching internals.

Environment

  • @lingo.dev/compiler: ^0.3.6
  • Build environment: Google Cloud Build (Docker)
  • Model: openai:gpt-4o-mini
  • Target locales: 5 (zh, fil, de, uk, pt)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions