Skip to main content
auth tells an Agent to bill a run against a subscription seat rather than an API key.

Quick Start

1

Pick a provider

2

Let auth choose the model

Omit llm and auth picks 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.

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

Credential stores (a Claude Code keychain entry, a Codex CLI file) are host concerns and are not read by the SDK. Register your own resolver with registerAuthProvider(name, resolver) — the TypeScript counterpart to Python’s register_subscription_provider.

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.
Prefer import { … } from 'praisonai' in application code. The leaf path 'praisonai/llm/auth' matters only when you build a custom bundle and want auth without pulling in openai or the embedding stack — the barrel (praisonai/llm) statically imports both.

Agent

Constructor options

Model Routing

How model names resolve