---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/ollama/types/interfaces/OllamaAdapterOptions.md
description: Configuration options for the native Ollama `/api/chat` adapter.
---

# Interface: OllamaAdapterOptions

Defined in: [src/batteries/llm/ollama/types.ts:337](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L337)

Configuration options for the native Ollama `/api/chat` adapter.

## Properties

| Property                                                               | Type                                                                                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Defined in                                                                                                                          |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|  `apiKey?`                                 | `string`                                                                                                                                                                                                                     | Bearer token for cloud Ollama (`https://ollama.com`). Omit for local (no auth).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [src/batteries/llm/ollama/types.ts:340](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L340) |
|  `autoAck?`                               | `boolean`                                                                                                                                                                                                                    | Whether the executor acks automatically on a tool-call-free terminal answer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [src/batteries/llm/ollama/types.ts:381](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L381) |
|  `baseURL?`                               | `string`                                                                                                                                                                                                                     | Endpoint base URL. The adapter targets `<baseURL>/api/chat`. Defaults to `http://localhost:11434` (local); cloud is `https://ollama.com`. Native Ollama is HTTP-only — for a Unix-socket deployment, point this at an HTTP bridge (nginx `proxy_pass` / `socat`) or inject a custom [OllamaAdapterOptions.fetch](#property-fetch) instead.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [src/batteries/llm/ollama/types.ts:347](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L347) |
|  `bucketOrder?`                       | [`ChatCompletionsBucketOrder`](../../../../type-aliases/ChatCompletionsBucketOrder.md)                                                                                                                                       | Determines order of the system-prompt content buckets in history assembly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [src/batteries/llm/ollama/types.ts:365](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L365) |
|  `contextWindow?`                   | `number`                                                                                                                                                                                                                     | Size of the model's token context window (the ADK guard, independent of `num_ctx`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | [src/batteries/llm/ollama/types.ts:367](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L367) |
|  `fetch?`                                   | { (`input`: `URL` | `RequestInfo`, `init?`: `RequestInit`): `Promise`<`Response`>; (`input`: `string` | `URL` | `Request`, `init?`: `RequestInit`): `Promise`<`Response`>; }                                        | Custom `fetch` implementation. Use to reach a Unix-socket Ollama via a custom transport (e.g. undici with a `unix:` socket path) — native Ollama is HTTP-only, so socket access is a fetch/bridge concern, not an adapter option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [src/batteries/llm/ollama/types.ts:355](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L355) |
|  `forgeToolsFilter?`             | (`forged`: [`ToolRegistry`](../../../../../forge/classes/ToolRegistry.md), `ctx`: [`DispatchContext`](../../../../../types/interfaces/DispatchContext.md)) => [`ToolRegistry`](../../../../../forge/classes/ToolRegistry.md) | OPTIONAL hook to SHAPE the artifact-query tools forged from prior-turn SpooledArtifact results, before they merge into the visible tool set. **Remarks** When a prior tool returned a [@nhtio/adk!SpooledArtifact](../../../../../spooled_artifact/classes/SpooledArtifact.md), this battery forges that artifact class's reader tools (via `ctor.forgeTools(ctx)`) so the model can read the handle. A JSON artifact forges ~14 readers (~2.4k tokens of tool schema) — an unsheddable floor on a tight window, because the forge happens INSIDE the battery, downstream of any middleware subtractive pass. This hook lets the ASSEMBLER shape that forged set: it receives the merged forged registry + the dispatch context and returns a (possibly narrowed) registry, applied BEFORE the merge with `ctx.tools`. e.g. return only the core readers (`artifact_head`, `artifact_json_get`) so a tight window fits; the rest stay reachable via `tool_catalog`/`call_a_tool`. Default absent = identity (all forged tools) = fully backward-compatible. The battery stays BUDGET-AGNOSTIC (per the CONTRIBUTING size-threshold rule): it does NOT measure or compare against `contextWindow` — it just applies whatever filter the assembler supplied. Any budget logic lives in the caller's filter (middleware-side), which legitimately knows the turn's budget. | [src/batteries/llm/ollama/types.ts:450](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L450) |
|  `format?`                                 | [`OllamaFormat`](../type-aliases/OllamaFormat.md)                                                                                                                                                                            | Structured-output control: `'json'` or a JSON schema object.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [src/batteries/llm/ollama/types.ts:391](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L391) |
|  `headers?`                               | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `string`>                                                                                                            | Custom HTTP headers sent with every request (override built defaults, including auth).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [src/batteries/llm/ollama/types.ts:349](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L349) |
|  `helpers?`                               | [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)<[`OllamaHelpers`](OllamaHelpers.md)>                                                                                              | Optional overrides for the Ollama translation helpers.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [src/batteries/llm/ollama/types.ts:377](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L377) |
|  `keep_alive?`                         | `string` | `number`                                                                                                                                                                                                         | How long the model stays resident after the request (e.g. `'5m'`, `0` to unload).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [src/batteries/llm/ollama/types.ts:395](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L395) |
|  `localToolCallParser?`       | | [`ToolCallParserName`](../../../transformers_js/helpers/type-aliases/ToolCallParserName.md) | [`ToolCallParserFn`](../../../transformers_js/helpers/type-aliases/ToolCallParserFn.md)                                    | OPTIONAL fallback parser for tool calls the provider's chat template did NOT return structurally. **Remarks** Native `/api/chat` tool-calling is authoritative: when Ollama returns `message.tool_calls`, those are used and this option is never consulted. But small models (Gemma, Phi, and others) frequently emit a tool call in a surface form the server template does not recognize — `<call:name{…}`, a fenced \`\`\`json \`\`\`\` block, `<tool_code…>`, or bare `name\nkey: value`— in which case the call arrives as plain`message.content`and`tool_calls`is empty, silently dropping the call. This is a cross-model, cross-weight reality, not a single-provider quirk. Set this to a parser family name (e.g.`'gemma'`), `'auto'`(try every bundled parser in priority order), or a custom [ToolCallParserFn](../../../transformers_js/helpers/type-aliases/ToolCallParserFn.md) to recover such calls from`content`ONLY 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/ollama/types.ts:429](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L429) |
|  `model`                                    | `string`                                                                                                                                                                                                                     | Required. The Ollama model name (e.g. `llama3.2`, `gpt-oss:120b` for cloud).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [src/batteries/llm/ollama/types.ts:387](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L387) |
|  `onPromptAssembled?`           | [`PromptAssembledObserverFn`](../../../../type-aliases/PromptAssembledObserverFn.md)                                                                                                                                         | Observe the fully-assembled request this battery is about to POST TO Ollama — 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](#property-onrawgeneration). Purely observational (return value ignored, errors swallowed). Default absent. The request is handed back AS-IS — no redaction — so treat it as potentially sensitive if you persist it. See [PromptAssembledObserverFn](../../../../type-aliases/PromptAssembledObserverFn.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [src/batteries/llm/ollama/types.ts:411](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L411) |
|  `onRawGeneration?`               | [`RawGenerationObserverFn`](../../../../type-aliases/RawGenerationObserverFn.md)                                                                                                                                             | 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. See [RawGenerationObserverFn](../../../../type-aliases/RawGenerationObserverFn.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [src/batteries/llm/ollama/types.ts:403](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L403) |
|  `options?`                               | [`OllamaRuntimeOptions`](OllamaRuntimeOptions.md)                                                                                                                                                                            | Native sampling/runtime parameters, sent nested under the request body's `options` key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | [src/batteries/llm/ollama/types.ts:393](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L393) |
|  `replayCompatibility?`       | readonly `string`\[]                                                                                                                                                                                                          | List of replay labels supported by the assistant.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [src/batteries/llm/ollama/types.ts:375](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L375) |
|  `requestTimeoutMs?`             | `number`                                                                                                                                                                                                                     | Request timeout in milliseconds for API calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [src/batteries/llm/ollama/types.ts:361](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L361) |
|  `retry?`                                   | [`ChatCompletionsRetryConfig`](../../../../interfaces/ChatCompletionsRetryConfig.md)                                                                                                                                         | Configures request retry behavior.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [src/batteries/llm/ollama/types.ts:363](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L363) |
|  `selfIdentity?`                     | `string`                                                                                                                                                                                                                     | Unique identity label for the assistant instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [src/batteries/llm/ollama/types.ts:369](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L369) |
|  `spoolStore?`                         | [`SpoolStore`](../../../../../common/type-aliases/SpoolStore.md)                                                                                                                                                             | Backing store for `string` / `Uint8Array` tool returns; defaults to a per-dispatch in-memory store.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | [src/batteries/llm/ollama/types.ts:379](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L379) |
|  `stream?`                                 | `boolean`                                                                                                                                                                                                                    | Whether to stream the response chunk by chunk.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [src/batteries/llm/ollama/types.ts:357](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L357) |
|  `streamIdleTimeoutMs?`       | `number`                                                                                                                                                                                                                     | Idle timeout in milliseconds for the stream before aborting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [src/batteries/llm/ollama/types.ts:359](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L359) |
|  `think?`                                   | [`OllamaThink`](../type-aliases/OllamaThink.md)                                                                                                                                                                              | Native reasoning control for thinking-capable models.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [src/batteries/llm/ollama/types.ts:389](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L389) |
|  `thoughtSurfacing?`             | `"all"` | `"all-self"` | `"latest-self"`                                                                                                                                                                                   | Determines which thoughts are surfaced back to the model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | [src/batteries/llm/ollama/types.ts:371](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L371) |
|  `tokenEncoding?`                   | | [`TokenEncodingId`](../../../../../type-aliases/TokenEncodingId.md) | `null`                                                                                                                                             | Tokenizer encoding configuration for token counting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | [src/batteries/llm/ollama/types.ts:373](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L373) |
|  `toolCallIdFilter?`             | [`ToolCallIdFilterFn`](../../../../type-aliases/ToolCallIdFilterFn.md)                                                                                                                                                       | Optional ingress hook for adapting provider tool-call ids; absent preserves the incoming id.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | [src/batteries/llm/ollama/types.ts:431](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L431) |
|  `unsupportedMediaPolicy?` | [`UnsupportedMediaPolicy`](../../../transformers_js/type-aliases/UnsupportedMediaPolicy.md)                                                                                                                                  | Policy for handling a [@nhtio/adk!Media](../../../../../common/classes/Media.md) whose modality the Ollama wire cannot represent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | [src/batteries/llm/ollama/types.ts:383](https://github.com/NHTIO/ADK/blob/v1.20261003.0/src/src/batteries/llm/ollama/types.ts#L383) |
