Environment Variables
Common environment variables used by Federation.
| Variable | Purpose |
|---|---|
DOWNCITY_FEDERATION_TOKEN_SIGNING_KEY | Lets Federation issue and validate user_token internally |
DOWNCITY_CITY_DATABASE_URL | Optional. Specifies the database URL used by Federation |
OPENAI_API_KEY | Example provider key; recommended to write it into the Federation database through Admin env |
OPENAI_BASE_URL | Example provider base URL; recommended to write it into the Federation database through Admin env |
fed deploy interactively provisions the administrator ID and password. The password is stored as a PBKDF2 digest and administrator sessions are stored server-side; there is no administrator key environment variable. DOWNCITY_FEDERATION_TOKEN_SIGNING_KEY and BETTER_AUTH_SECRET are generated automatically on first boot and stored in Federation's env table.
If DOWNCITY_CITY_DATABASE_URL is omitted, the default database path is:
.base/downcity.sqliteHow provider env is used
The model handler reads directly from input.env:
import { createDeepSeek } from "@ai-sdk/deepseek";
import {
AIChannel,
read_required_env,
type AIChannelStreamInput,
type LanguageModelV3StreamResult,
} from "@downcity/federation";
class DeepSeekChannel extends AIChannel {
constructor() {
super({
id: "deepseek",
env: { DEEPSEEK_API_KEY: "DeepSeek API Key" },
env_key: "DEEPSEEK_API_KEY",
base_url: "https://api.deepseek.com",
ai_sdk_provider_id: "deepseek",
});
}
protected async stream(
input: AIChannelStreamInput,
): Promise<LanguageModelV3StreamResult> {
const deepseek = createDeepSeek({
apiKey: read_required_env(input, this.env_key ?? ""),
baseURL: this.base_url,
});
const model = deepseek(input.model.upstream_model);
return model.doStream(input.call);
}
}
const deepseek = new DeepSeekChannel();So the practical rules are simple:
- you choose the env key names yourself
- uppercase snake case is recommended
- read values through
input.env(key)orread_required_env()insidestream()
Write values into the database
A trusted backend can write provider keys through FederationAdmin:
await admin.env.upsert({
key: "DEEPSEEK_API_KEY",
value: "sk-xxx",
});These values are stored in the env table inside the Federation database. Business runtime reads only from that Federation-managed env table and no longer falls back to .env or process environment variables.
See also AIChannel environment variables.