Interface: LLMOptions
@providerprotocol/ai / @providerprotocol/ai / LLMOptions
Interface: LLMOptions<TParams>
Section titled “Interface: LLMOptions<TParams>”Defined in: src/types/llm.ts:119
Options for creating an LLM instance with the llm() function.
Example
Section titled “Example”const options: LLMOptions = { model: openai('gpt-4'), system: 'You are a helpful assistant.', params: { temperature: 0.7, max_tokens: 1000 }, tools: [weatherTool, searchTool], toolStrategy: { maxIterations: 5 }};
const instance = llm(options);Type Parameters
Section titled “Type Parameters”TParams
Section titled “TParams”TParams = unknown
Provider-specific parameter type
Properties
Section titled “Properties”config?
Section titled “config?”
optionalconfig:ProviderConfig
Defined in: src/types/llm.ts:124
Provider infrastructure configuration (optional - uses env vars if omitted)
middleware?
Section titled “middleware?”
optionalmiddleware:Middleware[]
Defined in: src/types/llm.ts:166
Middleware for intercepting and transforming requests, responses, and streams.
Middleware are executed in array order for request/start hooks, and reverse order for response/end hooks.
Example
Section titled “Example”const model = llm({ model: anthropic('claude-sonnet-4-20250514'), middleware: [ loggingMiddleware(), parsedObjectMiddleware(), ],});model:
ModelInput
Defined in: src/types/llm.ts:121
A model reference from a provider factory
params?
Section titled “params?”
optionalparams:TParams
Defined in: src/types/llm.ts:127
Model-specific parameters (temperature, max_tokens, etc.)
structure?
Section titled “structure?”
optionalstructure:Structure
Defined in: src/types/llm.ts:147
Structured output schema (JSON Schema or Zod schema)
system?
Section titled “system?”
optionalsystem:string|unknown[]
Defined in: src/types/llm.ts:138
System prompt for all inferences.
Can be a simple string or a provider-specific array format:
- Anthropic:
[{type: 'text', text: '...', cache_control?: {...}}] - Google:
[{text: '...'}, {text: '...'}](parts array)
Array formats are passed through directly to the provider.
tools?
Section titled “tools?”
optionaltools:ToolInput<unknown,unknown>[]
Defined in: src/types/llm.ts:141
Tools available to the model (accepts Zod schemas for parameters)
toolStrategy?
Section titled “toolStrategy?”
optionaltoolStrategy:ToolUseStrategy
Defined in: src/types/llm.ts:144
Tool execution strategy