Skip to content

Interface: ModelReference

@providerprotocol/ai


@providerprotocol/ai / @providerprotocol/ai / ModelReference

Defined in: src/types/provider.ts:221

A reference to a model, created by a provider factory.

Model references are lightweight objects that identify a model and its provider, used as input to the llm() function.

const model = openai('gpt-4');
console.log(model.modelId); // 'gpt-4'
console.log(model.provider.name); // 'openai'

TOptions = unknown

Provider-specific options type

readonly modelId: string

Defined in: src/types/provider.ts:223

The model identifier (e.g., ‘gpt-4’, ‘claude-3-opus’)


readonly optional options: TOptions

Defined in: src/types/provider.ts:244

The original options passed when creating this model reference.

Used by providers with multiple LLM handlers (e.g., OpenAI with responses/completions APIs) to resolve the correct handler at request time, avoiding race conditions from shared state.


readonly provider: Provider<TOptions>

Defined in: src/types/provider.ts:226

The provider that created this reference


readonly optional providerConfig: Partial<ProviderConfig>

Defined in: src/types/provider.ts:236

Optional provider-specific configuration that gets merged into request config.

This allows providers to store options set at model reference creation time (e.g., anthropic('model', { betas: [...] })) that should be applied to all requests. The llm() factory will merge these into the request config, with explicit config values taking precedence.