import type { IOpenAiModelConnection } from './index.js'; import { type TOpenAiChatGptModelListErrorCode } from './smartai.chatgpt.catalog.js'; import type { TOpenAiChatGptRequestOutcome } from './smartai.chatgpt.openai.js'; /** The OpenAI API every API-key request goes to; the AI SDK's versioned base URL. */ export declare const OPENAI_API_BASE_URL = "https://api.openai.com/v1"; export declare class OpenAiApiKeyAuthError extends Error { status?: number; requestOutcome?: TOpenAiChatGptRequestOutcome; constructor(message: string, options?: { status?: number; requestOutcome?: TOpenAiChatGptRequestOutcome; }); } /** An OpenAI API key, as the OpenAI platform issues it. */ export interface IOpenAiApiKeyAccess { readonly apiKey: string; } export interface IOpenAiApiKeyConnectionOptions extends IOpenAiApiKeyAccess { /** Optional underlying transport. Defaults to the current global fetch. */ readonly fetch?: typeof fetch; } /** Whether a request URL is under `OPENAI_API_BASE_URL` and carries no credentials. */ export declare function isOpenAiApiRequestUrl(urlArg: string): boolean; /** * The headers an API-key request authenticates with, over the request's own: the key replaces any credential the * request carried, and the headers of `strippedRequestHeaders` are removed. Shared by inference and the model list. */ export declare function createOpenAiApiKeyHeaders(accessArg: IOpenAiApiKeyAccess, headersArg?: HeadersInit): Headers; /** * An OpenAI API connection on an API key, for inference billed to the key's organization and project. * * Requests go only to `https://api.openai.com/v1`, without following redirects, with the key as the bearer and * without ChatGPT, organization or project headers. A provider 401 (key rejected) or 403 (key lacks the permission) * fails with an `OpenAiApiKeyAuthError` whose `status` names it, since a key does not renew; every other status is * the caller's. Without a custom * `fetch` the connection keeps the provider's prompt-cache timing confirmation. */ export declare const createOpenAiApiKeyConnection: (optionsArg: IOpenAiApiKeyConnectionOptions) => IOpenAiModelConnection; /** A model an API key may use, as `GET /v1/models` lists it. */ export interface IOpenAiApiKeyModel { providerId: 'openai'; modelId: string; /** When the model was created, in Unix seconds. */ created: number; /** The organization that owns the model, such as `openai` or `system`. */ ownedBy: string; /** The date the model shuts down, as the API states it, when it states one. */ shutdownDate?: string; } export declare class OpenAiApiModelListError extends Error { readonly code: TOpenAiChatGptModelListErrorCode; readonly status?: number; constructor(codeArg: TOpenAiChatGptModelListErrorCode, statusArg?: number); } export interface IOpenAiApiKeyModelListOptions { signal?: AbortSignal; /** Optional underlying transport. Defaults to the current global fetch. */ fetch?: typeof fetch; } /** * Reads the models an API key may use from `GET /v1/models`, one unpaged list, at most 1 MiB and 1000 models. A * refused key fails with an `OpenAiApiKeyAuthError` whose `status` is 401 (rejected) or 403 (no permission to read * models); an abort rejects with the signal's * reason; every other failure is an `OpenAiApiModelListError` whose `code` is `NETWORK_FAILED`, `HTTP_ERROR` (with * `status`) or `PROTOCOL_ERROR`. */ export declare function listOpenAiApiKeyModels(accessArg: IOpenAiApiKeyAccess, optionsArg?: IOpenAiApiKeyModelListOptions): Promise;