LLM
The agent talks to language models through the LLMClient contract.
ts
import { anthropic, type LLMClient } from "duclaw-cli/sdk";LLMClient
Implement this contract when you want to connect a custom model provider.
ts
type LLMClient = {
chat(
messages: LLMMessage[],
system: string,
tools?: Tool[],
options?: {
requestId?: string;
signal?: AbortSignal;
},
): Promise<LLMResponse>;
};Anthropic Adapter
Use anthropic() when the model endpoint speaks the Anthropic Messages API.
ts
const model = anthropic({
apiKey: process.env.ANTHROPIC_API_KEY!,
baseURL: process.env.ANTHROPIC_BASE_URL,
model: process.env.ANTHROPIC_MODEL,
});baseURL is optional. Pass it when you route requests through an Anthropic-compatible gateway, proxy, or private model endpoint:
ts
const model = anthropic({
apiKey: process.env.MODEL_API_KEY!,
baseURL: "https://gateway.example.com/anthropic",
model: "claude-sonnet-4-6",
});If the endpoint expects bearer authentication instead of Anthropic's standard x-api-key header, set authStyle:
ts
const model = anthropic({
apiKey: process.env.MODEL_API_KEY!,
baseURL: "https://gateway.example.com/anthropic",
model: "claude-sonnet-4-6",
authStyle: "bearer",
});Supported options:
| Option | Required | Purpose |
|---|---|---|
apiKey | Yes | API key or gateway token |
model | No | Model name sent to the endpoint |
baseURL | No | Custom Anthropic-compatible endpoint |
maxTokens | No | Maximum response tokens |
authStyle | No | Use "x-api-key" by default, or "bearer" for Authorization: Bearer gateways |
Use a custom LLMClient when your application owns model routing, retries, observability, or provider fallback.