Configuration reference
Every setting robotsix_llmio reads, in one place. There are two kinds:
- Tier configuration: fields of the pydantic models in
src/robotsix_llmio/config/tier.py. Consumers set them in the dict they pass toload_tier_config(config/loader.py) or in a file read byload_tier_config_file. Anything left out keeps its baked default. These fields have no environment-variable overlay. - Runtime environment variables: read with
os.environ.get()by the module named in the table. The library never loads a.envfile itself.
The pages linked under "Details" explain the behaviour in full. This page only lists each setting once.
Tier configuration (TierConfig)
| Setting | Type | Default | Env var | Read by | Effect |
|---|---|---|---|---|---|
chain |
list[ProviderSlotConfig] (≥ 1 slot) |
3 baked slots: direct Anthropic API, Claude SDK, OpenRouter (see Baked defaults) | — | config/tier.py (TierConfig.for_level), config/factory.py (create_model) |
Ordered provider slots. Position 0 serves normal traffic. Later positions take over, in order, during failover. |
chain[i].level1 / level2 / level3 |
TierLevelConfig |
per slot, see Baked defaults | — | config/tier.py (ProviderSlotConfig.for_level) |
Which model the slot uses for each capability level. |
default / fallback (legacy) |
ProviderSlotConfig |
Claude SDK slot / OpenRouter slot | — | config/loader.py (load_tier_config), config/tier.py (TierConfig validation) |
Old two-slot format, converted to chain[0] / chain[1] on load. Cannot be combined with chain. See Legacy two-slot configs. |
vision |
TierLevelConfig |
openrouter-deepseek/deepseek-v4-flash-vision-exp, max_tokens=8192 |
— | core/image_tool.py |
Model that answers ask_image tool calls. It is used directly and never goes through the chain or failover. |
failover |
FailoverConfig |
see the next table | — | core/failover.py |
Failover policy for the provider chain. |
Per-level binding (TierLevelConfig)
| Setting | Type | Default | Env var | Read by | Effect |
|---|---|---|---|---|---|
model |
str (required) |
— | — | core/identifier.py (parse_model_identifier), config/factory.py |
Provider and model name in the form <provider>-<model-name>. The prefix picks the backend (see Provider prefixes). |
provider_kwargs |
dict[str, Any] |
{} (baked OpenRouter levels set price ceilings and routing) |
— | config/factory.py (create_model) |
Keyword arguments passed to the provider constructor. Values passed directly to create_model override them. |
max_tokens |
int \| None |
None (no cap); baked OpenRouter levels: 16 384 / 65 536 / 131 072 |
— | config/factory.py, provider backends |
Maximum output tokens. OpenRouter treats it as the max_tokens model setting; the Claude SDK treats it as a task_budget. |
Failover policy (FailoverConfig)
| Setting | Type | Default | Env var | Read by | Effect |
|---|---|---|---|---|---|
failure_threshold |
int (≥ 1) |
3 |
— | core/_failover_state.py (ProviderFailoverTracker) |
How many provider-related failures in a row a slot can have before the tracker skips it for a while (its window arms). Exhaustion arms the window right away. |
window_seconds |
float (> 0) |
900.0 (15 min) |
— | core/_failover_state.py |
How long the tracker skips a slot after its window arms. |
reattempt_backoff_base |
float (> 1) |
2.0 |
— | core/_failover_state.py |
Each time a slot that is still failing arms its window again, the window is multiplied by this factor. |
reattempt_backoff_cap_seconds |
float (> 0, ≥ window_seconds) |
14400.0 (4 h) |
— | core/_failover_state.py |
Maximum length of a backed-off window. |
reattempt_backoff_jitter |
float (0–1) |
0.5 |
— | core/_failover_state.py |
Random reduction applied to a backed-off window, as a fraction of its length. |
max_request_cost_usd |
float \| None (> 0) |
None (off) |
— | core/_failover_policy.py via core/_cost_guard.py |
Blocks a switch to the next slot when that slot's estimated worst-case cost per request is above this limit. |
cost_ratio_threshold |
float \| None (> 0) |
None (off) |
— | core/_failover_policy.py via core/_cost_guard.py |
Blocks a switch when the candidate slot would cost more than this multiple of the slot the request started on. |
Hard-coded failover limit (not configurable): each request switches slots at
most len(chain) - 1 times (_max_slot_switches in core/_failover_policy.py).
Details: Failover down the chain, Failover runbook, Provider failover.
Runtime environment variables
| Variable | Type | Default | Read by | Effect |
|---|---|---|---|---|
OPENROUTER_API_KEY |
str |
— (required for openrouter- models) |
openrouter/provider.py |
API key for OpenRouterProvider. A non-empty api_key= argument takes precedence. |
DEEPSEEK_API_KEY |
str |
— (required for deepseek models) |
deepseek/provider.py |
API key for the direct-API DeepseekProvider. |
ANTHROPIC_API_KEY |
str |
— (required for anthropic- models) |
anthropic/provider.py |
API key for the Anthropic Messages API provider. |
REFDOCS_API_KEY |
str |
unset (no Authorization header) |
clients/refdocs/_settings.py |
Bearer token for refdocs. Used only when RefdocsSettings.api_key is None. |
LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY |
str |
unset (tracing off) | core/tracing.py (constants in core/_otel.py) |
Langfuse trace and cost export runs only when both are set. |
LANGFUSE_BASE_URL |
str |
https://cloud.langfuse.com |
core/tracing.py |
Langfuse endpoint. |
LANGFUSE_PROJECT_ID |
str |
unset | core/tracing.py |
Optional Langfuse project id. |
LOG_LEVEL |
str |
INFO |
logging.py |
Logging level, unless one is passed explicitly. |
LOG_FORMAT |
str |
console |
logging.py |
Logging format, unless one is passed explicitly. |
Client settings (RefdocsSettings)
| Setting | Type | Default | Env var | Read by | Effect |
|---|---|---|---|---|---|
base_url |
str |
http://localhost:9090 |
— | clients/refdocs/_settings.py |
Base URL of the refdocs REST API. |
api_key |
str \| None |
None |
REFDOCS_API_KEY (fallback) |
clients/refdocs/_settings.py |
Bearer token. |
request_timeout |
float |
30.0 |
— | clients/refdocs/_settings.py |
Timeout for each request, in seconds. |
Details: Refdocs.
API
robotsix_llmio.config
Two-slot, three-level configuration schema for provider+model bindings.
Prefer importing from :mod:robotsix_llmio.core — the public types are
re-exported there for discoverability.
Imports are deferred via :pep:562 __getattr__ so that importing the
config package does not eagerly pull in pydantic until a name is accessed.
TierConfigLoadError
Bases: RobotsixLLMIOError
Raised when tier configuration cannot be loaded.
This wraps underlying pydantic :class:~pydantic.ValidationError(s) as
__cause__ so the original details are always available.
FailoverConfig
Bases: BaseModel
Automatic provider-failover policy.
After :attr:failure_threshold consecutive provider-shaped failures on
the default slot (a provider-wide exhaustion arms failover
immediately), calls route to the fallback slot for
:attr:window_seconds, then automatically return to default. See
:mod:robotsix_llmio.core.failover.
ProviderSlotConfig
Bases: BaseModel
One provider slot's binding of all three capability levels.
A slot is a role (a position in :attr:TierConfig.chain),
not a provider name: each level entry carries its own combined
provider-model identifier, so a slot can technically mix backends. The
baked configuration keeps each slot on one provider — that is what makes
provider-level failover meaningful.
for_level
for_level(level)
Return the :class:TierLevelConfig for integer level (1, 2, or 3).
Raises:
| Type | Description |
|---|---|
ValueError
|
If level is not 1, 2, or 3. |
TierConfig
Bases: BaseModel
Ordered N-slot, three-level provider+model configuration.
:attr:chain is an ordered sequence of :class:ProviderSlotConfig
entries: position 0 is the provider used in normal operation, and each
later position is the next provider to cascade to while failover is
active. Any number of slots (>= 1) is supported.
All fields are optional: the baked chain is Anthropic via the direct
Messages API (position 0), Anthropic via the Claude SDK (position 1),
then DeepSeek via OpenRouter (position 2), so TierConfig() yields the
fully baked configuration.
The legacy two-slot shape (top-level default / fallback keys) is
still accepted and migrated onto the chain — default becomes position
0 and fallback position 1 of a two-slot chain; an omitted legacy
key keeps its baked slot (Claude SDK / OpenRouter respectively).
Example YAML/JSON (legacy shape)::
{"default": {"level1": {...}, "level2": {...}, "level3": {...}}}
or the chain shape::
{"chain": [{"level1": {...}, ...}, {...}, {...}]}
Use :meth:for_level to resolve an integer level to the corresponding
:class:TierLevelConfig; by default it resolves against the slot the
failover tracker currently designates as active.
default
property
default
Legacy alias for chain position 0 (the normal-operation slot).
fallback
property
fallback
Legacy alias for chain position 1 (the first failover slot).
Raises:
| Type | Description |
|---|---|
ValueError
|
If the chain holds a single slot. |
slot_index
slot_index(name)
Return the zero-based chain position designated by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
ProviderSlotName
|
A chain index ( |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If name is not a valid chain index or alias. |
slot
slot(name)
Return the :class:ProviderSlotConfig at chain position name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
ProviderSlotName
|
A chain index or a legacy slot-name alias — see
:meth: |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If name is not a valid chain index or alias. |
for_level
for_level(level, slot=None)
Resolve integer level (1, 2, or 3) to a :class:TierLevelConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Capability level — 1, 2, or 3. |
required |
slot
|
ProviderSlotName | None
|
Which provider slot to resolve against — a zero-based
chain index or a legacy alias ( |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If level is not 1, 2, or 3, or slot is not a valid chain position. |
TierLevel
Bases: StrEnum
Three-level capability selector.
| Member | Value | Purpose |
|---|---|---|
| LEVEL1 | level1 |
Cheap, frequent: monitors, classifiers, summaries |
| LEVEL2 | level2 |
Workhorse: implementing code, main assistant turns |
| LEVEL3 | level3 |
Frontier: hardest reasoning and long-horizon work |
Collapsed from five levels on 2026-09-01: equivalent-capability models on
other providers are no longer separate levels — they live in the
fallback provider slot of :class:TierConfig at the same level.
TierLevelConfig
Bases: BaseModel
A single level's provider-model binding.
Describes which combined provider-model identifier to use for a given
:class:TierLevel. The identifier is <provider>-<model-name>: the
provider prefix (before the first hyphen) and the concrete model name —
e.g. "claudeSDK-opus" or
"openrouter-deepseek/deepseek-v4-flash-20260731".
A :func:~pydantic.model_validator parses the identifier and confirms
the provider prefix is a known backend; the concrete model name is the
backend's concern (no upfront registry check).
provider
property
provider
Provider prefix parsed from the identifier.
model_name
property
model_name
Concrete model name parsed from the identifier.
MalformedIdentifierError
Bases: RobotsixLLMIOError
Raised when a provider-model identifier string is malformed.
ParsedIdentifier
Bases: NamedTuple
Result of :func:parse_model_identifier.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
The provider prefix before the first hyphen (e.g.
|
model_name |
str
|
Everything after the first hyphen — the concrete model
name fed to the backend. May contain hyphens and slashes
(e.g. |
create_model
create_model(
*,
level=1,
tier_config=None,
slot=None,
**provider_kwargs,
)
Create a provider instance for the given capability level.
The provider is derived from the combined provider-model identifier
on the tier config — the identifier's prefix drives lazy backend import
via :func:~robotsix_llmio.core.factory.get_provider_for_identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Capability level (1, 2, or 3). Level 1 is the cheap
frequent tier, level 2 the workhorse, level 3 the frontier
( |
1
|
tier_config
|
TierConfig | None
|
Optional :class: |
None
|
slot
|
ProviderSlotName | None
|
Explicit provider slot ( |
None
|
**provider_kwargs
|
Any
|
Forwarded to the provider constructor (e.g.
|
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
LLMProvider |
LLMProvider
|
A fully-instantiated provider ready for
:meth: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If level is not 1, 2, or 3. |
ImportError
|
If the provider's optional extra is not installed. |
Example:
.. code-block:: python
from robotsix_llmio.config import create_model
# Level 2 → Claude SDK by default (identifier "claudeSDK-opus").
provider = create_model(level=2)
agent = provider.build_agent(
level=2,
system_prompt="You are a helpful assistant.",
)
dump_tier_config
dump_tier_config(config)
Serialise config to a JSON-compatible dict in the chain shape.
This is the canonical persisted form: the legacy default /
fallback keys are never written, so a config saved with this helper
round-trips through :func:load_tier_config and
:meth:TierConfig.model_validate unchanged.
load_tier_config
load_tier_config(config_dict=None)
Load a validated :class:TierConfig, merging config_dict over the
baked defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dict
|
dict[str, Any] | None
|
Optional dict in the :class: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
TierConfig |
TierConfig
|
A fully-validated configuration — the baked three-slot |
TierConfig
|
chain, or a two-slot (Claude SDK / OpenRouter) chain when the legacy |
|
TierConfig
|
|
Raises:
| Type | Description |
|---|---|
TierConfigLoadError
|
If the merged configuration fails validation —
an unknown provider prefix in a supplied |
load_tier_config_file
load_tier_config_file(path, *, migrate=True)
Load a persisted tier config from the JSON file at path.
A missing file yields the baked configuration and — with migrate —
is written out fresh in the chain shape. A file in the legacy
two-slot shape (top-level default / fallback keys) is loaded
through the same migration as :func:load_tier_config and — with
migrate — re-persisted in the chain shape, so a deploy over an
old on-disk config starts cleanly instead of crashlooping, and the
cleanup happens once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
JSON file holding a :class: |
required |
migrate
|
bool
|
Rewrite a missing or legacy-shaped file in the |
True
|
Raises:
| Type | Description |
|---|---|
TierConfigLoadError
|
If the file is not valid JSON, is not a JSON object, or fails validation. |
save_tier_config_file
save_tier_config_file(config, path)
Persist config as JSON in the chain shape at path.
The write is atomic (temp file in the same directory, then
:func:os.replace), so a crash mid-write never leaves a truncated
config on disk for the next startup to choke on.
get_provider_for_identifier
get_provider_for_identifier(identifier, **kwargs)
Resolve and instantiate a provider from a combined tier identifier.
The identifier is parsed via :func:~.identifier.parse_model_identifier,
the provider prefix looked up in :data:_PROVIDER_PREFIX_MAP, and the
backend is lazy-imported. **kwargs are forwarded to the provider
constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
Combined provider-model identifier — e.g.
|
required |
**kwargs
|
Any
|
Forwarded to the resolved provider class constructor. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
LLMProvider |
LLMProvider
|
A fully-instantiated provider. |
Raises:
| Type | Description |
|---|---|
MalformedIdentifierError
|
If identifier cannot be parsed. |
ValueError
|
If the parsed provider prefix is not in
:data: |
ImportError
|
If the provider's optional extra is not installed. |
parse_model_identifier
parse_model_identifier(identifier)
Parse a combined provider-model tier identifier.
Grammar::
<provider>-<model-name>
where <provider> is everything before the first hyphen and
<model-name> is everything after it (the model name may itself
contain hyphens and slashes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The combined identifier string — e.g.
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParsedIdentifier |
ParsedIdentifier
|
Parsed components. |
Raises:
| Type | Description |
|---|---|
MalformedIdentifierError
|
If the identifier has no hyphen-delimited model part, or an empty provider or model name. |