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); + }); });