// Chat Completion API interface ChatCompletionRequest { messages: Message[]; model: string; frequency_penalty?: number | null; presence_penalty?: number | null; logit_bias?: { [token: string]: number }; logprobs?: boolean | null; top_logprobs?: number | null; max_tokens?: number | null; n?: number | null; stop?: string | string[] | null; stream?: boolean | null; stream_options?: StreamOptions | null; temperature?: number | null; top_p?: number | null; tools?: Tool[]; tool_choice?: 'none' | 'auto' | 'required' | { type: 'function'; function: { name: string } } | null; parallel_tool_calls?: boolean; user?: string; service_tier?: 'auto' | 'default' | null; response_format?: ResponseFormat | null; seed?: number | null; } interface Message { role: 'user' | 'system' | 'assistant'; content: string; } interface StreamOptions { include_usage: boolean | null; } interface Tool { type: 'function'; function: { name: string }; } interface ResponseFormat { type: 'json_object'; } // Embedding API interface EmbeddingRequest { input: string | string[] | TokenArray[]; model: string; encoding_format?: 'float' | 'base64'; dimensions?: number; user?: string; } // If needed, define TokenArray for more complex input types involving tokens type TokenArray = number[]; // Image API interface CreateImageRequest { prompt: string; // Required. Text description of the desired image(s). model?: 'dall-e-2' | 'dall-e-3'; // Optional. Defaults to 'dall-e-2'. n?: number | null; // Optional. Number of images to generate. Defaults to 1. quality?: 'standard' | 'hd'; // Optional. Quality of the generated image, 'hd' only for dall-e-3. Defaults to standard response_format?: 'url' | 'b64_json' | null; // Optional. Format in which images are returned. Defaults to 'url'. size?: '256x256' | '512x512' | '1024x1024' | '1792x1024' | '1024x1792'; // Optional. Size of the generated images. Default: 1024x1024 style?: 'vivid' | 'natural' | null; // Optional. Style of the generated images, only for dall-e-3. Defaults to vivid user?: string; // Optional. Unique identifier for your end-user. } // Image Edit API interface ImageEditRequest { image: File; // Must be a valid PNG file, less than 4MB, and square prompt: string; // Required, max 1000 characters mask?: File; // Optional, PNG file, < 4MB, same dimensions as `image` model?: 'dall-e-2'; // Optional, default 'dall-e-2' n?: number; // Optional, defaults to 1, must be between 1 and 10 size?: '256x256' | '512x512' | '1024x1024'; // Optional, default '1024x1024' response_format?: 'url' | 'b64_json'; // Optional, default 'url' user?: string; // Optional, a unique user identifier } interface ImageObject { id: string; // Identifier for the generated image url?: string; // URL of the generated image, valid for 60 minutes b64_json?: string; // Base64 encoded JSON of the image, if requested } interface ImageResponse { images: ImageObject[]; // List of generated image objects } // Speech API type SpeechModel = 'tts-1' | 'tts-1-hd'; type VoiceType = 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'; type AudioFormat = 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'; interface CreateSpeechRequest { model: SpeechModel; input: string; voice: VoiceType; response_format?: AudioFormat; speed?: number; } // Transcription API interface CreateTranscriptionRequest { input: Blob; // Required, the audio file to transcribe model: 'whisper-1'; // Currently only 'whisper-1' is supported language?: string; // ISO-639-1 format, optional prompt?: string; // Optional guiding text responseFormat?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt'; // Optional, defaults to 'json' temperature?: number; // Optional, between 0 and 1, defaults to 0 timestampGranularities?: Array<'word' | 'segment'>; // Optional, defaults to ['segment'] } export type { ChatCompletionRequest, EmbeddingRequest, CreateImageRequest, ImageEditRequest, ImageResponse, CreateSpeechRequest, CreateTranscriptionRequest };