Class: OpenAIChatCompletionsAdapter
Opinionated cross-environment LLM adapter for the OpenAI Chat Completions wire shape.
Remarks
Construction validates options eagerly via @nhtio/adk/batteries!validateOptions and throws @nhtio/adk/batteries!E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS on failure — config bugs fail loud, not at dispatch time. The returned instance is reusable: call OpenAIChatCompletionsAdapter.executor once per DispatchRunner configuration to obtain an @nhtio/adk!DispatchExecutorFn bound to the baseline plus optional executor-scope overrides.
Per-iteration overrides live on the active @nhtio/adk!DispatchContext's stash.openaiChatCompletions slot and take highest precedence — they merge into the executor-scope shape on every iteration. headers, helpers, and retry merge key-by-key across all three layers; every other field is replaced wholesale at the highest layer that sets it.
Constructors
Constructor
new OpenAIChatCompletionsAdapter(options: unknown): OpenAIChatCompletionsAdapter;Parameters
| Parameter | Type | Description |
|---|---|---|
options | unknown | Constructor-baseline options. Re-validated on every iteration after per-dispatch and per-iteration overrides are layered in. |
Returns
OpenAIChatCompletionsAdapter
Throws
@nhtio/adk/batteries!E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS when options does not satisfy @nhtio/adk/batteries!openAIChatCompletionsOptionsSchema.
Properties
Methods
executor()
executor(overrides?: Partial<OpenAIChatCompletionsAdapterOptions>): DispatchExecutorFn;Returns an @nhtio/adk!DispatchExecutorFn bound to this adapter's baseline plus optional executor-scope overrides. The returned function is reusable across iterations — every iteration re-merges with ctx.stash[STASH_KEY] and re-validates the result.
Parameters
| Parameter | Type | Description |
|---|---|---|
overrides? | Partial<OpenAIChatCompletionsAdapterOptions> | Optional executor-scope overrides. Higher precedence than the baseline, lower precedence than ctx.stash[STASH_KEY]. |
Returns
An @nhtio/adk!DispatchExecutorFn suitable for DispatchRunner.
isOpenAIChatCompletionsAdapter()
static isOpenAIChatCompletionsAdapter(value: unknown): value is OpenAIChatCompletionsAdapter;Returns true when value is an OpenAIChatCompletionsAdapter instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to test. |
Returns
value is OpenAIChatCompletionsAdapter
true when value is an OpenAIChatCompletionsAdapter instance.