How to Choose a Free Primary Model: A Practical Guide for AI Agent Frameworks

    This article examines how to select a free primary model for AI agent systems when usage falls under a limited-time free quota or subsidy period. It clarifies billing details, provides a model selection checklist, explains prefix cache hit-rate calculation and invalidation scenarios with a runnable example, and outlines token budget allocation, rate-limiting thresholds, and observability metrics for cost control.

    What Is a Free Primary Model? Clarify Billing and Validity First

    This article starts from an industry pattern in which an open-source AI agent framework designates a publicly reported trillion-parameter MoE model as its first free primary model. Setting aside the specific product, we abstract this into a general technical question: when API calls are covered by a limited-time free quota or subsidy period, how should the architecture and engineering focus of an agent system shift?

    First, correct a common misreading: a free quota does not mean the inference unit price is permanently zero. It is usually a limited-time free quota or subsidy period, and the unit price is not zero in the long run. The billing model must be examined on at least four points: whether input and output tokens are priced separately, how cache hits are billed, whether the free quota covers very long contexts and tool calls, and the validity period plus the unit price after the quota is exhausted. Put these four items into your selection table before discussing architecture.

    How to Choose a Primary Model? Selection Checklist

    Check Item Key Question Red Flag
    Billing model How are input, output, and cache calculated Only a “free” label
    Validity period When does the subsidy end, and what is the overage price No announcement or email notice
    Architecture Is it MoE, and what is the ratio of activated to total parameters Only total parameters are advertised
    Context Is long context reliably available Long text is truncated or errors out
    Cache Is native prefix caching supported No price reduction after a hit
    Rate limits QPS/TPM thresholds and burst policy No 429 or Retry-After
    Data Retention period and whether data is used for training Vague terms

    Conclusion first: in scenarios with long contexts and stable prefixes, MoE, very long context, and native caching fit well with a division of labor between a local gateway and cloud inference. If prefixes change frequently and requests are short and varied, the advantages of this combination weaken significantly or may not hold at all.

    How to Design Context Caching? Hit-Rate Formula and Invalidation Scenarios

    Fix the hit-rate metric as follows: hit rate = input tokens served from cache ÷ total input tokens. Counting by request and counting by token yield different results, so the dashboard should record both metrics and annotate the statistical window (e.g., 5 minutes).

    Common invalidation scenarios: inserting a timestamp or random ID into the prompt prefix; concatenating tool return content at the front; multiple tenants sharing a prefix and causing cross-contamination; mismatch between the cache TTL and the gateway. The corresponding engineering actions are to place stable content at the front and volatile content at the back, and to apply hash validation to the prefix.

    Minimal runnable example (environment: Python 3.10+, Ubuntu 22.04, dependency openai==1.51.0; only demonstrates gateway and cache counting logic):

    1. # pip install openai==1.51.0
    2. from openai import OpenAI
    3. client = OpenAI(base_url="http://localhost:8080/v1", api_key="local")
    4. stable_prefix = "You are a rigorous assistant. Here is the fixed knowledge base...\n"
    5. def ask(q: str) -> str:
    6. r = client.chat.completions.create(
    7. model="local-gateway",
    8. messages=[{"role": "system", "content": stable_prefix},
    9. {"role": "user", "content": q}],
    10. temperature=0.2,
    11. )
    12. print(r.usage) # Expected output: a usage object containing prompt_tokens/completion_tokens
    13. return r.choices[0].message.content
    14. print(ask("Summarize the key points above"))

    Expected output: the terminal prints one usage object line and returns a summary text; if the print is empty or a connection error occurs, check the gateway port and model name first.

    How to Apply Rate Limiting and Fallback? Token Budget and Threshold Examples

    Token budget allocation example: per-request limit of 8k input + 2k output; daily budget of 2 million tokens, with 70% for the primary model, 20% for a lightweight model, and 10% reserved for bursts. Rate-limit threshold configuration example: QPS 20, TPM 150,000; on 429, apply exponential backoff according to Retry-After; switch to the lightweight model after 3 consecutive failures, and freeze that tenant for 60 seconds.

    How to Observe Costs? Dashboard Metrics and Common Mistakes

    The dashboard should include at least: cache hit rate (both metrics), average input/output tokens, cost per request (converted using the current billing model), 429 ratio, fallback count, end-to-end latency P95, and task success rate.

    Common mistakes with a free primary model: treating the subsidy as a long-term cost assumption; unstable prefixes causing cache invalidation; no fallback path; not recording billing model changes. Risk warning: subsidy termination, rate-limit fallback, and changes to data retention and compliance terms must all be evaluated in advance. The alternative is to maintain dual channels with a lightweight model and a local small model, and subscribe to price and terms change notifications.