How to Build a Verifiable "Fair Scale" for LLM API Relay Services
This article explains why third-party LLM API relay services often lack verifiable metering and consistency, and how to build a "fair scale" around three principles: metering fairness, scheduling fairness, and model consistency. It covers normalizing quotes to cost per million tokens, auditing cache pricing, managing multi-account pool risks, reconstructing bills through dual-run reconciliation, detecting model substitution with fingerprints and capability probes, and building a controllable gateway with common cloud capabilities. A practical checklist is included.
1. The Core Problem: Relay Chains Lack a Verifiable “Fair Scale”
In LLM API procurement and integration, a common pattern appears: a third-party relay service quotes a price well below the official public rate, and onboarding is simple—once you have an activation code or key, you can start calling. But after moving into production, problems surface all at once: ambiguous billing definitions, opaque credit-to-token conversion, and the same model name mapping to different actual specifications. Descriptions from the source material—“1/3 to 1/2 the price,” “no explanation of how credits convert to token quotas,” “includes input, output, and cache”—do not point to a single vendor’s issue. They point to the entire relay chain lacking a verifiable metering and consistency mechanism.
In engineering terms, a “fair scale” has three layers:
- Metering fairness: consistent and auditable definitions across billing dimensions such as input, output, cache hits, and tool calls.
- Scheduling fairness: rotation across an account pool (a resource pool of multiple accounts or keys) must not change the service tier a request receives.
- Consistency fairness: the requested model name must strictly correspond to the model specification actually executed.
If any one is missing, both the cost model and quality evaluation become distorted.
2. The Real Cost of Activation Codes and Credits: Converting “Cheap” into Comparable Units
Low prices are not the problem; incomparability is. To judge whether a quote is reasonable, you must first normalize every quote to a single unit: the blended cost per million tokens.
Official public pricing is usually split by dimension. For example, one model’s output price might be 4 CNY per million tokens during off-peak hours and 8 CNY during peak hours. A relay quote of “under 3 CNY” is not comparable unless it specifies whether that is the input price, output price, or a blended average. Statements from the source material like “10 CNY for about 10,000 credits” or “10 million token quota for about 40–50 CNY versus 10 CNY” lack a credit-to-token conversion function and are fundamentally unauditable.
The recommendation is to request an explicit pricing function before procurement and hard-code it on your self-built gateway side:
cost = in_tokens/1e6 * P_in+ out_tokens/1e6 * P_out+ cache_read_tokens/1e6 * P_cache_read+ cache_write_tokens/1e6 * P_cache_write+ tool_calls * P_tool+ time cost of failed retries and queue waiting
The most ambiguous dimension is cache. “Includes input, output, and cache” could mean cache reads are free, or that cache writes are not billed separately. The two interpretations have vastly different cost impacts for long-context, multi-turn scenarios. The engineering approach is to construct two control groups—one with high cache hits and one with zero cache hits—using a fixed prompt, then back-calculate the actual unit price rather than trusting verbal claims.
3. Account Pool Mechanics: Scheduling Risks and Governance
An account pool is a resource pool that a provider forms from multiple accounts or keys and exposes through a unified entry point using round-robin, weighting, or preemption strategies. Its legitimate purpose is to improve availability and throughput, but it introduces three risks:
- Service tier drift: different accounts may sit in different rate-limit tiers or different time-of-day price tiers, so the same user request may land in a peak-hour high-price pool or a lower-spec pool.
- Quota and ban coupling: when one account in the pool triggers risk controls, it shows up as random failures and long-tail latency.
- Missing observability: request logs do not distinguish the actual serving account, making faults impossible to locate.
The governance approach is to add “scheduling observability + tier labels” at the gateway:
# Example gateway request headers: require upstream to return service tier and serving identifier (desensitized)headers:X-SKU-Tier: standard # service tier labelX-Pool-Node: hashed-id # desensitized hash of pool nodeX-RateLimit-Remaining: 0 # remaining quotaX-Model-Fingerprint: sha256 # model fingerprint
Pair this with local circuit breaking and fallback: when remaining quota hits zero or the error rate exceeds a threshold, automatically switch to a backup channel and log the event, so upstream scheduling jitter is not mistaken for a defect in your own code.
4. Multiplier Auditing: Turning Discounts into a Verifiable Bill
In a business context, a “multiplier” often means the discount factor relative to the official price. In a technical context, it should be understood as a billing weight. The core of auditing a multiplier is not trusting the discount number but reconstructing the bill.
An executable four-step method:
- Step 1, build a baseline set: prepare fixed samples covering four workload types—short input with long output, long input with short output, high cache hit, and tool-call-heavy.
- Step 2, dual-run comparison: run the same samples through both the official channel and the relay channel, recording token usage per dimension.
- Step 3, regress unit prices: fit actual per-dimension unit prices using least squares and compare them item by item against the quote sheet.
- Step 4, continuous monitoring: feed the deviation rate into monitoring and alerting; a deviation beyond the agreed threshold triggers a review.
Illustrative reconciliation logic:
def reconcile(baseline, relay, tolerance=0.08):# baseline/relay hold token usage and charged amount per dimensionfor dim in ("in", "out", "cache_read", "cache_write"):p_base = baseline["cost"][dim] / max(baseline["tokens"][dim], 1)p_relay = relay["cost"][dim] / max(relay["tokens"][dim], 1)drift = abs(p_relay - p_base) / max(p_base, 1e-9)if drift > tolerance:return {"dim": dim, "drift": drift, "action": "review"}return {"action": "pass"}
5. Model Substitution: Detecting Specification Mismatches with Fingerprints and Behavioral Probes
“Model substitution” means a request declares a certain model specification but is actually served by a smaller-parameter, quantized, or different version. Detection has two layers.
Structural layer: model fingerprint. Send requests with a fixed prompt and fixed decoding parameters (temperature, top_p, max output length, and random seed if supported), normalize and hash the output to form a fingerprint baseline, then re-test periodically; fingerprint drift triggers an alert.
fingerprint = sha256( normalize(prompt) + params + output )
Behavioral layer: capability probes. Design a set of discriminating tasks covering long-context retrieval, multi-step reasoning, structured output (JSON mode compliance rate), multilingual and code generation, and track pass rates and latency distributions. When a specification is swapped, it typically shows up as a sharp drop in long-context accuracy, lower structured-output compliance, and shifts in first-token latency and throughput distribution.
It is important to note that sampling randomness means outputs will not be fully identical, so decisions should be based on statistical significance rather than a single comparison. Also fix decoding parameters and control concurrency and time of day to reduce irrelevant variables.
6. Building a Controllable Gateway: Assembling the “Fair Scale” with Common Baidu AI Cloud Capabilities
If an organization wants to internalize the “fair scale” as infrastructure, it can be assembled on Baidu AI Cloud using combinations of general product categories, all using industry-standard capabilities and no proprietary interfaces:
- Unified access layer: a container platform hosts a stateless gateway handling key custody, routing, and rate limiting.
- Metering and billing: a message queue buffers usage events, streaming them into object storage and a logging service to form tamper-resistant usage records.
- Observability: a monitoring and alerting system sets threshold alerts for deviation rate, error rate, and long-tail latency.
- Data and models: vector retrieval capabilities support caching and semantic deduplication, and a model service platform hosts self-built baselines and evaluation tasks.
The core data structure should retain full-dimension usage and fingerprints:
{"request_id": "uuid","model_declared": "model-a","model_fingerprint": "sha256:...","tier": "standard","tokens": {"in": 0, "out": 0, "cache_read": 0, "cache_write": 0},"latency_ms": {"first_token": 0, "total": 0},"cost": {"in": 0.0, "out": 0.0, "cache_read": 0.0, "cache_write": 0.0}}
7. Implementation Checklist
- Request a written pricing function before procurement, specifying unit prices for input, output, cache read/write, and tool calls.
- Dual-run the four baseline workloads, regress the real unit prices, and retain the evidence.
- Require service tier labels and desensitized pool-node identifiers; treat their absence as unmanageable.
- Establish a model fingerprint baseline and a capability probe set, and re-test periodically.
- Feed deviation rate, compliance rate, and long-tail latency into monitoring, alerting, and automatic fallback.
- Define metering definitions, reconciliation cycles, and deviation-handling mechanisms in the contract.
Only when metering, scheduling, and consistency are turned into verifiable data can a low price be a genuine technical dividend rather than a hidden overdraft on the bill and on quality.
