---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/openai_chat_completions/adapter/classes/OpenAIChatCompletionsAdapter.md
description: >-
  Opinionated cross-environment LLM adapter for the OpenAI Chat Completions wire
  shape.
---

# Class: OpenAIChatCompletionsAdapter

Defined in: [batteries/llm/openai\_chat\_completions/adapter.ts:284](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/llm/openai_chat_completions/adapter.ts#L284)

Opinionated cross-environment LLM adapter for the OpenAI Chat Completions wire shape.

## Remarks

Construction validates options eagerly via [@nhtio/adk/batteries!validateOptions](../../validation/functions/validateOptions.md) and throws
[@nhtio/adk/batteries!E\_INVALID\_OPENAI\_CHAT\_COMPLETIONS\_OPTIONS](../../exceptions/variables/E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS.md) on failure — config bugs fail loud, not at
dispatch time. The returned instance is reusable: call [OpenAIChatCompletionsAdapter.executor](#executor)
once per `DispatchRunner` configuration to obtain an [@nhtio/adk!DispatchExecutorFn](../../../../../dispatch_runner/type-aliases/DispatchExecutorFn.md) bound to the
baseline plus optional executor-scope overrides.

Per-iteration overrides live on the active [@nhtio/adk!DispatchContext](../../../../../types/interfaces/DispatchContext.md)'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

```ts
new OpenAIChatCompletionsAdapter(options: unknown): OpenAIChatCompletionsAdapter;
```

Defined in: [batteries/llm/openai\_chat\_completions/adapter.ts:300](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/llm/openai_chat_completions/adapter.ts#L300)

#### 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](../../exceptions/variables/E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS.md) when `options` does not satisfy
[@nhtio/adk/batteries!openAIChatCompletionsOptionsSchema](../../validation/variables/openAIChatCompletionsOptionsSchema.md).

## Properties

| Property                                    | Modifier   | Type                      | Description                                                                                                                                                                                                                   | Defined in                                                                                                                                                        |
| ------------------------------------------- | ---------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `STASH_KEY` | `readonly` | `"openaiChatCompletions"` | Customary key for per-iteration overrides on `ctx.stash`. The adapter reads `ctx.stash.get(OpenAIChatCompletionsAdapter.STASH_KEY, {})` at the start of every iteration and merges the value into the resolved options shape. | [batteries/llm/openai\_chat\_completions/adapter.ts:290](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/llm/openai_chat_completions/adapter.ts#L290) |

## Methods

### executor()

```ts
executor(overrides?: Partial<OpenAIChatCompletionsAdapterOptions>): DispatchExecutorFn;
```

Defined in: [batteries/llm/openai\_chat\_completions/adapter.ts:313](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/llm/openai_chat_completions/adapter.ts#L313)

Returns an [@nhtio/adk!DispatchExecutorFn](../../../../../dispatch_runner/type-aliases/DispatchExecutorFn.md) 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`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)<[`OpenAIChatCompletionsAdapterOptions`](../../types/interfaces/OpenAIChatCompletionsAdapterOptions.md)> | Optional executor-scope overrides. Higher precedence than the baseline, lower precedence than `ctx.stash[STASH_KEY]`. |

#### Returns

[`DispatchExecutorFn`](../../../../../dispatch_runner/type-aliases/DispatchExecutorFn.md)

An [@nhtio/adk!DispatchExecutorFn](../../../../../dispatch_runner/type-aliases/DispatchExecutorFn.md) suitable for `DispatchRunner`.

***

### isOpenAIChatCompletionsAdapter()

```ts
static isOpenAIChatCompletionsAdapter(value: unknown): value is OpenAIChatCompletionsAdapter;
```

Defined in: [batteries/llm/openai\_chat\_completions/adapter.ts:1208](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/llm/openai_chat_completions/adapter.ts#L1208)

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.
