You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stale-Rate Alarms for OpenAI-Compatible Agent SDKs (August 2026)
#63
One production pattern I would like to see more OpenAI-compatible SDKs expose is a stale-rate alarm. Not another pricing page, and not a hidden finance spreadsheet, but a runtime signal that tells an agent, an operator, and a billing reviewer when the rate card behind a model route is too old to trust.
This becomes important when one SDK can route to DeepSeek, Kimi, GLM, Qwen, ERNIE, or another Chinese model family through the same request shape. The model call may still be compatible with /v1/chat/completions, but the economics behind that call are not static. Input rows, cached-input rows, output multipliers, long-context behavior, and provider-specific limits can change faster than application releases.
For today's check, August 20, 2026, I pulled the live AIWave /api/pricing feed before writing this post. A few rows from that snapshot:
glm-5.1: $1.050/M input, about $3.300/M output, $0.32381/M cached input.
ernie-5.0: $1.232877/M input, about $4.657/M output, $0.100/M cached input.
qwen3.5-122b-a10b: $0.246575/M input and about $1.862/M output.
Those numbers are useful, but only if the SDK preserves when and where they were checked. A stale-rate alarm should treat a price row as an expiring operational dependency, similar to a certificate, schema contract, or feature flag. The request can still run after the expiry window, but the SDK should make the risk visible.
I would implement the alarm with three fields on every resolved route:
The SDK can then decide what to do before dispatch. In development, it might only log a warning. In CI, it can fail a test when committed fixtures are older than the policy allows. In production, the behavior should be policy-driven: warn, require an override header, route only low-risk traffic, or block high-budget agent runs until a fresh snapshot is loaded.
The alarm should be attached to usage events as well. If a customer asks why an agent run cost more than expected, support should be able to see both the billed model and the pricing state used at request time. "The route used a 2026-08-20 rate snapshot" is much easier to audit than "the SDK probably used the current dashboard."
There are two traps to avoid.
First, do not turn the alarm into a claim that one provider's number is globally correct. A gateway row, a direct-provider row, a batch row, and an account-specific contract row are different facts. The alarm should say which source was used, not pretend there is only one truth.
Second, do not hide stale rows by silently refreshing them in the background without recording the new version. Automatic refresh is useful, but it should still emit a new pricing_checked_at, source URL, and version hash when available. Otherwise the fix removes the very evidence operators need.
My default policy would be strict for agent workloads that can create long chains, retrieve large context, or retry across fallback routes. These are exactly the cases where stale cache math or output multipliers can turn a small route change into a real budget surprise. For short interactive calls, a warning plus telemetry may be enough.
Discussion question: should stale-rate alarms live inside the Python SDK, inside the gateway, or in both places? I lean toward both. The gateway owns the freshest rate card, but the SDK owns local tests, request policy, and developer-visible warnings. If you have implemented this, what max-age window did you choose, and did you fail closed or only warn?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
One production pattern I would like to see more OpenAI-compatible SDKs expose is a stale-rate alarm. Not another pricing page, and not a hidden finance spreadsheet, but a runtime signal that tells an agent, an operator, and a billing reviewer when the rate card behind a model route is too old to trust.
This becomes important when one SDK can route to DeepSeek, Kimi, GLM, Qwen, ERNIE, or another Chinese model family through the same request shape. The model call may still be compatible with
/v1/chat/completions, but the economics behind that call are not static. Input rows, cached-input rows, output multipliers, long-context behavior, and provider-specific limits can change faster than application releases.For today's check, August 20, 2026, I pulled the live AIWave
/api/pricingfeed before writing this post. A few rows from that snapshot:deepseek-v4-flash: $0.319/M input, $0.957/M output, $0.0318/M cached input.deepseek-v4-pro: $0.957/M input, $2.871/M output, $0.0333/M cached input.kimi-k2.5: $0.330/M input, $1.650/M output, about $0.1846/M cached input.kimi-k3: $2.250/M input, $11.250/M output, $0.200/M cached input.glm-5.1: $1.050/M input, about $3.300/M output, $0.32381/M cached input.ernie-5.0: $1.232877/M input, about $4.657/M output, $0.100/M cached input.qwen3.5-122b-a10b: $0.246575/M input and about $1.862/M output.Those numbers are useful, but only if the SDK preserves when and where they were checked. A stale-rate alarm should treat a price row as an expiring operational dependency, similar to a certificate, schema contract, or feature flag. The request can still run after the expiry window, but the SDK should make the risk visible.
I would implement the alarm with three fields on every resolved route:
{ "model": "glm-5.1", "pricing_source": "https://aiwave.live/api/pricing", "pricing_checked_at": "2026-08-20T14:00:00Z", "pricing_max_age_hours": 24, "pricing_state": "fresh" }The SDK can then decide what to do before dispatch. In development, it might only log a warning. In CI, it can fail a test when committed fixtures are older than the policy allows. In production, the behavior should be policy-driven: warn, require an override header, route only low-risk traffic, or block high-budget agent runs until a fresh snapshot is loaded.
The alarm should be attached to usage events as well. If a customer asks why an agent run cost more than expected, support should be able to see both the billed model and the pricing state used at request time. "The route used a 2026-08-20 rate snapshot" is much easier to audit than "the SDK probably used the current dashboard."
There are two traps to avoid.
First, do not turn the alarm into a claim that one provider's number is globally correct. A gateway row, a direct-provider row, a batch row, and an account-specific contract row are different facts. The alarm should say which source was used, not pretend there is only one truth.
Second, do not hide stale rows by silently refreshing them in the background without recording the new version. Automatic refresh is useful, but it should still emit a new
pricing_checked_at, source URL, and version hash when available. Otherwise the fix removes the very evidence operators need.My default policy would be strict for agent workloads that can create long chains, retrieve large context, or retry across fallback routes. These are exactly the cases where stale cache math or output multipliers can turn a small route change into a real budget surprise. For short interactive calls, a warning plus telemetry may be enough.
Discussion question: should stale-rate alarms live inside the Python SDK, inside the gateway, or in both places? I lean toward both. The gateway owns the freshest rate card, but the SDK owns local tests, request policy, and developer-visible warnings. If you have implemented this, what max-age window did you choose, and did you fail closed or only warn?
All reactions