LLM API Selection: A Six-Dimension Evaluation Framework and Routing Practice

    This article explains how to choose large language model APIs for production use. It covers defining task boundaries, a six-dimension evaluation framework for cost and caching, context and multimodality, reasoning and coding, Chinese-language capability and compliance, latency and stability, and replaceability and tooling. It also provides a model-category comparison, a scoring template, and a hybrid routing and fallback pattern. The core recommendation is to test candidates on your own evaluation sets and route different tasks to a portfolio of models rather than relying on leaderboards or unit prices alone.

    Conclusion First

    Model selection should not rely only on leaderboards or unit prices. A better approach is to break requirements down by business task, test candidate models on your own evaluation set, and then use routing to assign different tasks to different models. No single model covers every scenario, so the result should be a set of models divided by task, not one model for everything.

    1. Define Boundaries Before Selection

    Before comparing models, confirm four things:

    • Task types: Intelligent Q&A, agent tool calling, RAG retrieval Q&A, code generation, and long-document analysis each have different capability requirements.
    • Traffic and budget: Daily call volume, average input and output length, and monthly budget ceiling.
    • Latency requirements: End-user conversations usually need fast first-token response, while background batch processing can tolerate longer runtimes.
    • Data constraints: Whether data can cross borders, whether personal information or trade secrets are involved, and what logging and retention requirements apply.

    When boundaries are unclear, later evaluation easily turns into arguments about leaderboards.

    2. Six-Dimension Evaluation Framework

    The following six dimensions cover the main factors that affect production model selection.

    1. Price and Caching

    Looking only at the price per million tokens can easily mislead cost estimates. A more reasonable measure is cost per task:

    Cost per task = input tokens × input price + output tokens × output price − discount for cache hits

    Most vendors charge more for output than input, but the gap varies by vendor and model. Use each vendor’s billing page as the source of truth.

    The benefit of caching depends on the hit rate. In RAG and long-context conversations, system prompts and background materials often appear repeatedly. If the platform supports context caching, measure the hit rate using real traffic and estimate savings from that. Without a measured hit rate, do not directly adopt the discount ratio advertised by the vendor.

    2. Context Window and Multimodality

    Nominal window size and effective window size are two different things. The nominal window is the maximum length allowed by the API. The effective window is the length over which the model can actually use information reliably. A test method is:

    • Bury a known fact at the 10%, 50%, and 90% positions in a long text, with 20 questions for each length.
    • Record accuracy at each position and identify the length at which accuracy clearly drops.
    • Use the longest input actually used by the business as the basis, not the nominal value.

    Evaluate multimodal capability with real samples. For example, prepare 50 scanned financial statements, measure key-field extraction accuracy, and record issues such as table misalignment and unit errors.

    3. Reasoning, Agents, and Coding

    Agent scenarios mainly require three types of metrics:

    • Instruction following: Require the model to output a specified JSON structure and measure the valid-structure rate.
    • Function calling: Prepare 200 samples that require tool calls and measure the proportion where both tool names and parameters are correct.
    • Multi-step tasks: Measure final task completion rate, not only whether individual steps sound fluent.

    Evaluate coding scenarios with real tasks from a repository, such as fixing a known defect or refactoring a module across files, then run unit tests and measure the pass rate. Casual chat experience cannot reflect these capabilities.

    4. Chinese-Language Capability and Compliance

    Chinese-language evaluation should cover industry terminology, policy text comprehension, colloquial expressions, and abbreviations, with correct answers labeled manually by business staff.

    Compliance checks include data storage region, log retention period, whether a data processing agreement is signed, and whether a dedicated line or private deployment is supported. These terms need confirmation from legal or compliance staff. Engineering teams should not judge them by experience alone.

    5. Latency and Stability

    Measure latency and stability with the following metrics:

    • Time to first token (TTFT)
    • P95 latency of the overall response
    • Output speed (tokens per second)
    • Error rate and rate limiting (requests per minute, tokens per minute)
    • Vendor service-level agreement (SLA) terms

    Measure in the region where the business is deployed and cover different times of day over one week. Data from a single measurement is not useful.

    6. Vendor Replaceability and Tooling Ecosystem

    If a business is deeply tied to one vendor’s proprietary interface, switching costs later will be high. Reduce lock-in risk by:

    • Adding an adapter layer between business code and the model interface.
    • Decoupling prompts and evaluation sets from a specific vendor, and rerunning evaluation after switching models.
    • Checking whether the platform’s SDK, logging, and monitoring tools are mature and whether they integrate with existing systems.

    3. Comparison of Mainstream Model Categories

    The table below gives a qualitative comparison by model category. Specific parameters such as window length, price, and available regions change quickly. Use each vendor’s latest documentation and measured results as the basis.

    Category Typical strengths Issues to watch Better-fit scenarios
    Overseas flagship models Mature English ecosystem, strong complex reasoning and coding performance, rich developer tooling High cross-border network latency, cross-border data transfer compliance review, possible changes in pricing and policy Offline R&D testing, internal coding assistance, English content processing
    China-based cloud platform models Strong Chinese-language corpus coverage, clear local compliance path in China, lower network latency in mainland China, platform offers fine-tuning, retrieval augmentation, security review, and private deployment Some high-difficulty reasoning or coding tasks need testing; do not assume overall leadership by default Customer service for users in China, document processing, Chinese-language RAG, businesses with high compliance requirements
    Lightweight economical models Low latency, low unit price, suitable for high concurrency Higher error rate on complex tasks, limited long-text understanding Intent recognition, simple Q&A, content classification, pre-routing decisions

    Each category has its applicable boundaries. During selection, put candidate models into your own test set for comparison instead of directly applying the conclusions in the table.

    4. Scoring Template for Model Selection

    The table below is a scoring template that can be modified directly. Weights need to be adjusted according to business priorities.

    Dimension Reference weight Test set Example pass threshold Retest cycle
    Price and caching 15% Real traffic sample Cost per task below budget line Monthly
    Context and multimodality 15% Long-text and scanned-document samples Accuracy at the longest business input not below 95% of baseline Quarterly
    Reasoning and coding 25% Tool-calling and repository tasks Task completion rate not below human baseline Monthly
    Chinese and compliance 20% Industry terms and policy texts Human score meets the bar; all compliance terms confirmed Semiannual
    Latency and stability 15% One week of online probe data P95 latency and error rate meet SLA Weekly
    Replaceability 10% Adapter switch drill No significant drop in evaluation after switching Quarterly

    When scoring, first give each dimension a pass or fail, then calculate the weighted score. If any compliance item fails, exclude that candidate directly and do not include it in weighting.

    5. Hybrid Routing and Fallback

    Most production systems route requests to different models: simple questions go to lightweight models, complex questions go to stronger models, and when the primary route fails, the system switches to a backup route. The following code illustrates this structure.

    1. import logging
    2. import os
    3. import time
    4. import requests
    5. logger = logging.getLogger("model_router")
    6. TOKEN_URL = "https://aip.baidubce.com/oauth/2.0/token"
    7. class ModelRouter:
    8. def __init__(self, timeout=15, max_retries=2):
    9. # Read credentials only from environment variables