/** * OpenAI LLM Provider * * Implements LLMProvider interface for OpenAI models (GPT-4o, GPT-4o-mini, etc.) * Extends OpenAICompatibleProvider for shared functionality. * * @example * ```typescript * const provider = createOpenAIProvider({ * model: 'gpt-4o', * apiKey: process.env.OPENAI_API_KEY * }); * ``` * * @remarks * - Requires valid OpenAI API key * - Default model is gpt-4o * - Extended thinking is not supported (Claude-specific feature) */ import type { ChatOptions } from './types.js'; import { ProviderError } from '../errors.js'; import { OpenAICompatibleProvider } from './openai-compatible.js'; /** * Configuration for OpenAIProvider */ export interface OpenAIProviderConfig { /** OpenAI API key (falls back to OPENAI_API_KEY env var) */ apiKey?: string; /** Base URL for OpenAI API (default: https://api.openai.com) */ baseUrl?: string; /** Default model to use (default: gpt-4o) */ model?: string; /** Default max tokens (default: 4096) */ maxTokens?: number; /** Request timeout in milliseconds (default: 120000) */ timeout?: number; /** OpenAI organization ID (optional) */ organization?: string; /** Optional token estimator (e.g., tiktoken) for debug payload */ estimateTokens?: (text: string) => number; } /** * OpenAI LLM Provider * * Provides streaming chat completion using OpenAI models. * Supports GPT-4o, GPT-4o-mini, and other compatible models. */ export declare class OpenAIProvider extends OpenAICompatibleProvider { readonly name = "openai"; private readonly apiKey; private readonly organization?; constructor(config?: OpenAIProviderConfig); /** * OpenAI authentication with Bearer token */ protected getAuthHeaders(): Record; /** * OpenAI chat completions endpoint */ protected getEndpointPath(): string; /** * OpenAI uses standard body format (no provider-specific extensions needed) */ protected buildProviderSpecificBody(_options?: ChatOptions): Record; /** * Map HTTP errors with OpenAI-specific messages */ protected mapHttpError(status: number, body: string, _model: string): ProviderError; /** * Map connection errors with OpenAI-specific messages */ protected mapConnectionError(_error: Error): ProviderError; } /** * Create an OpenAI provider instance * * @example * ```typescript * // Using environment variable (OPENAI_API_KEY) * const provider = createOpenAIProvider(); * * // With explicit API key * const provider = createOpenAIProvider({ apiKey: 'sk-...' }); * * // With custom model * const provider = createOpenAIProvider({ model: 'gpt-4o-mini' }); * * // With organization * const provider = createOpenAIProvider({ * apiKey: 'sk-...', * organization: 'org-...' * }); * ``` */ export declare function createOpenAIProvider(config?: OpenAIProviderConfig): OpenAIProvider;