# How to Override the Default Model with a Custom LLM Provider in callLLM

> Learn how to override the default model in callLLM using a custom LLM provider via LLMOptions or the CLI flag. Easily integrate your preferred models for enhanced flexibility.

- Repository: [Udit Akhouri/adhd](https://github.com/UditAkhourii/adhd)
- Tags: how-to-guide
- Published: 2026-08-19

---

**You can override the default model in `callLLM` by supplying a custom model identifier through the `model` property in `LLMOptions`, or via the `--model` CLI flag when executing the run engine.**

The `UditAkhourii/adhd` repository provides a flexible framework for LLM-powered workflows through its `callLLM` utility. Since `callLLM` acts as a thin wrapper around the Claude Agent SDK's `query` function, you can easily redirect requests to any compatible provider—including OpenAI, Anthropic variants, or self-hosted endpoints—by configuring the model parameter appropriately.

## Understanding the Model Override Architecture

By default, `callLLM` forwards your request to the Claude Agent SDK, which falls back to its own default model (typically `claude-3-sonnet-20240229`) when no identifier is provided. The function builds query options through an internal helper that injects your custom model string directly into the SDK call.

In [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts), the `callLLM` function accepts an options object containing the optional `model` field. This field is passed through `buildQueryOptions` and ultimately determines which backend provider handles your request.

## Programmatic Model Configuration

### Direct Usage with callLLM

To override the model for a single invocation, pass the desired provider identifier via the `model` property:

```typescript
import { callLLM } from "./llm.js";

await callLLM({
  model: "my-custom-llm/v1",          // ← custom provider identifier
  systemPrompt: "You are a helpful assistant.",
  userPrompt: "Explain the concept of monads."
});

```

*Source:* [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts) (lines 17-20)

### Engine-Level Configuration with RunOptions

For batch operations managed by the execution engine, configure models through the `RunOptions` interface defined in [`src/types.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/types.ts). This approach supports distinct models for generation and critique phases:

```typescript
import { run } from "./engine.js";

await run({
  problem: "Build a todo app.",
  model: "anthropic/claude-3-sonnet-20240229",   // generator
  criticModel: "openai/gpt-4o-mini",            // scorer & clusterer
  // …other options
});

```

The engine routes these parameters to every `callLLM` invocation, with `criticModel` defaulting to the value of `model` when not explicitly set.

*Source:* [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) (lines 27-30)

## Command-Line Model Overrides

The CLI entry point in [`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts) exposes the `--model` and `--criticModel` flags, allowing you to swap providers without modifying source code. These flags populate the `RunOptions` object before execution begins:

```bash
node ./src/cli.js run "Improve project documentation" \
  --model=anthropic/claude-3-opus-20240229 \
  --criticModel=openai/gpt-4o

```

*Source:* [`src/cli.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/cli.ts) (lines 141-147)

## Complete Workflow Example

Combine engine configuration with custom providers to optimize both generation quality and evaluation cost:

```typescript
import { run } from "./engine.js";

const result = await run({
  problem: "Design a scalable chat service.",
  model: "my-org/custom-llm-2026",   // generator model
  criticModel: "anthropic/claude-3-sonnet-20240229", // optional separate critic
  framesPerRun: 4,
  ideasPerFrame: 5,
  topK: 3,
});
console.log(result.nonObviousPick?.text);

```

This pattern leverages [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts) to orchestrate the full pipeline while maintaining granular control over which LLM handles each phase.

## Summary

- **`callLLM`** forwards the `model` property directly to the underlying SDK via `buildQueryOptions` in [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts)
- **`RunOptions`** in [`src/types.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/types.ts) exposes both `model` (generation) and `criticModel` (evaluation) fields for differentiated provider selection
- **CLI flags** `--model` and `--criticModel` enable runtime overrides without code changes
- **Default fallback** occurs when no model is specified, deferring to the SDK's internal default configuration

## Frequently Asked Questions

### What happens if I don't specify a model in callLLM?

If the `model` property is omitted from `LLMOptions`, the Claude Agent SDK falls back to its internal default, typically `claude-3-sonnet-20240229`. The `callLLM` function in [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts) treats this field as optional and only forwards defined values.

### Can I use different models for generation and evaluation?

Yes. The `RunOptions` interface supports parallel configuration through the `model` and `criticModel` fields. The engine passes `criticModel` to the scoring and clustering stages, defaulting to the main `model` value when not specified, as implemented in [`src/engine.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/engine.ts).

### Does callLLM support local or self-hosted LLMs?

Yes. Any model identifier string recognized by the Claude Agent SDK—including custom endpoints, local models served via compatible APIs, or private provider formats—can be passed via the `model` property in `LLMOptions` or the CLI flags.

### Where is the model parameter processed in the source code?

The parameter is processed in [`src/llm.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/llm.ts) within the `callLLM` function, which constructs the query payload through `buildQueryOptions` before invoking the SDK's `query` method. The [`src/types.ts`](https://github.com/UditAkhourii/adhd/blob/main/src/types.ts) file defines the TypeScript interfaces that enforce type safety for these parameters.