Guides
Model Adapters
Adapt upstream protocols once through AIChannel.stream().
Downcity has two public protocols and one internal execution path:
City SDK / CityModel ------\
-> LanguageModelV3CallOptions -> AIChannel.stream()
OpenAI Chat Completions ---/ -> V3 streamFor an AI SDK model, call model.doStream(input.call) directly. For a private HTTP protocol, implement stream(input) and return LanguageModelV3StreamResult. AIService does not know the vendor request format.
OpenAI Chat Completions is an HTTP adapter around the same V3 path. There is no raw passthrough and no separate openai action, so tools, fallback, reasoning, metering, and billing behave consistently across clients.
Keep upstream-specific behavior in the Channel:
- credentials and base URL;
- upstream model factory and protocol selection;
- model-specific AI SDK providerOptions;
- usage interpretation and billing;
- conversion from private streams to V3 parts.
Keep Federation behavior in AIService:
- model registry and public catalog;
- authentication and availability;
- media fallback and reasoning validation;
- metering, balance checks, and charge settlement.