Understand Downcity City

AI Architecture

The ModelClient, AIService, AIChannel, and Provider Adapter execution path.

City client / Agent
        |
        v
CityModel (ModelClient)
        |
        v
Federation AIService
  auth -> model lookup -> fallback -> reasoning -> metering
        |
        v
AIChannel.stream(AIChannelStreamInput)
        |
        v
OpenAI-compatible or private Provider Adapter

CityModel is the client-side executable model. It knows the public CityModelDescriptor and the Federation transport, but never knows upstream keys or vendor protocol details.

AIService is the server-side orchestrator. It owns route selection, fallback, reasoning validation, usage normalization, and billing.

AIChannel is the server-side upstream boundary. It owns connection configuration, upstream model selection, server-side provider_options, and delegates conversion into ModelStreamEvent to a Provider Adapter.

The OpenAI-compatible endpoint is an adapter, not another execution path:

OpenAI JSON/SSE -> ModelCall -> AIService -> AIChannel.stream -> ModelStreamEvent -> OpenAI JSON/SSE