Skip to content

Configuration

GodeX is configured through a single YAML file, typically named godex.yaml. The configuration file controls every aspect of the gateway: which port to listen on, which providers to enable, how sessions are stored, what gets logged, and how traces are recorded. The system reads the file, interpolates environment variables, applies CLI overrides, and validates every field before the server starts.

At a Glance

SectionPurposeRequired
serverListen address, port, idle timeoutYes (has defaults)
default_providerProvider used when model omits prefixYes
providersMap of provider name to configYes
modelsModel aliases and wildcard mappingNo
sessionConversation history backendYes (has defaults)
loggingLog level, console, and file outputYes (has defaults)
traceRequest/response tracingYes (has defaults)

Config Loading Pipeline

The raw YAML file passes through a multi-stage pipeline before becoming the validated GodeXConfig object that the rest of the system consumes (src/config/builder.ts:17-39).

The file is read from disk by loadConfigFromFile (src/config/reader.ts:5-35), then each section is parsed by dedicated functions in src/config/sections/.

Environment Variable Interpolation

Every string value in the YAML file supports ${VAR} syntax. The interpolation is recursive, so nested objects and arrays are all processed. This lets you keep API keys out of your config file.

yaml
providers:
  deepseek:
    spec: deepseek
    credentials:
      api_key: ${DEEPSEEK_API_KEY}

The resolveEnvVarsDeep function handles this by walking the entire parsed object tree (src/config/env-interpolation.ts:9-20):

ExpressionBehavior
${MY_VAR}Replaced with process.env.MY_VAR
${MISSING_VAR}Left as the literal ${MISSING_VAR}
Non-string valuesPassed through unchanged

Server Section

Controls the HTTP server configuration. Parsed in src/config/sections/server.ts:10-37.

yaml
server:
  port: 5678
  host: "0.0.0.0"
  idle_timeout: 0
FieldTypeDefaultDescription
portnumber5678Listen port. Override: --port, GODEX_PORT
hoststring0.0.0.0Listen address. Override: --host, GODEX_HOST
idle_timeoutnumber0Idle connection timeout in seconds

Priority order for port: CLI flag > YAML value > GODEX_PORT env > default 5678.

Provider Section

Each provider entry maps a logical name to a provider spec with credentials. Parsed in src/config/sections/providers.ts:4-40.

yaml
providers:
  deepseek:
    spec: deepseek
    credentials:
      api_key: ${DEEPSEEK_API_KEY}
    endpoint:
      base_url: https://api.deepseek.com
    timeout_ms: 30000
FieldTypeRequiredDescription
specstringYesProvider spec name (e.g. deepseek, zhipu, minimax)
credentials.api_keystringYesBearer token for the provider API
endpoint.base_urlstringNoOverride the provider's default base URL
timeout_msnumberNoPer-request timeout in milliseconds

The spec field is mandatory. Legacy provider configs without spec will produce an error at startup (src/config/sections/providers.ts:17-19).

Models Section

Model aliases let you map friendly model names to concrete provider/model pairs. The wildcard * acts as a catch-all.

yaml
models:
  aliases:
    "gpt-5.5": deepseek/deepseek-v4-pro
    "glm": zhipu/glm-5.1
    "*": deepseek/deepseek-v4-flash
AliasResolves ToBehavior
gpt-5.5deepseek/deepseek-v4-proExact match
glmzhipu/glm-5.1Exact match
*deepseek/deepseek-v4-flashFallback for any unmatched model

Session Section

Controls how conversation history is persisted for multi-turn support via previous_response_id. Parsed in src/config/sections/session.ts:5-27.

yaml
session:
  backend: sqlite
  sqlite:
    path: ./data/sessions.db
FieldTypeDefaultDescription
backend"memory" | "sqlite"memoryStorage backend for response sessions
sqlite.pathstringAutoPath to the SQLite database file

Logging Section

Controls structured logging output via LogTape. Parsed in src/config/sections/logging.ts:9-67.

yaml
logging:
  level: info
  console:
    enabled: true
    level: info
  file:
    enabled: true
    level: debug
    dir: ./logs
    filename: godex.log
    max_size: 10485760
    max_files: 5
FieldTypeDefaultDescription
levelLogLevelinfoGlobal minimum log level. Override: --log-level, GODEX_LOG_LEVEL
console.enabledboolean-Enable console output
console.levelLogLevelinherits levelConsole-specific log level
file.enabledboolean-Enable file output
file.dirstringrequired if enabledDirectory for log files
file.filenamestringrequired if enabledLog file name
file.max_sizenumber-Max file size in bytes before rotation
file.max_filesnumber-Max number of rotated files to keep

Valid log levels: trace, debug, info, warn, error.

Trace Section

Controls the request/response tracing subsystem. Parsed in src/config/sections/trace.ts:6-49.

yaml
trace:
  enabled: true
  path: ./data/trace.db
  capture_payload: false
  payload_max_bytes: 65536
  max_queue_size: 10000
  flush_interval_ms: 1000
  batch_size: 100
FieldTypeDefaultDescription
enabledbooleantrueEnable or disable tracing
pathstringAutoPath to the trace SQLite database
capture_payloadbooleanfalseRecord full request/response bodies
payload_max_bytesnumber65536Max payload size to capture
max_queue_sizenumber10000In-memory trace event queue size
flush_interval_msnumber1000How often to flush traces to disk
batch_sizenumber100Number of traces per flush batch

Full Config Builder Flow

The buildConfig function in src/config/builder.ts:17-39 ties everything together.

CLI Overrides

The CLI layer can override specific config values without editing the YAML file. These overrides are passed to buildConfig via the ConfigOverrides interface (src/config/builder.ts:11-15).

CLI FlagConfig PathType
--portserver.portnumber
--hostserver.hoststring
--config(file path)string
--log-levellogging.levelLogLevel

Complete Example

yaml
server:
  port: 5678
  host: "0.0.0.0"
  idle_timeout: 0

default_provider: deepseek

models:
  aliases:
    "gpt-5.5": deepseek/deepseek-v4-pro
    "glm": zhipu/glm-5.1
    "*": deepseek/deepseek-v4-flash

providers:
  deepseek:
    spec: deepseek
    credentials:
      api_key: ${DEEPSEEK_API_KEY}
    endpoint:
      base_url: https://api.deepseek.com
    timeout_ms: 30000
  zhipu:
    spec: zhipu
    credentials:
      api_key: ${ZHIPU_API_KEY}
  minimax:
    spec: minimax
    credentials:
      api_key: ${MINIMAX_API_KEY}

session:
  backend: sqlite
  sqlite:
    path: ./data/sessions.db

logging:
  level: info
  console:
    enabled: true
  file:
    enabled: true
    dir: ./logs
    filename: godex.log

trace:
  enabled: true
  capture_payload: false

Configuration Schema

The top-level GodeXConfig type is defined in src/config/schema.ts:62-70:

Next Steps

TopicDescription
Quick StartInstall and run GodeX in five minutes
Built-in ProvidersCompare provider capabilities
OverviewArchitecture and design concepts

References