Construct a new OpenAiAdapter instance.
String API key or complete OpenAiAdapterConfig object.
Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Internal helper to build chat messages array.
Optionaloptions: OpenAiGenerateOptionsProtected_Strips optional markdown JSON codeblock fences from a response string.
Raw text output from model.
Cleaned JSON text.
Protected_Parse an individual Server-Sent Events line and extract delta content.
Raw SSE line string.
Text delta string if available, or null.
Protected_Protected_Internal helper to make an authorized POST request to /chat/completions.
Optionalheaders: Record<string, string>OptionaltimeoutMs: numberGenerates structured data strictly conforming to a JSON schema.
Context or instructions.
Target JSON schema or contract.
Optionaloptions: OpenAiGenerateOptionsGeneration options.
Parsed JSON object conforming to type T.
Sends a prompt to the OpenAI-compatible chat completions API and retrieves the response string.
Text instruction or prompt query.
Optionaloptions: OpenAiGenerateOptionsExecution options (model, messages, temperature, maxTokens).
Generated text from model.
Sends a prompt and returns an async iterable stream of generated text tokens.
Text instruction or prompt query.
Optionaloptions: OpenAiGenerateOptionsExecution options.
Async iterable yielding chunks of text.
Initialize the adapter and validate setup.
StaticforPreset for DeepSeek API endpoint (V3 & R1).
DeepSeek API key.
Default model (defaults to 'deepseek-chat').
StaticforPreset for local LM Studio instance.
LM Studio endpoint URL (defaults to 'http://localhost:1234/v1').
Default model identifier.
StaticforPreset for local or on-premise Ollama instance.
Ollama endpoint URL (defaults to 'http://localhost:11434/v1').
Default model (defaults to 'llama3.2').
StaticforPreset for OpenAI official endpoint.
OpenAI API key.
Default model (defaults to 'gpt-4o').
StaticforPreset for OpenRouter aggregator endpoint.
OpenRouter API key.
Default model (defaults to 'openrouter/auto').
StaticforPreset for Alibaba Qwen API endpoint (DashScope OpenAI compatible).
DashScope API key.
Default model (defaults to 'qwen-plus').
AI Adapter implementation for OpenAI and OpenAI-compatible models (DeepSeek, Qwen, Mistral, Ollama). Built with native fetch and Web Streams without external third-party SDK dependencies.