Quickstart
Connect Client
Call the Federation from a product client with User City.
Product clients use User City. The common paths are city.ai.* for AIService and city.service(id).action(name).invoke() for custom services.
import { City } from "@downcity/federation/legacy";
const city = new City({
federation_url: "https://base.example.com",
user_token: "ub_xxx",
});
const catalog = await city.ai.catalog();
const model = catalog.get("gpt-5.4");
if (!model) throw new Error("model not found");
const result = await city.ai.text({
model,
prompt: "Write a welcome message for the product",
});If you already know the target model, select it directly from the directory:
const body = await city.ai.stream({
model: catalog.get("gpt-5.4"),
prompt: "Stream a short paragraph",
});ai.text() returns an AI SDK UIMessage. ai.stream() uses CityModel's
LanguageModelV3 transport and converts it client-side into a
ReadableStream<UIMessageChunk>.
One Federation can serve many client surfaces:
https://app.example.com- a Chrome extension
- a desktop tool
- a mobile app
- an internal operations tool
Those clients do not need to manage provider keys, model routing, or usage tracking on their own.