/** * Drop-in replacement for the OpenAI Node SDK. * Swap your import to get permit-first governance transparently. * * BEFORE: import OpenAI from "openai"; * AFTER: import { OpenAI } from "keel-sdk/providers/openai"; * * The wrapper does NOT depend on the `openai` npm package. * It talks to Keel's proxy endpoint, which handles the provider call. */ export interface ChatCompletionMessageParam { role: "system" | "user" | "assistant" | "function" | "tool"; content: string | null; name?: string; function_call?: unknown; tool_calls?: unknown[]; tool_call_id?: string; } export interface ChatCompletionCreateParams { model: string; messages: ChatCompletionMessageParam[]; max_tokens?: number | null; temperature?: number | null; top_p?: number | null; n?: number | null; stream?: boolean | null; stop?: string | string[] | null; presence_penalty?: number | null; frequency_penalty?: number | null; logit_bias?: Record | null; user?: string; response_format?: { type: string; } | null; seed?: number | null; tools?: unknown[]; tool_choice?: unknown; [key: string]: unknown; } export interface ChatCompletionMessage { role: "assistant"; content: string | null; tool_calls?: unknown[]; function_call?: unknown; } export interface ChatCompletionChoice { index: number; message: ChatCompletionMessage; finish_reason: string | null; } export interface CompletionUsage { prompt_tokens: number; completion_tokens: number; total_tokens: number; } export interface ChatCompletion { id: string; object: "chat.completion"; created: number; model: string; choices: ChatCompletionChoice[]; usage?: CompletionUsage; system_fingerprint?: string | null; } /** A single chunk in a streamed chat completion. */ export interface ChatCompletionChunk { id: string; object: "chat.completion.chunk"; created: number; model: string; choices: Array<{ index: number; delta: { role?: string; content?: string | null; tool_calls?: unknown[]; }; finish_reason: string | null; }>; usage?: CompletionUsage | null; } export interface OpenAIConfig { /** Ignored -- Keel manages provider keys. Accepted for API compatibility. */ apiKey?: string; /** Keel API base URL. Defaults to KEEL_BASE_URL env var. */ keelBaseUrl?: string; /** Keel API key. Defaults to KEEL_API_KEY env var. */ keelApiKey?: string; /** Keel project ID. Defaults to KEEL_PROJECT_ID env var. */ keelProjectId?: string; /** Subject for permit requests. */ keelSubject?: { type: string; id: string; }; /** Request timeout in milliseconds. */ timeout?: number; /** Maximum retries on transient errors. */ maxRetries?: number; } export declare class OpenAI { readonly chat: { completions: { create: (params: ChatCompletionCreateParams) => Promise>; }; }; private readonly keel; private readonly projectId; private readonly subject; constructor(config?: OpenAIConfig); private _create; private _createSync; private _createStream; }