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

String values in the providers section support ${VAR} syntax. The interpolation is recursive, so nested objects and arrays under providers 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 object tree it is given (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
specstringNo (defaults to key name)Provider 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

When spec is omitted, the provider key name is used as the spec (src/config/sections/providers.ts:17-19). Startup fails when the resolved spec — explicit or key name — is not a registered provider definition.

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: 10           # 10 MB per file
    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_sizenumber10Max file size in MB 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

Web Search Section

Controls built-in web search. GodeX can either let the provider handle search natively, or run the search itself ("GodeX-managed") and feed the results back into a continuation request. Parsed in src/config/sections/web-search.ts:10-73.

yaml
web_search:
  enabled: true
  mode: auto                 # auto | provider_native | godex_managed | disabled
  provider: none             # none | mock | zhipu
  on_unavailable: client_tool_call  # client_tool_call | fail | ignore
  max_iterations: 2
  timeout_ms: 10000
FieldDefaultDescription
enabledtrueMaster switch
modeautoauto (prefer native, fall back to managed), provider_native, godex_managed, or disabled
providernoneSearch backend for godex_managed mode (none / mock / zhipu)
on_unavailableclient_tool_callFallback when managed search is configured but unavailable
max_iterations2Max managed search rounds per request
timeout_ms10000Per-search timeout (ms)

With the shipped defaults, providers that support native web search (Zhipu, Xiaomi) use it directly; others forward web_search calls to the client. Note that for native providers mode has no effect — they always use native search. To enable GodeX-managed search for non-native providers (DeepSeek, MiniMax), set provider: zhipu and add a providers.zhipu block with credentials.api_key to godex.yaml (the search backend reads the provider config, not just ZHIPU_API_KEY). See the Config Schema - Web Search for full field semantics.

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