import { APIClient } from "https://deno.land/x/openai@v4.69.0/core.ts";
Methods
private
buildHeaders(unnamed 0: { options: FinalRequestOptions; headers: Record<string, string | null | undefined>; contentLength: string | null | undefined; retryCount: number; }): Record<string, string>private
calculateContentLength(body: unknown): string | nullprivate
calculateDefaultRetryTimeoutMillis(retriesRemaining: number, maxRetries: number): numberprivate
getUserAgent(): stringprivate
makeRequest<Req>(optionsInput: PromiseOrValue<FinalRequestOptions<Req>>, retriesRemaining: number | null): Promise<APIResponseProps>private
methodRequest<Req, Rsp>(): APIPromise<Rsp>private
retryRequest(): Promise<APIResponseProps>private
shouldRetry(response: Response): booleanprotected
authHeaders(opts: FinalRequestOptions): Headersprotected
defaultHeaders(opts: FinalRequestOptions): HeadersOverride this to add your own default headers, for example:
{ ...super.defaultHeaders(), Authorization: 'Bearer 123', }
protected
defaultIdempotencyKey(): stringprotected
abstract
defaultQuery(): DefaultQuery | undefinedprotected
getRequestClient(): RequestClientprotected
makeStatusError(status: number | undefined,
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
protected
parseHeaders(headers: HeadersInit | null | undefined): Record<string, string>protected
prepareOptions(options: FinalRequestOptions): Promise<void>Used as a callback for mutating the given FinalRequestOptions
object.
protected
prepareRequest(request: RequestInit, unnamed 1: { url: string; options: FinalRequestOptions; }): Promise<void>Used as a callback for mutating the given RequestInit
object.
This is useful for cases where you want to add certain headers based off of
the request properties, e.g. method
or url
.
protected
stringifyQuery(query: Record<string, unknown>): stringprotected
validateHeaders(headers: Headers, customHeaders: Headers)Override this to add your own headers validation:
buildRequest<Req>(options: FinalRequestOptions<Req>, unnamed 1?: { retryCount?: number; }): { req: RequestInit; url: string; timeout: number; }
buildURL<Req>(path: string, query: Req | null | undefined): string
delete<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp>
fetchWithTimeout(): Promise<Response>
get<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp>
getAPIList<Item, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(): PagePromise<PageClass, Item>
patch<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp>
post<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp>
put<Req, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp>
request<Req, Rsp>(options: PromiseOrValue<FinalRequestOptions<Req>>, remainingRetries?: number | null): APIPromise<Rsp>
requestAPIList<Item = unknown, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(Page: new (...args: ConstructorParameters<AbstractPage>) => PageClass, options: FinalRequestOptions): PagePromise<PageClass, Item>