/** * BrowserOpenAIProvider — fetch-based OpenAI adapter for browsers. * * Pattern: Adapter (GoF). Zero peer dependencies — uses global `fetch`. * Role: Outer ring. Same `LLMProvider` contract as `OpenAIProvider` * but skips the `openai` SDK. For prototypes / playgrounds. * Production apps should proxy through a backend. * Emits: N/A. * * Also works with OpenAI-compatible endpoints (Ollama, Together, vLLM) * via `apiUrl`. * * ─── Limitations ──────────────────────────────────────────────────── * * • Multi-modal NOT supported. * • CORS depends on the endpoint — OpenAI requires the user-supplied * key in the Authorization header, which they'll do explicitly. */ import type { LLMCallHooks, LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js'; export interface BrowserOpenAIProviderOptions { /** API key. REQUIRED. */ readonly apiKey: string; /** Default model when `LLMRequest.model` is `'openai'`. */ readonly defaultModel?: string; /** Default max tokens. */ readonly defaultMaxTokens?: number; /** Override the API URL (Ollama, Together, vLLM, OpenAI proxies). */ readonly apiUrl?: string; /** Optional `Organization` header. */ readonly organization?: string; /** Auth header scheme. `'bearer'` (default) → `Authorization: Bearer `; * `'api-key'` → the `api-key` header (Azure OpenAI). */ readonly authScheme?: 'bearer' | 'api-key'; /** Treat the target as a **reasoning model** (o-series): omit `temperature` and send * the `developer` role. Standard o-series ids are auto-detected; set for arbitrary * Azure deployment names. */ readonly reasoning?: boolean; /** @internal Custom fetch implementation for tests. */ readonly _fetch?: typeof fetch; } export declare function browserOpenai(options: BrowserOpenAIProviderOptions): LLMProvider; export declare class BrowserOpenAIProvider implements LLMProvider { readonly name = "browser-openai"; private readonly inner; constructor(options: BrowserOpenAIProviderOptions); complete(req: LLMRequest, hooks?: LLMCallHooks): Promise; stream(req: LLMRequest, hooks?: LLMCallHooks): AsyncIterable; } export interface BrowserAzureOpenAIProviderOptions { /** Resource endpoint, e.g. `https://my-co.openai.azure.com` (or a same-origin * proxy path like `/azure` to sidestep CORS in dev). REQUIRED. */ readonly endpoint: string; /** API key (Azure `api-key`). REQUIRED. */ readonly apiKey: string; /** Azure API version, e.g. `2024-12-01-preview`. REQUIRED. */ readonly apiVersion: string; /** The DEPLOYMENT name (Azure's "model"), e.g. `gpt-4o-128k`. REQUIRED. */ readonly deployment: string; /** Default max tokens. */ readonly defaultMaxTokens?: number; /** Set when the Azure deployment is a **reasoning model** (o1/o3/o4-mini) — omits * `temperature` and sends the `developer` role. */ readonly reasoning?: boolean; /** @internal Custom fetch implementation for tests. */ readonly _fetch?: typeof fetch; } /** * Fetch-based **Azure OpenAI** provider for the browser/edge — no SDK, no Node. * * The browser can't use the Node `azureOpenai()` (it needs the `openai` SDK), so * use this in a browser "bring your own (company) key" flow. Builds the * deployment-scoped Azure URL + `api-key` header + `api-version`, and reuses all * of `browserOpenai()`'s body/streaming/tool logic. The request `model` is the * deployment; `'azure'` resolves to the configured `deployment`. * * **CORS:** an `*.openai.azure.com` resource may not allow direct browser calls; * if blocked, point `endpoint` at a same-origin proxy (e.g. a Vite `/azure` * proxy) or a backend. Same trade-off as `browserOpenai`. * * @example * import { browserAzureOpenai } from 'agentfootprint/llm-providers'; * const provider = browserAzureOpenai({ * endpoint: 'https://my-co.openai.azure.com', * apiKey: userKey, apiVersion: '2024-12-01-preview', deployment: 'gpt-4o-128k', * }); * // Agent.create({ provider, model: 'azure' }) */ export declare function browserAzureOpenai(options: BrowserAzureOpenAIProviderOptions): LLMProvider; export declare class BrowserAzureOpenAIProvider implements LLMProvider { readonly name = "browser-azure-openai"; private readonly inner; constructor(options: BrowserAzureOpenAIProviderOptions); complete(req: LLMRequest, hooks?: LLMCallHooks): Promise; stream(req: LLMRequest, hooks?: LLMCallHooks): AsyncIterable; } //# sourceMappingURL=BrowserOpenAIProvider.d.ts.map