Skip to content

ModelRunnerBackendConfig

Defined in: packages/ai.matey.types/src/model-runner.ts:257

Configuration for model runner backends.

Extends BackendAdapterConfig with model runner-specific options.

readonly apiKey: string

Defined in: packages/ai.matey.types/src/adapters.ts:130

API key for authentication. Should be injected from environment or secure config.

BackendAdapterConfig.apiKey


readonly optional baseURL: string

Defined in: packages/ai.matey.types/src/adapters.ts:136

Base URL for API endpoint. Useful for proxies or alternative endpoints.

BackendAdapterConfig.baseURL


readonly optional browserMode: boolean

Defined in: packages/ai.matey.types/src/adapters.ts:189

Enable browser-compatible mode.

⚠️ SECURITY WARNING: Enabling browser mode may expose API keys in client-side code. This option should ONLY be used for development and testing. Production applications should always use proxy servers to protect API keys.

Each provider implements browser compatibility differently:

  • Anthropic: Adds anthropic-dangerous-direct-browser-access: true header
  • Gemini: Already browser-compatible (API key in URL), this flag has no effect
  • OpenAI: Already browser-compatible, this flag has no effect
  • Other providers: May have provider-specific implementations
false
// Development only - DO NOT use in production!
const backend = new AnthropicBackendAdapter({
apiKey: process.env.ANTHROPIC_API_KEY,
browserMode: true // ⚠️ Exposes API key in browser
});

BackendAdapterConfig.browserMode


readonly optional cacheModels: boolean

Defined in: packages/ai.matey.types/src/adapters.ts:223

Enable model list caching.

true

BackendAdapterConfig.cacheModels


communication: CommunicationConfig

Defined in: packages/ai.matey.types/src/model-runner.ts:271

Communication configuration.


readonly optional custom: Record<string, unknown>

Defined in: packages/ai.matey.types/src/adapters.ts:164

Provider-specific configuration options.

BackendAdapterConfig.custom


readonly optional debug: boolean

Defined in: packages/ai.matey.types/src/adapters.ts:154

Enable debug logging.

false

BackendAdapterConfig.debug


readonly optional defaultModel: string

Defined in: packages/ai.matey.types/src/adapters.ts:199

Default model to use when no model is specified in the request. This provides a fallback model for requests that don’t specify one.

'gpt-4o' for OpenAI, 'claude-3-5-sonnet-20241022' for Anthropic

BackendAdapterConfig.defaultModel


readonly optional headers: Record<string, string>

Defined in: packages/ai.matey.types/src/adapters.ts:159

Custom HTTP headers to include in requests.

BackendAdapterConfig.headers


optional lifecycle: LifecycleConfig

Defined in: packages/ai.matey.types/src/model-runner.ts:281

Lifecycle management configuration.


readonly optional maxRetries: number

Defined in: packages/ai.matey.types/src/adapters.ts:148

Maximum number of retries for transient failures.

0

BackendAdapterConfig.maxRetries


model: string | ModelReference

Defined in: packages/ai.matey.types/src/model-runner.ts:261

Model configuration.


readonly optional models: readonly (string | AIModel)[]

Defined in: packages/ai.matey.types/src/adapters.ts:211

Static model list (used when provider doesn’t have listing endpoint or to override remote list).

Can be either:

  • Array of model IDs (strings) - will be normalized to AIModel objects
  • Array of full AIModel objects with capabilities

BackendAdapterConfig.models


readonly optional modelsCacheScope: "global" | "instance"

Defined in: packages/ai.matey.types/src/adapters.ts:237

Cache scope strategy.

  • ‘global’: Share cache across all adapter instances (default)
  • ‘instance’: Each adapter instance has its own cache
'global'

BackendAdapterConfig.modelsCacheScope


readonly optional modelsCacheTTL: number

Defined in: packages/ai.matey.types/src/adapters.ts:229

Cache TTL in milliseconds.

3600000 (1 hour)

BackendAdapterConfig.modelsCacheTTL


readonly optional modelsEndpoint: string

Defined in: packages/ai.matey.types/src/adapters.ts:217

URL endpoint for fetching models (overrides default). Used for custom model endpoints or proxies.

BackendAdapterConfig.modelsEndpoint


optional port: number

Defined in: packages/ai.matey.types/src/model-runner.ts:287

Port number for HTTP communication. If not specified, an available port will be auto-discovered.


process: ProcessConfig

Defined in: packages/ai.matey.types/src/model-runner.ts:266

Process execution configuration.


optional promptTemplate: string | PromptTemplate

Defined in: packages/ai.matey.types/src/model-runner.ts:293

Prompt template name or custom template.

'llama2', 'chatml', 'alpaca'

optional runtime: RuntimeConfig

Defined in: packages/ai.matey.types/src/model-runner.ts:276

Runtime configuration for model execution.


readonly optional streaming: StreamingConfig

Defined in: packages/ai.matey.types/src/adapters.ts:251

Streaming configuration for this backend.

Controls how streaming responses are delivered:

  • mode: ‘delta’ (incremental only) or ‘accumulated’ (full text each chunk)
  • includeBoth: Whether to provide both delta and accumulated in chunks
  • bufferStrategy: How to buffer for accumulated mode
{ mode: 'delta', includeBoth: false, bufferStrategy: 'memory' }

BackendAdapterConfig.streaming


readonly optional timeout: number

Defined in: packages/ai.matey.types/src/adapters.ts:142

Request timeout in milliseconds.

30000

BackendAdapterConfig.timeout