Configuration
Import: from air.config import AIRConfig. AIRConfig is also available as from air import AIRConfig.
AIRConfig
python
@dataclass
class AIRConfig:
default_provider: str | None = None
routing: str = "priority"
context_optimization: str = "auto"
context_budget: ContextBudget = field(default_factory=ContextBudget)
summarize_with_ai: bool = False
summarize_provider: str | None = None
usage_thresholds: list[float] = field(default_factory=lambda: [0.8])default_provider: str | None. If set, and aChatRequestdoes not set its ownprovider, this name is used for explicit provider selection (no fallback). Equivalent in effect to always settingChatRequest.providerto this value.routing: str."priority"(default) or"intelligent". See ../core/routing.md and ../features/intelligent-routing.md. Any other value raisesConfigurationErrorwhen constructingAIR(...).context_optimization: str."auto"(default) or"off". See ../features/context-optimization.md. Any other value raisesConfigurationError.context_budget: ContextBudget. See below.summarize_with_ai: bool. DefaultFalse. IfTrue, context optimization asks a configured provider to summarize older messages instead of using the local, no-API-call summary. See ../features/context-optimization.md.summarize_provider: str | None. Which registered provider to use for AI assisted summarization. IfNone, the highest priority registered provider is used.usage_thresholds: list[float]. Default[0.8]. Fractions (of a configured token limit) that trigger ausage_thresholdevent the first time each is crossed, per provider. See ../features/capacity-tracking.md.
ContextBudget
Import: from air.context.optimize import ContextBudget.
python
@dataclass
class ContextBudget:
max_tokens: int = 8000
keep_recent: int = 6
max_message_chars: int = 4000See ../features/context-optimization.md for what each field controls.
Passing configuration to AIR
python
from air import AIR
from air.config import AIRConfig
from air.context.optimize import ContextBudget
air = AIR(config=AIRConfig(
routing="intelligent",
context_budget=ContextBudget(max_tokens=4000, keep_recent=4),
usage_thresholds=[0.5, 0.8, 0.95],
))AIR(routing=...) and AIR(persist=...) are shorthand constructor arguments that set config.routing and select the context store respectively; they do not have corresponding AIRConfig fields of their own for the store selection (there is no AIRConfig.persist field; persistence is controlled only through the AIR(persist=...) constructor argument).