aix.config¶
Central configuration for AIX (single source of truth for defaults).
This module is the SSOT for *what model (and related parameters) each AIX
function uses by default*. Instead of scattering hardcoded DFLT_* constants
across modules, every function resolves its defaults from a single, layered
configuration.
Resolution layers, highest precedence first:
Explicit call argument – e.g.
chat(..., model=...)always wins (handled at the call site, not here).Runtime override –
configure()swaps the active config;using()scopes an override to awithblock.Environment variables –
AIX_CHAT_MODEL,AIX_CHAT_TEMPERATURE,AIX_EMBEDDING_MODEL,AIX_IMAGE_MODEL,AIX_TTS_MODEL,AIX_TTS_VOICE,AIX_TRANSCRIPTION_MODEL, …User config file – a TOML file at
<app config dir>/config.toml(override the path with theAIX_CONFIG_FILEenvironment variable).Shipped defaults – the dataclass field defaults below.
The schema is a set of frozen dataclasses (immutable). A module-level *active
config* pointer holds the currently resolved AixConfig; configure()
and using() swap that pointer rather than mutating in place.
Examples
>>> from aix import config
>>> c = config.get_config()
>>> isinstance(c.chat.model, str)
True
Scoped override (does not leak outside the block):
>>> with config.using(chat_model="some/model"):
... config.get_config().chat.model
'some/model'
>>> config.get_config().chat.model == c.chat.model
True
TOML config file shape:
[chat]
model = "openai/gpt-4o-mini"
temperature = 1.0
[embeddings]
model = "text-embedding-3-small"
[image]
model = "dall-e-3"
size = "1024x1024"
[audio]
tts_model = "tts-1"
tts_voice = "alloy"
transcription_model = "whisper-1"
[vision]
model = "gpt-4o-mini"
[aliases]
fast = "openai/gpt-4o-mini"
best = "anthropic/claude-sonnet-4"
Functions
|
Resolve an |
Return the current active |
|
|
Replace the active config wholesale. |
|
Apply runtime overrides to the active config and return it. |
|
Context manager applying scoped overrides, restored on exit. |
Path to the user config file (env |
|
|
Resolve a semantic alias ( |
Classes
|
Defaults for |
|
Defaults for |
|
Defaults for |
|
Defaults for |
|
Defaults for |
|
Defaults for |
|
Top-level AIX configuration (single source of truth for defaults). |
- class aix.config.AixConfig(chat=<factory>, embeddings=<factory>, image=<factory>, audio=<factory>, video=<factory>, vision=<factory>, aliases=<factory>)[source]¶
Bases:
objectTop-level AIX configuration (single source of truth for defaults).
- class aix.config.AudioConfig(tts_model='gpt-4o-mini-tts', tts_voice='alloy', tts_speed=1.0, transcription_model='whisper-1')[source]¶
Bases:
objectDefaults for
text_to_speech/transcribe/translate_audio.
- class aix.config.ChatConfig(model='gpt-4.1-mini', temperature=1.0, max_tokens=None)[source]¶
Bases:
objectDefaults for
chat/ask/prompt_func.
- class aix.config.EmbeddingConfig(model='text-embedding-3-small', batch_size=512)[source]¶
Bases:
objectDefaults for
embeddings/embed.
- class aix.config.ImageConfig(model='dall-e-3', size='1024x1024', quality='standard', num_images=1)[source]¶
Bases:
objectDefaults for
generate_image/generate_images.
- class aix.config.VideoConfig(provider=None)[source]¶
Bases:
objectDefaults for
generate_video(provider-dependent).
- class aix.config.VisionConfig(model='gpt-4o-mini')[source]¶
Bases:
objectDefaults for
describe_image(image→text).The default is a cheap, vision-capable OpenAI model so it works with the same
OPENAI_API_KEYmost users already have; override per call (describe_image(..., model=...)), viaconfigure(vision_model=...), or the[vision]TOML section to route to Claude / Gemini / etc.
- aix.config.config_file_path()[source]¶
Path to the user config file (env
AIX_CONFIG_FILEoverrides default).- Return type:
- aix.config.configure(**overrides)[source]¶
Apply runtime overrides to the active config and return it.
- Return type:
Examples
>>> from aix import config >>> _ = config.configure(chat_model="openai/gpt-4o-mini") >>> config.get_config().chat.model 'openai/gpt-4o-mini' >>> _ = config.configure(chat={"temperature": 0.2}) >>> config.get_config().chat.temperature 0.2
- aix.config.load_config(path=None, *, environ=None)[source]¶
Resolve an
AixConfigfrom shipped defaults, TOML file, and env.Precedence (low to high): shipped defaults < TOML file < environment variables. Runtime overrides (
configure()/using()) and explicit call arguments sit above this and are applied elsewhere.
- aix.config.resolve_model(model, *, config=None)[source]¶
Resolve a semantic alias (
"fast","best", …) to a concrete model id.Plain substitution: if
modelis a key in the activealiasestable it is replaced (following chains, with cycle protection). Anything that is not an alias – including every literal model id like"gpt-4o"– is returned unchanged.Nonepasses through (callers apply their own default first).Note
aliases share a namespace with literal model ids, so an unknown name is treated as a literal id, not an error. Inspect available aliases via
aix.get_config().aliases.Examples
>>> from aix import config >>> config.resolve_model("fast") in config.DEFAULT_ALIASES.values() True >>> config.resolve_model("gpt-4o") # not an alias -> unchanged 'gpt-4o' >>> config.resolve_model(None) is None True