Add request timeout to OpenAI

This commit is contained in:
GyeongSu Han 2026-01-28 22:49:26 +09:00 • committed by GitHub
parent cfd9bc4e31
commit b970565f8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,11 +18,14 @@ import type {
import { z } from "zod";
import { OpenAIConfigSchema } from "../types.js";
import {
customFetch,
chatChunk,
usageChatChunk,
chatChunkFromDelta,
customFetch
} from "../util.js";
import {
BaseLlmApi,
CreateRerankResponse,
FimCreateParamsStreaming,
RerankCreateParams,
} from "./base.js";
import {
createResponsesStreamState,
fromResponsesChunk,
@ -30,12 +33,6 @@ import {
responseToChatCompletion,
toResponsesParams,
} from "./openaiResponses.js";
import {
BaseLlmApi,
CreateRerankResponse,
FimCreateParamsStreaming,
RerankCreateParams,
} from "./base.js";
export class OpenAIApi implements BaseLlmApi {
openai: OpenAI;
@ -53,6 +50,7 @@ export class OpenAIApi implements BaseLlmApi {
apiKey: config.apiKey ?? "",
baseURL: this.apiBase,
fetch: customFetch(config.requestOptions),
timeout: config?.requestOptions?.timeout || undefined
});
}