City-Level Large Model API Service Platform: Architecture and Practice

    This article describes how to build a city-level large model API service platform. It covers the core problems the platform solves, a five-layer architecture, key capabilities such as unified APIs, retrieval-augmented generation, and heterogeneous compute scheduling, data and compute coordination practices, typical application scenarios, integration conventions, and operations and governance recommendations.

    As large models mature, enterprises are shifting their focus from whether they can call a model to how they can embed model capabilities into business systems in a stable, secure, and governable way. Single-point applications often face high deployment and operations costs, scattered data with complex permissions, heterogeneous compute resources, fragmented scenario requirements, non-standard interfaces, and missing security audits. A city-level large model API service platform addresses these issues by packaging model services, data resources, algorithm capabilities, and compute scheduling into one platform. It offers intelligent services through a unified API that is measurable, auditable, and scalable.

    1. Background and Core Problems

    A large model API service platform usually serves multiple tenants, scenarios, and resource pools. Its goal is not simply to expose an inference endpoint. Instead, it should build a capability system in which models are available, data is controlled, compute is schedulable, algorithms are configurable, and services are manageable. Developers need stable interface protocols, clear error codes, and rate limiting and quota policies. Enterprise users need data isolation, access control, audit trails, and scenario-specific optimization. Platform operators need a service catalog, metering and billing, resource scheduling, and quality assessment.

    The platform design should therefore address four problems. First, unified access, so that each business system does not need to integrate with different models separately. Second, a unified data boundary, so that the authorization relationships among public data, enterprise data, and the model inference process remain clear. Third, unified compute scheduling, so that model tasks of different sizes are matched to suitable resource pools. Fourth, unified security governance, covering identity authentication, content safety, log auditing, and risk alerts.

    2. Overall Architecture

    A practical large model API service platform can be divided into five layers: the access layer, the model service layer, the integration and scheduling layer, the data resource layer, and the security and operations layer.

    The access layer provides a unified API gateway. The gateway handles identity authentication, tenant identification, quota management, rate limiting and circuit breaking, request routing, idempotency control, and access logging. The gateway should expose a consistent request structure for different scenarios, so that business systems do not need to know the differences among underlying models.

    The model service layer hosts locally deployed large-parameter models and lightweight models. It provides inference services, prompt templates, retrieval-augmented generation (RAG), tool-calling orchestration, and output post-processing. A model routing policy can select different models or inference configurations based on scenario, latency requirements, cost policy, and data sensitivity level.

    The integration and scheduling layer coordinates data, algorithms, and compute. On the compute side, it manages multiple heterogeneous resource pools and assigns inference tasks by queue, priority, and resource quota. On the algorithm side, it provides a range of algorithm services and post-processing capabilities. On the data side, it gives retrieval-augmented generation, question answering, and agents controlled data access through a resource catalog and authorization policies.

    The data resource layer includes a public data resource catalog, enterprise data spaces, vector indexes, metadata management, and data quality rules. The platform should not allow models to access raw data without control. Instead, access should follow a controlled chain: catalog search, authorization checks, data masking and filtering, and reference traceability.

    The security and operations layer covers key management, tenant isolation, content safety, log auditing, monitoring and alerting, distributed tracing, and cost analysis. For areas such as government services and energy, the platform also needs to support data classification and grading, operation logging, and traceable results.

    3. Key Platform Capabilities

    A unified API with multi-tenant support is the foundation of the platform. The API should include fields for tenant ID, scenario ID, model policy, input messages, data scope, and trace ID. Responses should return the answer, citation information, usage statistics, and risk flags. In a multi-tenant model, logical isolation or resource isolation must ensure that calls from different organizations do not affect each other.

    Intelligent question answering with retrieval augmentation is a common deployment pattern. The platform can combine natural language interaction, domain term processing, knowledge retrieval, and answer generation into one service chain. It first retrieves controlled knowledge fragments for the question, then sends those fragments and the user’s question to the model together, and finally generates an answer with citations. This pattern reduces the risk of hallucination and makes the source of each answer auditable.

    Heterogeneous compute scheduling determines the platform’s elasticity. Different model sizes, context lengths, and concurrency needs place different demands on resources. The platform should support resource pool abstraction, task queuing, priority scheduling, elastic scaling, and failover. Scheduling policies should balance latency, throughput, cost, and resource utilization.

    Algorithm services and tool orchestration extend the platform from a question answering interface to an agent service. Capabilities such as classification, summarization, extraction, retrieval, and rule validation can be orchestrated into reusable components, so business systems can combine them by scenario. All components should follow a unified input and output contract, and each call should be recorded in the call chain.

    Security and compliance capabilities must be built in. The platform should support encryption in transit and at rest, key rotation, sensitive information recognition, content filtering, permission checks, and audit logs. For scenarios involving public data resources, the platform should verify authorization scope, so that the model uses only the data fragments it is permitted to access.

    4. Data and Compute Coordination in Practice

    On the data side, the platform should establish a resource catalog and an authorization model. Developers request data scopes by scenario, and the platform checks whether the tenant, scenario, and data scope match at call time. Retrieval results should be masked, filtered, and annotated with citations, so that unauthorized data does not enter the model context. For highly sensitive scenarios, a private knowledge base combined with local inference can reduce the risk of data leaving the organization.

    On the compute side, the platform should build resource pool profiles that include resource type, available capacity, task queues, and health status. The scheduler selects a resource pool based on the requested model policy, maximum latency, and priority. When a pool is overloaded, the scheduler can queue requests, degrade service, or apply rate limits. The platform should also provide observability metrics, such as request volume, success rate, latency distribution, queue length, and resource utilization, to support capacity planning.

    5. Typical Application Scenarios

    Government service question answering requires accuracy and traceability. The platform can connect to policy knowledge bases and service guides, return answers with citations through retrieval-augmented generation, and block risky questions that involve sensitive topics. Energy scenarios can combine equipment records, operating procedures, and safety standards to explain technical terms, assist with fault troubleshooting, and provide operational guidance. Air-ground collaborative intelligent inspection combines image recognition, text question answering, and task orchestration to produce inspection event descriptions, handling recommendations, and reusable knowledge. For enterprise services, a unified API can give small and medium-sized enterprises ready-to-use model capabilities, while large enterprises can receive optimization for scenario-specific prompts, knowledge bases, and workflow orchestration.

    6. Integration Example and Engineering Conventions

    The following is a generic HTTP request example. It shows field design only and does not represent a specific platform interface.

    1. POST /llm/api/invoke
    2. {
    3. "tenant_id": "tenant-a",
    4. "scene": "gov_qa",
    5. "model_policy": "local_large",
    6. "messages": [
    7. {"role": "user", "content": "Please explain the requirements for handling this matter."}
    8. ],
    9. "data_scope": ["public_catalog:policy"],
    10. "trace_id": "req-20250101-0001"
    11. }

    A response can be designed as follows:

    1. {
    2. "answer": "Based on the authorized policy excerpts, the requirements include...",
    3. "citations": ["doc:policy-001#sec-2"],
    4. "usage": {"input_tokens": 128, "output_tokens": 256},
    5. "risk_flags": []
    6. }

    From an engineering standpoint, the team should define unified error codes, timeouts, retry policies, and idempotency keys. For long-text scenarios, set context truncation and summarization strategies. Cache frequently asked questions. For critical business workloads, configure canary releases and version rollback. For model outputs, build an evaluation set and a manual spot-check process.

    7. Operating Model and Governance Recommendations

    Platform operations can use a service catalog that packages capabilities such as model question answering, document summarization, information extraction, retrieval-augmented generation, and agent orchestration by scenario. Small and medium-sized enterprises can receive standardized APIs and quota plans to lower the barrier to entry. Large enterprises can receive scenario-specific knowledge bases, prompt optimization, workflow orchestration, and dedicated resource policies. Operators should establish metering and billing, service level agreements, ticket-based support, and quality assessment mechanisms, and keep building scenario templates and evaluation data over time.

    For governance, the team should establish five policies: model admission, data authorization, content safety, log auditing, and cost accounting. Every call should be traceable to its tenant, scenario, data scope, and model version. All sensitive operations should be logged, and every answer citation should be verifiable. Through platform-based governance, large model API services can move from experimental applications to sustainable, well-run infrastructure.