Auth
Bill an Agent against a subscription seat instead of an API key.
auth tells an Agent to bill a run against a subscription seat rather than an API key.
Quick Start
- Pick a provider
typescript import { Agent } from 'praisonai'; const agent = new Agent({ instructions: 'You are helpful', auth: 'claude-code', }); const reply = await agent.chat('Hello'); - Let auth choose the model
Omit
llmandauthpicks the provider’s default model, so a subscription token never ships to the wrong endpoint.
Default models
When you pass auth without an llm, the agent uses the provider’s default model.
| Provider | Default model |
|---|---|
claude-code | anthropic/claude-sonnet-4-5 |
qwen-cli | openai/qwen3-coder-plus |
How it works
The credentials are resolved once on the first turn, then every outgoing request is sent through a fetch wrapper that adds the provider’s headers. Existing headers on a request win, so you can still override one deliberately.
Because a subscription seat belongs to one vendor, auth also pins the default model โ falling back to API-key billing would charge the wrong account, so an unregistered provider fails at construction rather than at request time.
When it throws
import { Agent } from 'praisonai';
new Agent({ instructions: 'Hi', auth: 'not-a-provider' });
// Error: Unknown subscription provider 'not-a-provider'. Registered: (none).
// A subscription store is a host concern: register one with
// registerAuthProvider('not-a-provider', resolver).Leaf import for bundle-sensitive callers
resolveAuth, registerAuthProvider, listAuthProviders, resetAuthProviders, and the LLMAuth, LLMAuthResolver, and LLMAuthSource types can be imported from 'praisonai', 'praisonai/llm', or the leaf module 'praisonai/llm/auth'. All three resolve to the same names โ PraisonAI PR #4874 moved the implementation into llm/auth.ts and re-exports it, so the public API is unchanged.
// Any of these work โ same names, same behaviour
import { registerAuthProvider } from 'praisonai';
import { registerAuthProvider } from 'praisonai/llm';
import { registerAuthProvider } from 'praisonai/llm/auth';