From ea0148626bfc3709f80bfed8846c422ee08a71cf Mon Sep 17 00:00:00 2001 From: Abhinavexist Date: Wed, 22 Jul 2026 02:55:07 +0530 Subject: [PATCH] fix: default client timeout to 900s (900000ms) so large document/OCR jobs aren't cut short MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Interfaze's /v1/chat/completions runs synchronously with an 800s server cap (maxDuration=800). openai-node defaults to a 600s timeout — below the server's own limit — so large multi-page PDF->markdown / OCR / vision requests time out client-side even though the server would still return. Default to 900000ms (server cap + buffer), overridable via new Interfaze({ timeout }). --- README.md | 2 ++ src/client.ts | 3 ++- src/constants.ts | 1 + test/client.test.ts | 10 ++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83934db..9ae6fa8 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ are rejected client-side (Interfaze does not accept them). - `temperature` ≤ 1, `max_tokens` ≤ 32000, `top_p` ≤ 1 (values above → 400). - Both `max_tokens` and `max_completion_tokens` bound output length (`max_tokens` wins if both set). - `n`, `seed`, `stop`, penalties, `logprobs`, `tool_choice`, `top_k` are ignored by Interfaze. +- Requests default to a 900s timeout (large OCR/document/vision jobs are slow); override with + `new Interfaze({ timeout: ... })` (milliseconds). - The underlying OpenAI client is available at `interfaze.openai` as an escape hatch. ## License diff --git a/src/client.ts b/src/client.ts index a17a6f2..9a9dd6c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -2,7 +2,7 @@ import OpenAI from "openai"; import type { ClientOptions } from "openai"; import { InterfazeChat } from "./chat.js"; -import { HEADERS, INTERFAZE_BASE_URL } from "./constants.js"; +import { DEFAULT_TIMEOUT_MS, HEADERS, INTERFAZE_BASE_URL } from "./constants.js"; import { InterfazeError } from "./errors.js"; import { Tasks } from "./tasks.js"; @@ -54,6 +54,7 @@ export class Interfaze { apiKey: resolvedKey, baseURL: baseURL ?? INTERFAZE_BASE_URL, defaultHeaders: headers, + timeout: rest.timeout ?? DEFAULT_TIMEOUT_MS, }); this.chat = new InterfazeChat(this.openai); diff --git a/src/constants.ts b/src/constants.ts index e597eea..68cca40 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,6 @@ export const INTERFAZE_BASE_URL = "https://api.interfaze.ai/v1"; export const INTERFAZE_MODEL = "interfaze-beta"; +export const DEFAULT_TIMEOUT_MS = 900_000; /** Task names accepted in a `` tag. */ export const TASK_NAMES = [ diff --git a/test/client.test.ts b/test/client.test.ts index 66f5afb..7889538 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -43,4 +43,14 @@ describe("client construction", () => { expect(i.openai).toBeDefined(); expect(i.openai.chat.completions).toBeDefined(); }); + + it("defaults the timeout above the server's 800s cap", () => { + const i = new Interfaze({ apiKey: "sk-test" }); + expect((i.openai as unknown as { timeout: number }).timeout).toBe(900_000); + }); + + it("respects an explicit timeout", () => { + const i = new Interfaze({ apiKey: "sk-test", timeout: 30_000 }); + expect((i.openai as unknown as { timeout: number }).timeout).toBe(30_000); + }); });