rulvar API reference / @rulvar/openai
@rulvar/openai
Classes
| Class | Description |
|---|---|
| OpenAiIdMap | Bijective canonical-to-wire (call_*) id map. |
Interfaces
| Interface | Description |
|---|---|
| OpenAiAdapterOptions | - |
| OpenAiClientLike | The client sub-surface the adapter consumes; injectable for tests. |
| OpenAiCompatibleConfig | - |
| OpenAiModelInfo | - |
Type Aliases
| Type Alias | Description |
|---|---|
| ResponsesStreamEvent | Raw Responses SSE events, structurally typed. |
Variables
| Variable | Description |
|---|---|
| CONSERVATIVE_COMPATIBLE_CAPS | Gateways cannot be introspected reliably: when caps are not supplied the factory assumes the most conservative capability set. Callers SHOULD supply caps for anything beyond it; the window and output floors here are deliberately small so an unprobed endpoint is never overcommitted. Absent pricing is legitimate for local models: they surface as unpriced in CostReport. |
| OPENAI_MODELS | Static seed table of the current model set. |
Functions
| Function | Description |
|---|---|
| buildChatCompletionsParams | The Chat Completions degraded path: delta-patched chunk assembly instead of typed SSE, nested function tools with explicit strict where supported, response_format instead of text.format, no reasoning item replay. Selected by caps (api: 'chat'), visible in events, never silent. |
| buildResponsesParams | Builds Responses API params. Manual item replay ONLY: store: false plus include reasoning.encrypted_content; previous_response_id and the Conversations API place state server-side, break replay identity, and are REJECTED as a typed ConfigError. Role 'system' messages project into top-level instructions on every request. |
| mapChatCompletionsStream | Delta-patched chunk assembly for the degraded path. |
| mapOpenAiEffort | Canonical-to-wire effort: low through xhigh pass through; canonical max downmaps to xhigh (documented lossy; recorded in providerMetadata); provider 'none' is reachable only via providerOptions.openai.reasoningEffort. |
| mapResponsesStream | Maps the typed Responses SSE stream to ChatEvents. Canonical parts come from the typed output array, never the output_text aggregate. Raw output items ride finish.providerMetadata.openai.outputItems so the runtime can retain reasoning items as provider-raw parts. |
| normalizeOpenAiUsage | Normalizes Responses usage: input_tokens already includes cached reads. |
| openai | @rulvar/openai: the first-class OpenAI Responses API adapter with the Chat Completions degraded path, plus the openaiCompatible factory for Ollama, vLLM, and gateways. |
| openaiCompatible | Creates a Chat Completions dialect adapter for a compatible endpoint. |
| openAiErrorToWire | Projects SDK/API errors into the retryable WireError vocabulary. |
| openAiModelInfo | Unknown OpenAI models are assumed current-generation Responses models. |