A Practical Guide to AI Application Development in the Era of Accessible Large Models

    This article presents an engineering guide for building AI applications once large model capabilities are widely available through APIs. It explains a shared five-layer architecture, model selection and routing, context engineering with token budgeting, hybrid retrieval and reranking, tool calling with constrained agent orchestration, evaluation and observability, cost governance, security and compliance, common pitfalls, and a four-week rollout plan. Readers will learn a unified methodology that applies across AI browsers, AI search, assistants, agents, and chatbots without rebuilding the stack for each use case.

    1. From Accessible to Usable: The Engineering Shift

    Once large model capabilities became broadly available through APIs, the focus of AI application innovation shifted from training a model to orchestrating a system. AI browsers, AI search, AI assistants, agents, and chatbots may look different on the surface, but they share the same engineering skeleton: a model inference layer, a context construction layer, a tool and data integration layer, an interaction and orchestration layer, and a governance and observability layer. Understanding this allows developers to apply one methodology across product forms instead of reinventing the wheel for every scenario.

    Accessibility brings three immediate changes. First, the cost of experimentation drops, and a prototype can be built in days. Second, competition moves up to data quality and interaction design. Third, stability and compliance become release requirements. Cloud providers such as Baidu AI Cloud typically package large model capabilities, retrieval augmentation, object storage, message queues, container platforms, logging, and monitoring and alerting as general cloud product categories. Developers can assemble what they need on demand and avoid being locked into a single implementation.

    2. Reference Architecture: Five Layers and Their Responsibilities

    1. Access layer: handles session management, authentication, rate limiting, and multi-client adaptation. Decouple the transport protocol from business logic.
    2. Orchestration layer: handles task decomposition, flow control, and multi-turn state management. This is where agents and chatbots differentiate.
    3. Context layer: handles prompt templates, memory, fusion of retrieval results, and token budget allocation.
    4. Capability layer: wraps model inference, vector retrieval, keyword retrieval, structured queries, and external tool calls.
    5. Governance layer: covers logging, metrics, tracing, content safety, cost attribution, and canary releases.

    The key benefit of layering is replaceability. When a capability vendor or model version changes, you only replace the capability layer implementation while orchestration and interaction stay unchanged.

    1. User / Client
    2. ↓
    3. Access Layer (auth / rate limit / session)
    4. ↓
    5. Orchestration Layer (intent / task graph / state machine)
    6. ↓ ↘
    7. Context Layer Capability Layer (inference / retrieval / tools)
    8. ↓ ↙
    9. Governance Layer (logs / metrics / safety / cost)

    3. Model Selection and Routing: Avoid Lock-In

    Evaluate candidates along four dimensions: quality, latency, context window, and unit cost. A more robust practice is multi-model routing: simple Q&A goes to a small or low-latency configuration, complex reasoning goes to a stronger configuration, and long documents go to a large context window. Routing can be implemented with an intent classifier or a rule table, and you should keep a manual override switch.

    1. def route(task):
    2. if task.kind in ("chitchat", "faq"):
    3. return "light" # low-latency configuration
    4. if task.tokens > 24000:
    5. return "long_ctx" # large context configuration
    6. return "strong" # strong reasoning configuration

    Do not switch models based on intuition without an evaluation set. Build a small but representative evaluation set first, then measure the benefit of routing.

    4. Context Engineering: Prompts, Memory, and Token Budget

    Context quality sets the ceiling on output quality. Split context into four segments and allocate budget explicitly: system instructions (constraints and role), long-term memory (user preferences and facts), retrieved snippets (with source and timestamp), and the current conversation (summary of recent turns). An example allocation is 10% system, 15% memory, 50% retrieval, and 25% conversation, with runtime adjustment allowed.

    Memory falls into two types: factual memory is written to structured storage, and preference memory is updated as a rolling summary. Avoid stuffing the entire raw history into the context, which wastes budget and introduces noise.

    1. [System] You are a rigorous technical assistant; state uncertainty explicitly.
    2. [Memory] User preference: lead with the conclusion, then the key points.
    3. [Retrieval] Snippet #12 (source: internal doc, 2026-01): ...
    4. [Conversation] Summary: the user is debugging low retrieval recall ...

    5. Retrieval Augmentation: Hybrid Search and Reranking

    For AI search and knowledge assistants, the bottleneck is usually recall rather than generation. The recommended approach is hybrid retrieval combining keyword search and vector search, followed by a reranking model for fine-grained ordering, then deduplication and snippet assembly. For chunking, splitting on semantic boundaries works better than fixed character counts. Keep the title path and last-updated time on each chunk so sources can be cited during generation.

    Measure retrieval with three metrics: recall hit rate, snippet relevance, and the proportion of answers that are traceable to sources. If recall hit rate is below expectations, check chunking and index update pipelines first rather than editing the prompt.

    6. Tool Calling and Agent Orchestration

    The essential difference between an agent and a chatbot is whether it autonomously decides and calls tools. In practice, use a constrained state machine rather than fully free-form planning to reduce uncontrolled risk:

    1. Define the tool list and constrain inputs with a JSON Schema.
    2. Set a timeout, retries, and an idempotency key for each tool.
    3. Add a second confirmation and a rollback plan for write operations.
    4. Cap the number of tool calls per session and hand off to a human when exceeded.
    1. {
    2. "tool": "query_order",
    3. "arguments": {"order_id": "A1024", "need_detail": true},
    4. "idempotency_key": "sess-77-step3"
    5. }

    7. Evaluation, Observability, and Cost Governance

    Before release, build three levels of evaluation: unit level (prompts and parsing), scenario level (task completion rate), and regression level (version comparison). In production, use logging and monitoring with alerting as the foundation, and collect time to first token, overall latency, tool success rate, refusal rate, and human takeover rate. For cost governance, attribute token consumption by business line, set quotas, and define degradation strategies, such as automatically switching to a low-latency configuration during peak hours or preferring cache hits.

    Roll out canary releases by traffic percentage, and keep the ability to roll back to the previous orchestration configuration with one action.

    8. Security and Compliance

    Apply bidirectional filtering on both input and output, and redact sensitive data before it enters the model. Follow the principle of least privilege, and keep tool credentials short-lived. Retain auditable logs across the full chain, but avoid recording unnecessary raw sensitive fields. Labeling generated content with sources and uncertainty is an effective way to reduce the risk of misleading output.

    9. Common Pitfalls

    • Tuning prompts only, without an evaluation set, so quality cannot be regression-tested.
    • Chasing fully autonomous agents without step limits or permission constraints.
    • Evaluating retrieval and generation separately, which makes root-cause analysis difficult.
    • No cost attribution, which prevents capacity and budget planning.

    10. Suggested Rollout Plan

    Week one: narrow down the scenario and build the evaluation set. Week two: connect the minimum loop of access, orchestration, and retrieval. Week three: add tool calling and governance observability. Week four: canary release and cost optimization. At this pace, a team can deliver an AI application foundation within a month that is measurable, extensible, and rollback-capable, and can then replace capability implementations as needed to keep benefiting from the falling costs driven by accessible large models.