Downcity
Reference

Model Config Reference

Real model implementation flow: SQLite storage, encryption, binding resolution, and apply behavior

Model Config Reference

Model implementation has two layers:

  1. Console-global model pool in ~/.downcity/downcity.db (SQLite)
  2. Project-local model.primary in each agent downcity.json

1) Persistence layout

Console-global model pool:

  • file: ~/.downcity/downcity.db
  • tables: model_providers, models
  • write entrypoint: city model ...

Project-local binding:

  • file: <project>/downcity.json
  • field: model.primary

2) Write flow

  1. city model ...
    writes provider/model records into ~/.downcity/downcity.db

  2. Console UI model switch
    updates current agent downcity.json -> model.primary

  3. city agent create
    selects a model id from console pool and writes model.primary

3) Read flow at runtime

{
  "model": {
    "primary": "default"
  }
}

primary must reference an existing model id in SQLite, otherwise startup fails.

4) Encryption behavior

Provider apiKey is not stored in plaintext:

  • algorithm: AES-256-GCM field-level encryption
  • key priority: DC_MODEL_DB_KEY env var > ~/.downcity/console/model-db.key
  • DB field: api_key_encrypted

5) Commands

Manage model pool globally:

city model list
city model get model fast

Bind agent to a model ID:

city config set model.primary fast

6) Apply changes

Restart agent after model changes:

city agent restart .