Skip to content

Interface: LLMOptions

@providerprotocol/ai


@providerprotocol/ai / @providerprotocol/ai / LLMOptions

Defined in: src/types/llm.ts:119

Options for creating an LLM instance with the llm() function.

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);

TParams = unknown

Provider-specific parameter type

optional config: ProviderConfig

Defined in: src/types/llm.ts:124

Provider infrastructure configuration (optional - uses env vars if omitted)


optional middleware: 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.

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


optional params: TParams

Defined in: src/types/llm.ts:127

Model-specific parameters (temperature, max_tokens, etc.)


optional structure: Structure

Defined in: src/types/llm.ts:147

Structured output schema (JSON Schema or Zod schema)


optional system: 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.


optional tools: ToolInput<unknown, unknown>[]

Defined in: src/types/llm.ts:141

Tools available to the model (accepts Zod schemas for parameters)


optional toolStrategy: ToolUseStrategy

Defined in: src/types/llm.ts:144

Tool execution strategy