Fallbacks

Register named callables that invoke your own provider clients and API keys. Aurex does not proxy LLM traffic.

Agent hint

Use for register_fallback / registerFallback, fallbacks config chain, idempotency modes.

In scope

  • register_fallback API
  • fallbacks config name/after
  • idempotency auto | require_key | off

Out of scope

  • Classification kinds — see Classification
  • Dashboard metrics — see Loss Accounting
Python
import openai
from aurex_sdk import AurexAuditor, AurexConfig

auditor = AurexAuditor(AurexConfig(
    api_key="aux_dev_yourkey",
    resilience={
        "enabled": True,
        "mode": "enforce",
        "fallbacks": [{"name": "openai_mini", "after": ["network", "5xx"]}],
    },
))

client = openai.OpenAI()

def call_mini(**kwargs):
    kwargs["model"] = "gpt-4o-mini"
    return client.chat.completions.create(**kwargs)

auditor.register_fallback(
    "openai_mini",
    call_fn=call_mini,
    provider="openai",
    model="gpt-4o-mini",
)
Node.js
import OpenAI from "openai";
import { AurexAuditor } from "aurex-sdk";

const auditor = AurexAuditor.getInstance({
  apiKey: "aux_dev_yourkey",
  resilience: {
    enabled: true,
    mode: "enforce",
    fallbacks: [{ name: "openai_mini", after: ["network", "5xx"] }],
  },
});

const client = new OpenAI();

auditor.registerFallback("openai_mini", async (params) => {
  return client.chat.completions.create({ ...params, model: "gpt-4o-mini" });
}, { provider: "openai", model: "gpt-4o-mini" });
  • idempotency: require_key — skips retry/fallback without a stable idempotency key (safe for non-idempotent tools).
  • Retries and fallbacks accumulate cost against max_extra_cost_usd; enforce stops when exceeded.
  • Fallback callables receive the same params built for the primary call.

See also