How to Choose a Primary LLM and Build a Full-Stack Workflow: A Practical Guide

    This article explains why choosing a large language model based on hype tends to fail in production, and offers a vendor-neutral framework for selecting a primary model. It covers a four-dimension evaluation model (task fit, cost per successful task, engineering usability, and replaceability), credential and quota handling, multi-model switching, and context rules for AI coding tools. A side-by-side case study of building an AI riddle game illustrates how to compare candidates, followed by an automation pattern for scheduled data collection and a checklist for controlling cost and stability. Readers get a reusable selection method and engineering practices that keep model switching to a configuration change.

    1. Why “Following the Hype” Is Failing

    Large model releases are accelerating, with flagship models launching one after another both internationally and in China. As agent frameworks gain traction, API calls have shifted from optional to essential. In this climate, many teams pick models by asking “which is newest?” or “which is most talked about?” Yet the core requirement in real production environments is remarkably consistent: stable output per unit of cost.

    Treating model selection as trend-chasing usually leads to three problems. First, capability redundancy: the advantages of flagship models in complex reasoning are nearly irrelevant for high-volume formatting and extraction tasks. Second, runaway cost: pay-as-you-go billing combined with frequent calls makes the bill grow far faster than business returns. Third, migration difficulty: when business code is tightly coupled to one vendor’s interface, switching models means rewriting a layer.

    A more sensible approach is to treat the primary model as infrastructure: isolate vendor differences behind a unified abstraction layer, then benchmark candidates on real tasks. This article does not recommend any specific product. Instead, it provides a transferable set of criteria and engineering practices.

    2. A Four-Dimension Framework for Evaluating a Primary Model

    2.1 Task Fit

    Start by measuring the real call distribution: how much is structured output, code generation, long-document summarization, and multi-turn dialogue. If more than 80% is code completion and script generation, prioritize code comprehension and instruction following over general leaderboard scores.

    2.2 Cost Structure

    Do not look at unit price alone. Calculate the cost per successfully completed task. A simplified formula:

    1. cost per task = (input tokens + output tokens) × unit price ÷ first-pass rate

    The lower the first-pass rate, the higher the hidden cost of rework. A cheap model that needs repeated retries is actually more expensive.

    2.3 Engineering Usability

    This includes streaming output, concurrency limits, timeout and retry semantics, clear error codes, and compatibility with mainstream tool-chain calling protocols. A compatible interface significantly lowers integration cost.

    2.4 Replaceability

    This is the most overlooked dimension. The business layer should call models through an adapter, converging vendor differences into a single configuration point.

    1. # Example: a unified adapter that hides vendor differences
    2. class LLMClient:
    3. def __init__(self, provider, api_key, model):
    4. self.provider = provider
    5. self.api_key = api_key
    6. self.model = model
    7. def chat(self, messages, temperature=0.2):
    8. # Request differences across providers converge here
    9. return self._dispatch(messages, temperature)

    3. Connecting the Model to an AI Coding Tool Chain

    3.1 Credentials and Quota Management

    Create an API key in the provider’s open platform, and choose a subscription or pay-as-you-go plan based on estimated call volume. At the entry stage, start with the smallest quota package to validate results. Distinguish text/code quota from multimodal quota for images and speech to avoid misjudging what is available. Keys must be placed in environment variables or a local configuration file and added to the version-control ignore list:

    1. export LLM_API_KEY="your-key-here"
    2. export LLM_BASE_URL="your-endpoint"
    3. export LLM_MODEL="your-model-name"

    3.2 Switching Between Models

    Real development often needs a “primary model plus a backup model.” A graphical configuration switcher is recommended to manage multiple profiles and switch among coding assistants, terminal agents, and code review tools with one action, avoiding manual edits that introduce errors. After switching, verify connectivity with a minimal task, such as asking the model to output a fixed-format JSON.

    3.3 Context and Rule Constraints

    Maintain a rules file in the project that states the tech stack, directory conventions, and checks that must run before a commit. The model reads this file on every generation, which noticeably improves output consistency.

    4. Benchmark Case: Building an “AI Riddle Game” from Scratch

    Task: build a riddle web app with a separated frontend and backend, where the AI poses riddles, the user answers, and the model judges and returns hints. The same requirement was given to two primary-model candidates to compare first-pass rate and rework volume.

    4.1 Requirement Breakdown

    • Backend: riddle generation endpoint, answer validation endpoint, session state storage;
    • Frontend: input area, hint area, history, error feedback;
    • Data: persist sessions and rounds to enable later analysis of difficulty distribution.

    4.2 Define the API Contract First

    Having the model produce the interface definition before the implementation greatly reduces rework:

    1. {
    2. "POST /api/riddle/start": { "req": {"difficulty": "easy"}, "resp": {"sessionId": "s1", "question": "..."} },
    3. "POST /api/riddle/guess": { "req": {"sessionId": "s1", "guess": "..."}, "resp": {"correct": false, "hint": "..."} }
    4. }

    4.3 Prompt and Judging Logic

    The judging step must return structured output only, so natural language does not break frontend parsing:

    1. You are a riddle judge. Output JSON only:
    2. {"correct": boolean, "hint": "a hint of no more than 20 characters", "finished": boolean}
    3. Do not output any character other than JSON.

    Add server-side validation: if parsing fails, retry once; if it still fails, fall back to keyword matching to preserve availability.

    4.4 Benchmark Dimensions

    Record four metrics: ratio of first-generation runs that work, API contract consistency rate, number of frontend style reworks, and average cost per round. In practice, the difference is often not “can it write code” but “does it strictly follow constraints.”

    5. Automation for Efficiency: From Scripts to Long-Term Data

    The device inspection scenario mentioned in the original text is essentially “multi-source data collection plus scheduled execution plus result archiving.” Abstracted into a general pattern:

    1. Collection layer: prefer standard interfaces; when no interface exists, use controlled simulated login with encrypted credentials and failure alerts;
    2. Scheduling layer: scheduled jobs with idempotent design to avoid duplicate writes;
    3. Output layer: console visualization plus tabular archiving to form traceable long-term data;
    4. Observability layer: connect logging and monitoring with automatic alerts on anomalies.

    When involving the model in script generation, require it to add exception handling, retry limits, and logging; otherwise the gap between “it runs” and “it is operable” is large.

    6. Cost and Stability Control Checklist

    • Set a call limit per 5 hours to prevent runaway debugging;
    • Cache repeated requests and lower the temperature for extraction tasks;
    • Trim and summarize long context to control input tokens;
    • Build a fallback path that switches to the backup model automatically when the primary fails;
    • Review first-pass rate and cost per task weekly, and adjust the primary model dynamically.

    7. Conclusion

    Model leaderboards change every week; what endures is the evaluation framework and engineering standards. Determine requirements from the real task distribution, preserve room to switch through a unified adapter, then use structured constraints and observability to turn “it works” into “it runs long term.” This method depends on no specific vendor; switching models requires changing a single line of configuration. If you already use relevant Baidu AI Cloud products, the same abstraction approach can bring model calls, logging, and monitoring into your existing architecture for consistency.