/** * OpenAI API Client Module * * Handles communication with the OpenAI Chat Completions API and Image Generation API. * Uses the standard OpenAI API format (also compatible with many other providers). */ import type { LLMStreamChunk } from '../../llm_api/types.js'; /** * OpenAI message role */ export interface OpenAIMessage { role: 'user' | 'assistant' | 'system'; content: string | OpenAIContentItem[]; } /** * OpenAI content item for multimodal messages */ export type OpenAIContentItem = { type: 'text'; text: string; } | { type: 'image_url'; image_url: { url: string; }; }; /** * OpenAI generation configuration parameters */ export interface OpenAIGenerationConfig { /** Controls randomness in output (0.0-2.0). Lower = more deterministic */ temperature?: number; /** Nucleus sampling probability (0.0-1.0) */ top_p?: number; /** Maximum number of tokens in the response */ max_tokens?: number; /** Penalizes new tokens based on whether they appear in the text so far */ frequency_penalty?: number; /** Penalizes new tokens based on whether they appear in the text at all */ presence_penalty?: number; } /** * Call the OpenAI Chat Completions API (non-streaming) * @param opts - API call options * @returns Raw API response and HTTP status code */ export declare function call_openai_api(opts: { api_key: string; api_url: string; model: string; messages: OpenAIMessage[]; generation_config?: OpenAIGenerationConfig; }): Promise<{ raw: Record; status: number; }>; /** * Call the OpenAI Image Generation API * @param opts - API call options * @returns Raw API response and HTTP status code */ export declare function call_openai_image_api(opts: { api_key: string; api_url_image: string; model: string; prompt: string; }): Promise<{ raw: Record; status: number; }>; /** * Call the OpenAI Embeddings API * @param opts - API call options * @returns Raw API response and HTTP status code */ export declare function call_openai_embed_api(opts: { api_key: string; api_url_embed: string; model: string; input: string | string[]; }): Promise<{ raw: Record; status: number; }>; /** * Call the OpenAI Chat Completions API with streaming enabled. * Yields LLMStreamChunk objects as SSE events arrive. * * @param opts - API call options * @yields LLMStreamChunk objects with text deltas or done/error signals */ export declare function call_openai_api_stream(opts: { api_key: string; api_url: string; model: string; messages: OpenAIMessage[]; generation_config?: OpenAIGenerationConfig; }): AsyncGenerator; //# sourceMappingURL=openai_client.d.ts.map