Skip to content

Configuration

cc-lb reads configuration from cc-lb.toml and environment-backed secret references. Keep secret values in the environment or deployment secret store.

  • CC_LB_MASTER_KEY for encrypted runtime fields.
  • An admin authentication provider and its secret, such as CC_LB_ADMIN_TOKEN.
  • A storage URL or path supported by the selected server build.
  • A proxy and admin listener configuration.
[[admin.auth.providers]]
kind = "static_token"
id = "local"
token_env = "CC_LB_ADMIN_TOKEN"

The optional [oauth.anthropic], [oauth.openai], and [oauth.gemini] sections override provider endpoints and installed-app client settings for authenticated subscription login. Defaults target the real provider endpoints; use local mock URLs only for tests or isolated development.

[oauth.openai]
client_id = "app_EMoamEEZ73f0CkXaXp7hrann"
auth_url = "https://auth.openai.com/oauth/authorize"
authorize_url = "https://auth.openai.com/oauth/authorize"
token_url = "https://auth.openai.com/oauth/token"
browser_redirect_uri = "http://localhost:1455/auth/callback"
device_usercode_url = "https://auth.openai.com/api/accounts/deviceauth/usercode"
device_token_url = "https://auth.openai.com/api/accounts/deviceauth/token"
device_verification_url = "https://auth.openai.com/codex/device"
device_redirect_uri = "https://auth.openai.com/deviceauth/callback"
[oauth.gemini]
code_assist_url = "https://cloudcode-pa.googleapis.com/v1internal"
userinfo_url = "https://www.googleapis.com/oauth2/v3/userinfo"
[oauth.antigravity]
client_id = "<ANTIGRAVITY_CLIENT_ID>"
client_secret = "<ANTIGRAVITY_CLIENT_SECRET>"

auth_url and device_redirect_uri serve the device-code flow. The browser fallback uses authorize_url and browser_redirect_uri so the operator can paste the localhost callback address from a remote browser.

Gemini OAuth credentials retain the profile that issued them. Existing Gemini CLI enterprise grants use gemini_cli; when oauth_profile is absent from an imported or stored bundle, it defaults to gemini_cli. New Gemini subscription sign-ins and reconnects use antigravity.

The Antigravity profile is configured under [oauth.antigravity]. The operator MUST provide both client_id and client_secret; there is no built-in Antigravity client credential. Starting a Gemini subscription sign-in or refreshing an existing Antigravity credential returns oauth_client_not_configured until both keys are set:

Key Default
client_id Required; no default
client_secret Required; no default
authorize_url https://accounts.google.com/o/oauth2/v2/auth
token_url https://oauth2.googleapis.com/token
userinfo_url https://www.googleapis.com/oauth2/v2/userinfo?alt=json
redirect_uri http://localhost:51121/oauth-callback
scopes https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/cclog, https://www.googleapis.com/auth/experimentsandconfigs
code_assist_url https://daily-cloudcode-pa.googleapis.com
user_agent antigravity/hub/2.24.0 (aidev_client; os_type=darwin; arch=arm64; cl=1000335682)

The existing [oauth.gemini] section remains the gemini_cli profile. Keep client secrets out of source control and logs. Antigravity quota polling uses Code Assist retrieveUserQuotaSummary, with the same parser and fallback behavior as Gemini CLI sign-ins. It reports the same four windows: Gemini models have 5-hour (gemini_5h) and weekly (gemini_7d) windows; Claude and GPT-OSS models have 5-hour (third_party_5h) and weekly (third_party_7d) windows.

The optional [warmup] section selects the minimal request models used for OpenAI and Gemini OAuth warm-up. Anthropic uses its fixed Haiku warm-up model.

[warmup]
openai_model = "gpt-6.1-sol"
gemini_model = "gemini-2.5-flash-lite"
gemini_antigravity_model = "gemini-3.8-flash-low"
gemini_third_party_model = "gpt-oss-120b-medium"

openai_model defaults to gpt-6.1-sol. gemini_model defaults to gemini-2.5-flash-lite and is used only for the primary lane of Gemini CLI credentials. gemini_antigravity_model defaults to gemini-3.8-flash-low and is used for the primary lane of Antigravity credentials. Each primary-lane model must belong to its profile’s Gemini models quota group; a model outside that group, such as gemini-2.5-flash-lite on Antigravity, returns 200 but does not start the five-hour or weekly window. Antigravity model IDs carry a thinking-level suffix.

gemini_third_party_model defaults to gpt-oss-120b-medium. Gemini upstreams on the Antigravity profile use it to warm the Claude and GPT-OSS quota group (third_party_5h, third_party_7d). The value must start with claude- or gpt-oss-; any other value fails at config load.

Cache keepalive is configured per principal. The principal object controls whether the feature is enabled, its lead times, maximum refresh count, maximum duration, snapshot size, and classifier options.

For GPT-5.6+ Responses, enable both cache_keepalive.enabled and cache_keepalive.classifier.openai_responses_enabled. The documented prompt_cache_options.ttl is "30m" by default or "12h"; a supported input breakpoint may override that lifetime. Only eligible 30-minute prefixes with sufficient native cached-token evidence and refresh budget schedule renewals. A selected 12-hour prefix records a not-tracked decision because reads do not restart its clock. Legacy prompt_cache_retention is a separate policy. See the keep-alive operator guide for limits and renewal costs.

Use SQLite for local or bounded single-node operation. Use Postgres when multiple replicas must share durable job claims, idempotency keys, and cache-keepalive fences.

After changing scheduler or affinity retention settings, restart the server so all workers use the same startup policy.

Storage and scheduler connections use storage.url, but resolve TLS mode independently. Storage connections, including startup preflight, use storage.pool.sslmode. The scheduler uses scheduler.separate_pool.sslmode; it does not inherit storage.pool.sslmode.

For each pool, TLS mode follows this precedence:

  1. An explicit pool sslmode overrides the URL mode.
  2. If the pool setting is omitted, the URL’s sslmode or ssl-mode query parameter applies.
  3. If neither specifies a mode, cc-lb uses prefer, even when PGSSLMODE is set.

Omit each pool’s sslmode to inherit the URL policy. An explicit prefer or disable intentionally overrides even a strict URL mode such as require, verify-ca, or verify-full; remove a redundant prefer when the URL should control TLS.

After upgrading, a strict URL mode takes effect wherever the pool setting is omitted. Connections that previously relied on the implicit prefer fallback may fail until the database and client TLS configuration satisfy that policy.

Learned upstream affinity bindings are retained for 7 days from their last successful binding by default. Ordinary replay reads do not refresh the timestamp, so bindings older than ttl_days fail closed with 503 and are purged.

When an OpenAI Responses request contains unowned reasoning.encrypted_content items (with previous_response_id absent or empty and no compaction/compaction_summary items), unknown_openai_reasoning selects "hybrid" (default) or "fail_closed". Under "hybrid", multiple eligible OpenAI upstreams strip unknown reasoning items upfront, while a single eligible upstream (or a resolved owner carrying unmatched pending reasoning items) tries verbatim first and retries once on the same upstream with only unowned reasoning items stripped when 400 invalid_encrypted_content occurs before any response frame is emitted. "fail_closed" rejects unknown reasoning.encrypted_content with 503 upstream_affinity_unavailable.

[upstream_affinity]
ttl_days = 7
unknown_openai_reasoning = "hybrid"

Request events store all 99 operational, latency-breakdown, and abnormal-stream-error scalar fields in typed relational columns. The payload column is dropped, so event reads have zero TOAST overhead. The deep diagnostic fields are cache_breakpoints, cache_control_message_indices, routing_trace, iterations, and internal_errors, plus the optional native_cache object, which is omitted when no native cache analysis is recorded. Serving-bundle cache_breakpoints retain at most 32 prefix candidates in total, including bounded lookback_prefixes and their breakpoint/content-block positions. These candidates are emitted only in the off-path diagnostics log, not stored in request-event rows.

The optional startup setting below emits one cc_lb.request_diagnostics.v1 JSON line to stdout after each stored request event commits. The line also carries thread_id, observed_session_id, input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens, duration_ms, and upstream_ttfb_ms. The optional cache_write_input_tokens, cache_write_input_tokens_30m, and cache_write_input_tokens_12h integers are omitted when unreported or when the write component is invalid; a valid reported 0 is kept.

Key Default Environment variable Effect
observability.request_diagnostics_log false CC_LB_OBSERVABILITY__REQUEST_DIAGNOSTICS_LOG Writes one diagnostics JSON line to stdout for each stored request event.
[observability]
request_diagnostics_log = true

The setting is fixed at startup. observability.log_redaction and observability.user_prompt_redaction do not apply to diagnostics lines; producers redact internal error text and cap routing traces before persistence. See the observability guide and the request diagnostics runbook for delivery and reconciliation boundaries.

The optional [openai_oauth_compat] section controls how public OpenAI requests are adapted for ChatGPT-subscription upstreams. Defaults apply server-wide and are read at startup; changing cc-lb.toml requires a process restart. Each key can override these settings through the admin API.

[openai_oauth_compat]
store_true = "coerce"
sampling = "drop"
logprobs = "drop"
truncation_auto = "emulate"
prompt_cache_in_memory = "drop"
service_tier = "coerce"
web_search_preview = "coerce"
metadata = "drop_echo"
max_tool_calls = "drop"
background = "drop"
hosted_tools = "drop_tool"
compact = "emulate"
chat_n = "emulate"
chat_stop = "emulate"
chat_seed_penalties = "drop"
transcription = "disabled"

The alternatives are coerce/reject for store_true, service_tier, and web_search_preview; drop/reject for sampling, logprobs, prompt_cache_in_memory, max_tool_calls, background, and chat_seed_penalties; emulate/drop/reject for truncation_auto and chat_stop; drop_echo/drop/reject for metadata; drop_tool/reject for hosted_tools; emulate/reject for compact and chat_n; and enabled/disabled for transcription. Transcription is disabled by default because the upstream retains submitted audio for 30 days.

The separate [openai_public_api] section sets the realtime public API origin. realtime_origin defaults to https://api.openai.com/ and is restart-only; cc-lb appends /v1/realtime… paths to it.