Skip to content

reference data models

Nik edited this page May 30, 2026 · 1 revision

Data models

The Swift types DroidProxy uses to represent providers, accounts, models, and usage. These are plain struct/enum values — there is no database. State lives in JSON files under ~/.cli-proxy-api/, in ~/.factory/settings.json, and in UserDefaults.

Provider and account types

Defined in src/Sources/AuthStatus.swift. See Auth management for behavior.

ServiceType

A String-raw-value enum of the logical providers, with a forgiving initializer that maps credential-file type strings onto a provider.

Case Raw value Display name Auth file type values that map to it
claude claude Claude Code claude
codex codex Codex codex
antigravity antigravity Antigravity antigravity, gemini, gemini-cli
kimi kimi Kimi kimi
cursor cursor Cursor cursor

AuthAccount

One authenticated account, parsed from a credential JSON file.

Field Type Source
id String the filename
email String? email field
login String? login field (for Copilot-style logins)
type ServiceType mapped from type field
expired Date? parsed from expired ISO-8601 string
filePath URL path to the JSON file
isDisabled Bool disabled field (default false)

Computed: isExpired (true when expired < now), displayName (email, else login, else id). ServiceAccounts groups the accounts for one ServiceType.

Credential file shape

Each file in ~/.cli-proxy-api/*.json is provider-written OAuth state. DroidProxy reads a small subset and writes only two fields itself (disabled, and refreshed Claude tokens).

Field Read by Written by
type AuthManager.parseAccount (provider mapping) provider login
email / login account display provider login
expired expiry detection, usage refresh provider login, Claude token refresh
disabled enable/disable state AuthManager.toggleAccountDisabled
access_token / refresh_token OAuth usage tracker Claude token refresh
account_id Codex usage request header provider login
apiKey Cursor forwarding SettingsView.saveCursorApiKey (cursor.json)

Model catalog types

Defined in src/Sources/DroidProxyModelCatalog.swift. See Reasoning and models for the full catalog.

DroidProxyModelDefinition

The authoritative description of one exposed Factory model.

Field Type Purpose
baseModel String upstream model id sent in the request body
idSlug String builds simpleID = custom:droidproxy:<idSlug>
displayName String shown as DroidProxy: <name> in Factory
maxOutputTokens Int written to the Factory custom-model entry
provider String Factory provider (anthropic, openai, generic-chat-completion-api)
providerKey String maps to a ServiceType for enable/disable filtering
baseURL String http://localhost:8317 or …:8317/v1
kind DroidProxyModelKind claudeAdaptive, codex, kimi, antigravity, cursor
levels [DroidProxyThinkingLevel] supported reasoning efforts
defaultLevelValue String default effort

settingsEntry turns this into the [String: Any] dictionary written to ~/.factory/settings.json, embedding enableThinking and reasoningEffort when the model has levels. DroidProxyThinkingLevel is just { value, displayName }.

Usage model types

Defined in src/Sources/OAuthUsageTracker.swift. See OAuth usage tracker.

  • OAuthUsageWindow — one quota window: title, usedPercent, resetText, resetDate, computed remainingPercent.
  • OAuthAccountUsage — per-account result: provider, email, isLoading, windows, error, updatedAt.

Auth and login commands

AuthCommand (in src/Sources/ServerManager.swift) enumerates the OAuth login flows and their CLI flags: claudeLogin-claude-login, codexLogin-codex-login, antigravityLogin-antigravity-login, kimiLogin-kimi-login.

Related references

Clone this wiki locally