# Class OllamaAdapter

Ollama model adapter for local model inference.

#### Hierarchy (View Summary)

- BaseAdapter
  - OllamaAdapter

- Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:151

##### Index

### Constructors

constructor

### Properties

providerId
modelId
capabilities
logger
config

### Methods

hasCapability
logRequest
logResponse
transformError
validateConfig
complete
stream
countTokens

## Constructors

### constructor

- new OllamaAdapter(config: OllamaAdapterConfig): OllamaAdapter

  #### Parameters

  - config: OllamaAdapterConfig

  #### Returns OllamaAdapter

  Overrides BaseAdapter.constructor

  - Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:154

## Properties

### `Readonly` providerId

providerId: string

Provider identifier (e.g., 'anthropic', 'openai')

Inherited from BaseAdapter.providerId

- Defined in packages/nexus-agents/src/adapters/base-adapter.ts:149

### `Readonly` modelId

modelId: string

Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o')

Inherited from BaseAdapter.modelId

- Defined in packages/nexus-agents/src/adapters/base-adapter.ts:150

### `Readonly` capabilities

capabilities: readonly ModelCapability[]

Capabilities this model supports

Inherited from BaseAdapter.capabilities

- Defined in packages/nexus-agents/src/adapters/base-adapter.ts:151

### `Protected` `Readonly` logger

logger: ILogger

Logger for request/response logging

Inherited from BaseAdapter.logger

- Defined in packages/nexus-agents/src/adapters/base-adapter.ts:154

### `Protected` `Readonly` config

config: BaseAdapterConfig

Configuration for the adapter

Inherited from BaseAdapter.config

- Defined in packages/nexus-agents/src/adapters/base-adapter.ts:157

## Methods

### hasCapability

- hasCapability(capability: ModelCapability): boolean

  Check if this adapter supports a specific capability.

  #### Parameters

  - capability: ModelCapability

    The capability to check for

  #### Returns boolean

  True if the capability is supported

  Inherited from BaseAdapter.hasCapability

  - Defined in packages/nexus-agents/src/adapters/base-adapter.ts:256

### `Protected` logRequest

- logRequest(request: CompletionRequest): void

  Log details about an outgoing request. Sanitizes sensitive information before logging.

  #### Parameters

  - request: CompletionRequest

    The completion request to log

  #### Returns void

  Inherited from BaseAdapter.logRequest

  - Defined in packages/nexus-agents/src/adapters/base-adapter.ts:266

### `Protected` logResponse

- logResponse(response: CompletionResponse): void

  Log details about a received response.

  #### Parameters

  - response: CompletionResponse

    The completion response to log

  #### Returns void

  Inherited from BaseAdapter.logResponse

  - Defined in packages/nexus-agents/src/adapters/base-adapter.ts:288

### `Protected` transformError

- transformError(error: unknown): ModelError

  Transform a provider-specific error into a standardized ModelError.

  Maps common error patterns to appropriate error codes:

  - Rate limiting (429, quota exceeded)
  - Timeouts (ETIMEDOUT, ESOCKETTIMEDOUT)
  - Authentication (401, 403)
  - Model unavailable (503, 502)

  #### Parameters

  - error: unknown

    The original error from the provider

  #### Returns ModelError

  A standardized ModelError

  Inherited from BaseAdapter.transformError

  - Defined in packages/nexus-agents/src/adapters/base-adapter.ts:311

### validateConfig

- validateConfig(): Result<void, ConfigError>

  Validate adapter configuration.

  Checks that required configuration fields are present and valid. Concrete adapters may override to add provider-specific validation.

  #### Returns Result<void, ConfigError>

  Ok if valid, ConfigError if invalid

  Overrides BaseAdapter.validateConfig

  - Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:168

### complete

- complete(
  request: CompletionRequest,
  ): Promise<Result<CompletionResponse, ModelError>>

  Send a completion request to the model. Must be implemented by concrete adapter classes.

  #### Parameters

  - request: CompletionRequest

    The completion request

  #### Returns Promise<Result<CompletionResponse, ModelError>>

  Result with response or ModelError

  Overrides BaseAdapter.complete

  - Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:179

### stream

- stream(request: CompletionRequest): AsyncIterable<StreamChunk>

  Stream a completion request from the model. Must be implemented by concrete adapter classes.

  #### Parameters

  - request: CompletionRequest

    The completion request

  #### Returns AsyncIterable<StreamChunk>

  #### Yields

  StreamChunk objects as they arrive

  Overrides BaseAdapter.stream

  - Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:192

### countTokens

- countTokens(text: string): Promise<number>

  Count tokens in text using the unified TokenEstimator.

  This provides a reasonable estimate for most use cases. Concrete adapters may override this with provider-specific tokenizers.

  #### Parameters

  - text: string

    Text to count tokens for

  #### Returns Promise<number>

  Approximate token count

  Overrides BaseAdapter.countTokens

  - Defined in packages/nexus-agents/src/adapters/ollama-adapter.ts:201