configure(options)
Sets global defaults for all agent() calls. Call this once at application startup.
Signature
ts
function configure(options: {
provider?: AIProvider;
model?: string;
}): voidParameters
| Parameter | Type | Description |
|---|---|---|
provider | AIProvider | The default provider for all agents |
model | string | The default model identifier |
Example
ts
import { configure, openrouter } from '@daedalus-ai-dev/ai-sdk';
configure({
provider: openrouter({
apiKey: process.env.OPENROUTER_API_KEY!,
}),
model: 'openai/gpt-4o-mini',
});After calling configure(), any agent() call without an explicit provider or model will use these defaults:
ts
// Uses the globally configured provider and model
const response = await agent({
instructions: 'Be helpful.',
}).prompt('Hello!');
// Overrides the model for this agent only
const powerfulResponse = await agent({
instructions: 'Reason carefully.',
model: 'anthropic/claude-3-5-sonnet',
}).prompt('Solve this complex problem...');Notes
configure()is global state — it affects all subsequentagent()calls in the process.- In a test environment, pass
providerdirectly to eachagent()instead of usingconfigure()to keep tests isolated. - Per-agent
providerandmodelalways override the global defaults.