Mixture-of-Experts Model Selection Guide: Capabilities, Cost, and Evaluation

    This article explains how to evaluate large models for agentic workloads that must reason, write code, and call tools. It covers the three capability dimensions to test, how MoE architecture affects compute and latency, how to calculate request and per-successful-task costs, and three access paths—API integration, web testing, and private or local deployment—along with privacy and compliance considerations.

    From Chatting to Getting Work Done

    Early large language models were mainly used for copywriting, question answering, and summarization. Once a task is split into multiple steps—for example, clarifying requirements, writing code, and then running and debugging it—models often fail in intermediate steps, and their conclusions no longer line up.

    Newer models train and orchestrate reasoning, coding, and tool calling within a single capability system. A model can break down a problem, write runnable code, and use function calls to query a database, send a notification, or write a file. This combination is the technical foundation of current agentic applications.

    When selecting a model, teams need to judge performance across three capability areas:

    • Reasoning depth: When facing a multi-step problem, can the model break it down step by step and correct itself when an intermediate result is wrong? The measurable metric is multi-step reasoning accuracy.
    • Code quality: Can the generated code run directly, and does it follow engineering constraints in the context, such as dependency versions, naming conventions, and interface definitions? The measurable metric is code pass rate.
    • End-to-end task completion: Can the model turn a natural-language requirement into correct tool calls and continue advancing based on execution results? The measurable metrics are tool-call accuracy and end-to-end task completion rate.

    The exact calculation methods for these metrics are covered in the evaluation methodology.

    Why MoE Can Save Compute—and When It Actually Does

    Mixture-of-Experts (MoE) is a common architecture supporting these capabilities. A dense model makes all parameters participate in computation on every inference. An MoE model contains multiple groups of “expert” subnetworks. A router selects a small number of experts for each token based on the input, and only the outputs of those experts are computed.

    The two can be compared to two kinds of teams. A dense model is like a generalist employee who must handle the entire task regardless of difficulty. An MoE model is like a team with clear division of labor, where a dispatcher assigns people to roles based on the task type.

    In a single inference, the forward computation of the selected expert subnetworks is roughly equal to their activated parameter count. End-to-end latency and cost must also account for attention layers, routing computation, multi-GPU communication, and batch utilization. The following table lists the main differences between the two model types:

    Dimension Dense Model Mixture-of-Experts Model
    Single forward computation Roughly equivalent to the number of parameters involved in computation Related to the parameter count of activated experts; usually lower at the same total parameter count
    Memory footprint Loaded according to total parameters Usually must load all experts, increasing memory pressure
    Multi-GPU communication Mainly conventional parallelism Additional communication overhead from routing and data movement when experts are distributed across GPUs
    Batch sensitivity Lower Low expert utilization with very small batches; better load balance with larger batches
    Latency characteristics Relatively stable Tail latency may rise when requests concentrate on a few popular experts

    Therefore, MoE may reduce latency and unit cost only when routing is relatively balanced, communication overhead is controllable, and request batches are appropriate. Before selection, teams should rely on measured data from the target scenario rather than inferring benefits from architecture characteristics alone.

    Vendors usually offer flagship and lightweight tiers. The flagship tier suits complex tasks such as architecture-level code refactoring and deep reasoning. The lightweight tier has fewer parameters and suits high-concurrency routine calls. For capability and price gaps between the two, refer to vendor-published model cards and price lists.

    How to Calculate Cost: Use Formulas, Not Rule-of-Thumb Discounts

    During model selection, teams often see claims such as “an order-of-magnitude cost reduction” or “halving costs.” These numbers depend on cache hit rate, input-to-output ratio, and actual unit prices, so teams cannot apply them directly. A more reliable approach is to calculate costs with formulas.

    The basic formula is as follows, with unit prices in yuan per million tokens:

    Cost per request (yuan) = input tokens ÷ 1,000,000 × input unit price + output tokens ÷ 1,000,000 × output unit price

    For example, assume a business has an average daily input of 5 million tokens and an average daily output of 1 million tokens. The input unit price is a yuan per million tokens, and the output unit price is b yuan per million tokens. The daily cost is then 5a + b yuan. Calculated over 30 days, the monthly cost is approximately 150a + 30b yuan.

    If the vendor offers a cache discount for repeated prefixes, such as system prompts and code repository descriptions, input cost should be split into two parts:

    Input cost (yuan) = uncached input tokens ÷ 1,000,000 × input unit price + cached input tokens ÷ 1,000,000 × cache unit price

    The higher the cache hit rate, the more noticeable the savings. The hit rate depends on whether the request prefix is stable. Frequent changes to the system prompt invalidate the cache. Whether cache writes are charged separately should also be confirmed against the specific price documentation.

    Teams should also calculate the cost per successful task:

    Cost per successful task (yuan) = total cost in the period (including retries) ÷ number of successfully completed tasks

    Common measurement mistakes include:

    • Calculating only input cost and ignoring output unit price.
    • Ignoring retries. Retries after timeouts or failures are billed again.
    • Ignoring cache invalidation. Frequent prefix changes reduce the hit rate.
    • Estimating with average token counts. A small number of very long requests can significantly raise overall cost; use percentile statistics.
    • Ignoring how reasoning content is billed. Some models count the thinking process as output tokens, so verify against billing details.

    Three Access Paths

    Path 1: API Integration into Business Systems

    This suits teams with engineering capacity. Most cloud platforms provide interfaces compatible with common SDK protocols, which can be embedded directly into existing development workflows.

    The following example uses Python and the official openai SDK. Before running it, meet the following conditions:

    • Python 3.9 or later.
    • Pin the SDK version in requirements.txt, for example openai>=1.0,<2.0, to avoid interface behavior changes after upgrades.
    • Set MODEL_API_KEY in an environment variable. Do not write the key into code or commit it to a code repository.
    • Set MODEL_BASE_URL and MODEL_NAME according to the vendor documentation.
    1. import os
    2. from openai import OpenAI, APIError, APITimeoutError
    3. client = OpenAI(
    4. api_key=os.environ["MODEL_API_KEY"],
    5. base_url=os.environ.get("MODEL_BASE_URL", "https://your-model-endpoint/v1"),
    6. timeout=60.0,
    7. max_retries=2, # Retries inside the SDK are also billed and must be included in cost tracking.
    8. )
    9. def stream_refactor(prompt: str) -> None:
    10. try:
    11. stream = client.chat.completions.create(
    12. model=os.environ.get("MODEL_NAME", "model-name"),
    13. messages=[
    14. {"role": "system", "content": "You are a senior engineer assistant"},
    15. {"role": "user", "content": prompt},
    16. ],
    17. stream=True,
    18. )
    19. try:
    20. for chunk in stream:
    21. if chunk.choices and chunk.choices[0].delta.content:
    22. print(chunk.choices[0].delta.content, end="", flush=True)
    23. finally:
    24. stream.close()
    25. except APITimeoutError:
    26. print("Request timed out. Check the network connection or increase the timeout value.")
    27. except APIError as e:
    28. print(f"API call failed: {e}")
    29. if __name__ == "__main__":
    30. stream_refactor("Refactor the following function and add unit tests")

    The code sets a timeout limit, closes the stream after streaming output ends, and provides messages for common exceptions. Before launch, teams should also add logging, alerting, and request tracing.

    Privacy and compliance reminders

    • Do not write API keys into code, logs, or screenshots. If a key leaks, rotate it in the console immediately.
    • Third-party APIs receive prompt content. Before sending, remove personal data such as customer identity information, account numbers, and phone numbers. Keys in source code, internal domains, and unpublished algorithms should also not be sent directly; desensitize them or replace them with placeholders first.
    • Logs should record only request ID, latency, token count, and error code, not full prompts and responses. If content must be stored, desensitize it first and set a retention period.
    • Retries are billed again and may repeat tool calls with side effects, such as sending duplicate notifications or writing duplicate files. The business side should generate a unique request ID for each task, query whether the task has already been executed before tool calls, and limit the number of retries.
    • Trigger an alert when the failure rate or per-request cost exceeds a threshold.
    • Confirm the provider’s data retention and training-use policies, subject to the contract and official terms.

    Path 2: Web Interface Testing

    Teams can test a model in a chat interface without writing code, which suits early research and initial effect screening. The web interface’s features, context length, and call frequency are subject to the page documentation. It is not suitable for batch evaluation, and keys or unredacted customer data should not be pasted into it.

    Path 3: Private or Local Deployment

    This suits scenarios where data cannot leave the intranet and compliance requirements are high. MoE models still need to load all experts, so memory capacity and multi-GPU interconnect are the main barriers. Before deployment, estimate GPU count, memory, and target concurrency, and use the inference framework’s official documentation to check whether it supports the selected model’s MoE structure. Model updates, operations, and security hardening are the team’s responsibility, and their costs should be included in total cost of ownership.

    How to Choose

    Teams with engineering capacity that need to embed the model into business systems should start with the API integration path described above.