Interface: OpenAIChatCompletionsAdapterOptions
Defined in: src/batteries/llm/openai_chat_completions/types.ts:486
Configuration options for the OpenAI Chat Completions adapter.
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
apiKey? | string | undefined | API key for authenticating requests to the OpenAI-compatible service. | src/batteries/llm/openai_chat_completions/types.ts:489 |
audio? | { format: "wav" | "mp3" | "flac" | "opus" | "pcm16"; voice: string; } | undefined | Parameters for audio output if requested. | src/batteries/llm/openai_chat_completions/types.ts:614 |
audio.format | "wav" | "mp3" | "flac" | "opus" | "pcm16" | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:614 |
audio.voice | string | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:614 |
autoAck? | boolean | false | Whether the executor should call ctx.ack() itself when a generation completes with no tool calls (a terminal text answer). Remarks ack() is terminal and one-shot: once called, the dispatch loop exits after the current iteration. When the executor acks automatically, it seizes turn-completion control from the implementor — a dispatchOutputPipeline quality gate can never run, because the signal is already set before the output pipeline executes. This option therefore defaults to false (opt-in). With autoAck: false, a tool-call-free response leaves the context unsignalled and the executor returns; the implementor's output pipeline (or a later iteration) is responsible for calling ctx.ack() / ctx.nack(). This is the seam that makes output-side quality gates (citation enforcement, schema validation, regenerate-on-reject) possible. Set autoAck: true to restore single-shot behavior: the executor acks the moment a tool-call-free answer finishes, terminating the turn without giving the output pipeline a vote. The tool-call path is unaffected by this flag — it always withholds ack so the runner can iterate and execute the calls. Error paths always nack regardless of this flag. | src/batteries/llm/openai_chat_completions/types.ts:608 |
baseURL? | string | undefined | Base URL for the OpenAI-compatible API endpoint. | src/batteries/llm/openai_chat_completions/types.ts:491 |
bucketOrder? | ChatCompletionsBucketOrder | undefined | Determines order of memory and retrievable buckets in history assembly. | src/batteries/llm/openai_chat_completions/types.ts:505 |
contextWindow? | number | undefined | Size of the model's token context window. | src/batteries/llm/openai_chat_completions/types.ts:507 |
fetch? | { (input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined | Custom fetch implementation to use for HTTP requests. | src/batteries/llm/openai_chat_completions/types.ts:503 |
forgeToolsFilter? | (forged: ToolRegistry, ctx: DispatchContext) => ToolRegistry | undefined | OPTIONAL hook to SHAPE the artifact-query tools forged from prior-turn SpooledArtifact results, before they merge into the visible tool set. Receives the merged forged registry + dispatch context; returns a (possibly narrowed) registry, applied BEFORE the merge with ctx.tools. Lets the assembler keep only the core readers on a tight window (the rest reachable via tool_catalog/call_a_tool). Default absent = identity (all forged tools) = backward-compatible. The battery stays budget-agnostic (per the CONTRIBUTING size-threshold rule) — it applies the supplied filter without measuring context; budget logic lives in the caller's filter. | src/batteries/llm/openai_chat_completions/types.ts:763 |
frequency_penalty? | number | undefined | Frequency penalty wire field to discourage repeating words. | src/batteries/llm/openai_chat_completions/types.ts:616 |
function_call? | | "auto" | "none" | { name: string; } | undefined | Deprecated wire field to control which function is called. | src/batteries/llm/openai_chat_completions/types.ts:618 |
functions? | { description?: string; name: string; parameters?: JsonSchema; }[] | undefined | Deprecated list of functions available to the model. | src/batteries/llm/openai_chat_completions/types.ts:620 |
headers? | Record<string, string> | undefined | Extra HTTP headers to include with each request. | src/batteries/llm/openai_chat_completions/types.ts:493 |
helpers? | Partial<ChatCompletionsHelpers> | undefined | Optional overrides for OpenAI chat completions helpers. | src/batteries/llm/openai_chat_completions/types.ts:536 |
localToolCallParser? | | ToolCallParserName | ToolCallParserFn | undefined | OPTIONAL fallback parser for tool calls the provider did NOT return structurally. Remarks The Chat Completions message.tool_calls array is authoritative: when the provider returns tool calls, those are used and this option is never consulted. But some models — especially small local ones served through an OpenAI-compatible endpoint — emit a tool call in a surface form the endpoint does not lift into tool_calls: <call:name{…}, a fenced ```json ```` block, <tool_code…>, or bare name\nkey: value. Those land as plain assistant contentwithtool_callsempty, silently dropping the call. This is a cross-model, cross-weight reality, not a single-endpoint quirk. Set this to a parser family name (e.g.'gemma'), 'auto'(try every bundled parser in priority order), or a custom ToolCallParserFn to recover such calls fromcontentONLY when the provider returned none. Recovered calls execute exactly like native ones. Default absent = disabled = today's native-only behaviour (fully backward-compatible). Mirrors the on-device batteries'toolCallParser, which parse from text unconditionally because those runtimes never return structured calls. | src/batteries/llm/openai_chat_completions/types.ts:751 |
logit_bias? | Record<string, number> | undefined | Bias logits to control token generation likelihood. | src/batteries/llm/openai_chat_completions/types.ts:622 |
logprobs? | boolean | undefined | Request log probabilities for generated tokens. | src/batteries/llm/openai_chat_completions/types.ts:624 |
max_completion_tokens? | number | undefined | Hard limit on token count for model reasoning/completion. | src/batteries/llm/openai_chat_completions/types.ts:626 |
max_tokens? | number | undefined | Maximum number of generated tokens. | src/batteries/llm/openai_chat_completions/types.ts:628 |
metadata? | Record<string, string> | undefined | Metadata key-value pairs forwarded to the provider. | src/batteries/llm/openai_chat_completions/types.ts:630 |
modalities? | ("text" | "audio")[] | undefined | Desired modalities for model output, such as text and audio. | src/batteries/llm/openai_chat_completions/types.ts:632 |
model | string | undefined | Name of the model to use for completion. | src/batteries/llm/openai_chat_completions/types.ts:612 |
n? | number | undefined | Number of completions to generate for each request. | src/batteries/llm/openai_chat_completions/types.ts:634 |
onPromptAssembled? | PromptAssembledObserverFn | undefined | Observe the fully-assembled request this battery is about to POST TO the provider — fired once per terminal generation, the instant the body is built and BEFORE the fetch, with the wire messages, tools, and the complete requestBody. The mirror of onRawGeneration. Purely observational (return value ignored, errors swallowed). Default absent. An ADK-control key — stripped from the wire request body, never sent to the provider. The request is handed back AS-IS — no redaction — so treat it as potentially sensitive (it may contain auth material that rode the body) if you persist it. See PromptAssembledObserverFn. | src/batteries/llm/openai_chat_completions/types.ts:732 |
onRawGeneration? | RawGenerationObserverFn | undefined | Observe the model's RAW response for each completed generation — fired once per terminal generation, after the provider's reply is parsed but before the result is persisted, with the returned assistant content (rawText), the residual cleanedText, and the extracted reasoning / toolCalls. Purely observational (return value ignored, errors swallowed). Default absent. An ADK-control key — stripped from the wire request body, never sent to the provider. See RawGenerationObserverFn. | src/batteries/llm/openai_chat_completions/types.ts:722 |
parallel_tool_calls? | boolean | undefined | Allow the model to emit multiple tool calls in one turn. | src/batteries/llm/openai_chat_completions/types.ts:636 |
prediction? | { content: | string | { text: string; type: "text"; }[]; type: "content"; } | undefined | Prediction helper to accelerate latency of known content. | src/batteries/llm/openai_chat_completions/types.ts:638 |
prediction.content | | string | { text: string; type: "text"; }[] | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:640 |
prediction.type | "content" | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:639 |
presence_penalty? | number | undefined | Presence penalty wire field to encourage new topics. | src/batteries/llm/openai_chat_completions/types.ts:643 |
prompt_cache_key? | string | undefined | Vendor cache key for caching system prompts. | src/batteries/llm/openai_chat_completions/types.ts:645 |
prompt_cache_retention? | "in_memory" | "24h" | undefined | Cache retention strategy for cached system prompts. | src/batteries/llm/openai_chat_completions/types.ts:647 |
reasoning_effort? | "none" | "low" | "high" | "minimal" | "medium" | undefined | Target reasoning depth/effort for reasoning models. | src/batteries/llm/openai_chat_completions/types.ts:649 |
reasoningFieldPrecedence? | ReasoningFieldPrecedence | ['reasoning', 'reasoning_content'] | Ordered precedence of the wire fields the adapter reads for model reasoning/thinking output. Remarks Reasoning is not part of OpenAI's official Chat Completions spec, so OpenAI-compatible providers disagree on the field name: Ollama's /v1 and current vLLM emit reasoning, while legacy vLLM (≤0.8) and the DeepSeek API emit reasoning_content. The adapter reads every field in this list that is present on the response. Precedence governs two things. When more than one listed field is present with identical content (or only one is present), the adapter emits a single thought attributed to the highest-precedence field. When listed fields are present with divergent content, each surfaces as its own thought (ordered by precedence) rather than silently dropping one — a thought stream is the wrong place to lose data. | src/batteries/llm/openai_chat_completions/types.ts:534 |
replayCompatibility? | readonly string[] | undefined | List of replay labels supported by the assistant. | src/batteries/llm/openai_chat_completions/types.ts:515 |
requestTimeoutMs? | number | undefined | Request timeout in milliseconds for API calls. | src/batteries/llm/openai_chat_completions/types.ts:499 |
response_format? | | { type: "text"; } | { type: "json_object"; } | { json_schema: { description?: string; name: string; schema: JsonSchema; strict?: boolean; }; type: "json_schema"; } | undefined | Enforces a specific output format, e.g. JSON schema. | src/batteries/llm/openai_chat_completions/types.ts:651 |
retry? | ChatCompletionsRetryConfig | undefined | Configures request retry behavior. | src/batteries/llm/openai_chat_completions/types.ts:501 |
safety_identifier? | string | undefined | Unique safety system identifier or configuration ID. | src/batteries/llm/openai_chat_completions/types.ts:664 |
seed? | number | undefined | Deterministic random seed for generation. | src/batteries/llm/openai_chat_completions/types.ts:666 |
selfIdentity? | string | undefined | Unique identity label for the assistant instance. | src/batteries/llm/openai_chat_completions/types.ts:509 |
service_tier? | "default" | "auto" | "flex" | "scale" | "priority" | undefined | Service reliability tier for processing the request. | src/batteries/llm/openai_chat_completions/types.ts:668 |
spoolStore? | SpoolStore | a new InMemorySpoolStore per dispatch | Backing store for string / Uint8Array tool returns. Tool output bytes are written under the tool call's id; the resulting @nhtio/adk!SpooledArtifact (or the tool's configured subclass) is the model-visible handle for the rest of the turn. Remarks Defaults to a fresh, ephemeral per-dispatch @nhtio/adk/batteries/storage/in_memory!InMemorySpoolStore. Inject an @nhtio/adk/batteries/storage/opfs!OpfsSpoolStore or a Flydrive-backed store to persist artifacts to durable storage (and to stream large/binary tool output to disk rather than buffering it in memory). Lifetime / namespacing: the default store is per-dispatch, so tool-call ids only need to be unique within a dispatch. An injected durable store persists across turns and dispatches, so the tool-call ids used as keys must be globally unique for that store (or the store must apply its own keyPrefix); the adapter does not namespace keys for you, and it does not delete entries — lifetime and cleanup of an injected store are the consumer's responsibility. | src/batteries/llm/openai_chat_completions/types.ts:557 |
stop? | string | string[] | undefined | Custom stop sequence strings. | src/batteries/llm/openai_chat_completions/types.ts:670 |
store? | boolean | undefined | Request the provider to store the completed trace. | src/batteries/llm/openai_chat_completions/types.ts:672 |
stream? | boolean | undefined | Whether to stream the completion response chunk by chunk. | src/batteries/llm/openai_chat_completions/types.ts:495 |
stream_options? | { include_obfuscation?: boolean; include_usage?: boolean; } | undefined | Configuration options for response streaming. | src/batteries/llm/openai_chat_completions/types.ts:674 |
stream_options.include_obfuscation? | boolean | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:674 |
stream_options.include_usage? | boolean | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:674 |
streamIdleTimeoutMs? | number | undefined | Idle timeout in milliseconds for the stream before aborting. | src/batteries/llm/openai_chat_completions/types.ts:497 |
strictToolChoice? | boolean | false | When tool_choice (or the allowed_tools variant) forces the model onto a specific tool name, and that name resolves to an ephemeral, forged artifact-query tool (one produced by <Subclass>.forgeTools(ctx) — i.e. tool.ephemeral === true), this flag controls how the adapter reacts: - false (default): emit a single helpers.log.warn({ kind: 'tool-choice-forged-artifact', ... }) record and continue. Forging an artifact-query tool by name is almost always a misconfiguration — the tool may not exist in the next iteration once the artifact ages out — but the call still goes through. - true: hard-fail with E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS. Use this in production deployments where forcing a forged tool indicates a real bug. | src/batteries/llm/openai_chat_completions/types.ts:573 |
temperature? | number | undefined | Sampling temperature control. | src/batteries/llm/openai_chat_completions/types.ts:676 |
thoughtSurfacing? | "all" | "all-self" | "latest-self" | undefined | Determines which thoughts are surfaced back to the model. | src/batteries/llm/openai_chat_completions/types.ts:511 |
tokenEncoding? | | TokenEncodingId | null | undefined | Tokenizer encoding configuration for token counting. | src/batteries/llm/openai_chat_completions/types.ts:513 |
tool_choice? | | "required" | "auto" | "none" | { function: { name: string; }; type: "function"; } | { custom: { name: string; }; type: "custom"; } | { allowed_tools: { mode: "required" | "auto"; tools: ( | { function: { name: string; }; type: "function"; } | { custom: { name: string; }; type: "custom"; })[]; }; type: "allowed_tools"; } | undefined | Enforce or disable tool execution selection. | src/batteries/llm/openai_chat_completions/types.ts:678 |
toolCallIdFilter? | ToolCallIdFilterFn | undefined | Optional ingress hook for adapting provider tool-call ids; absent preserves the vendor id. | src/batteries/llm/openai_chat_completions/types.ts:753 |
top_logprobs? | number | undefined | Top log probability tokens limit. | src/batteries/llm/openai_chat_completions/types.ts:695 |
top_p? | number | undefined | Nucleus sampling probability threshold. | src/batteries/llm/openai_chat_completions/types.ts:697 |
unsupportedMediaPolicy? | UnsupportedMediaPolicy | 'throw' | Policy for how the adapter handles a @nhtio/adk!Media instance whose modality the OpenAI Chat Completions wire format does not natively support (today: video). See UnsupportedMediaPolicy. | src/batteries/llm/openai_chat_completions/types.ts:582 |
user? | string | undefined | End-user identifier for abuse monitoring. | src/batteries/llm/openai_chat_completions/types.ts:699 |
verbosity? | "low" | "high" | "medium" | undefined | Diagnostics verbosity level. | src/batteries/llm/openai_chat_completions/types.ts:701 |
web_search_options? | { search_context_size?: "low" | "high" | "medium"; user_location?: { approximate: { city?: string; country?: string; region?: string; timezone?: string; }; type: "approximate"; }; } | undefined | Configuration for built-in web search. | src/batteries/llm/openai_chat_completions/types.ts:703 |
web_search_options.search_context_size? | "low" | "high" | "medium" | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:704 |
web_search_options.user_location? | { approximate: { city?: string; country?: string; region?: string; timezone?: string; }; type: "approximate"; } | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:705 |
web_search_options.user_location.approximate | { city?: string; country?: string; region?: string; timezone?: string; } | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:707 |
web_search_options.user_location.approximate.city? | string | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:708 |
web_search_options.user_location.approximate.country? | string | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:709 |
web_search_options.user_location.approximate.region? | string | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:710 |
web_search_options.user_location.approximate.timezone? | string | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:711 |
web_search_options.user_location.type | "approximate" | undefined | - | src/batteries/llm/openai_chat_completions/types.ts:706 |