Settings internals
What each setting means to a person running Tubematic, and when to change it, is in the user guide's Settings. Here you will find how settings are stored, read, masked and checked, every key with its type and bounds, the other rows that share the table, and how to add a key.
Storage and reads
Every setting is a row in the settings table (key TEXT PRIMARY KEY, value TEXT NOT NULL), so
every value is stored as a string. SETTINGS_SPEC in renderer/api/pipeline.py declares each
key's type and default. The types are bool, int, str, secret, json_list, voice_list and
lexicon. pipeline.py::_coerce_setting turns a raw value into its typed form and into the string
that is stored, and raises on a value outside the key's bounds.
pipeline.py::_read_all_settingscoerces every declared key and uses the spec default for a key with no row. A new key's default therefore applies to an upgraded install with nothing written for it. A stored value that fails coercion reads as the default too.POST /settings(pipeline.py::post_settings) rejects any undeclared key with400, coerces every value, and then writes. One bad value changes nothing.strandsecretvalues are stripped of surrounding whitespace before they are stored.- No process caches a setting. The API, the MCP server and the worker read the database on each
use, so no key needs a restart.
log_retention_daysis the one key with a delay (Logs). - A renderer reads no settings.
render_timeout_secs,render_stall_timeout_secsandwatermark_enabledarrive with each claim, read at that moment, so a change applies from the next claim.
The default-voice invariant is enforced on read
If the stored elevenlabs_voice_id is not on the elevenlabs_voices roster, _read_all_settings
returns it as "". post_settings does not check the pair. The roster can fall back to [] by
itself when a stored list fails coercion, and a write-time check would then reject the next
unrelated settings save with an error about voices. Do not add one.
The default mascot is checked on read and on write
default_mascot_id names a row in mascots, which _coerce_setting cannot see because it has no
database connection. The two checks live elsewhere:
_read_all_settingsreturns""when the mascot is archived or was never approved.post_settingsrefuses a changed value that is not a pickable mascot. It also refuses any changed value while no renderer's GPU isworking(tubematic_core/mascots.py::mascot_gpu_error, the rule and wording a pick on a video uses).
post_settings checks the value only when it changes. Refusing a re-sent stored value would block
every unrelated save once the mascot is archived or the GPU is gone. "" passes.
Derived: pronunciation_mode
pronunciation_mode is not stored, and posting it is an unknown-key error. It belongs to a voice's
model, so GET /settings does not return it.
tubematic_core/voice_models.py::pronunciation_mode_for_model computes it wherever a video's model
is known, and the MCP get_video tool reports it per video:
ipaforeleven_v3andeleven_v4phonemefor a model that supports phoneme tagsrespellotherwise
It is derived because a model that supports more markup only adds capability, which leaves a human nothing to choose. See Scripting and Voice.
Key reference
Every key in SETTINGS_SPEC, grouped as on the dashboard's Settings page. The Bounds column
is what _coerce_setting enforces. It also refuses a negative value for every int key.
Pipeline control
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
pipeline_paused | bool | false | scripts/poll.py, which then starts no pipeline or research session. The worker's Auto Pilot pass and voicing-stall check |
Sessions already running finish, script profiles are still built, and human approvals still work.
AI review
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
gemini_review_enabled | bool | false | The worker's review step (render_results.py). When false, or while no gemini_api_key is stored, a successful render goes to VIDEO_READY | |
ai_review_model | str | gemini-2.5-flash | One of AI_REVIEW_MODELS: gemini-2.5-flash, gemini-3.5-flash, gemini-3.6-flash | The review step |
ai_review_fps | int | 10 | 1 to 24 | The review step, as the frame sampling rate sent to Gemini. See Cost |
ai_review_max_loops | int | 1 | 1 to 2 | The review step, as the number of revision rounds the reviewer may force |
ai_review_model is an allowlist because the review needs a measured tokens-per-frame figure for
each model.
Rendering
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
render_timeout_secs | int | 10800 | At least 60 | The render gateway, which sends it with each claim. The ceiling on one render |
render_stall_timeout_secs | int | 600 | At least 60 | The render gateway, with each claim. How long the render's progress counter may stand still before the renderer stops the render |
max_render_retries | int | 1 | render_results.py. Caps videos.render_fail_count | |
text_layout_audit_enabled | bool | true | The MCP validate_job tool. Switches off the advisory text-overlap and safe-zone audit | |
default_mascot_id | str | "" | "" or a pickable mascot. See above | Video creation, in the API and the MCP server, when the domain has no default of its own |
watermark_enabled | bool | true | The render gateway, with each claim. The renderer passes it to the composition |
render_timeout_secsdetects a render that will not end. Three hours covers a three-minute Short on the CPU with headroom.render_stall_timeout_secscatches a hung render sooner, whatever the video's length, because Remotion reports every frame it renders and encodes.max_render_retriescounts failed renders, stalls, timeouts, and renders lost to a renderer restart or an expired lease.ai_review_max_loopsis a separate cap, so allowing one review round does not reduce the render-retry budget.watermark_enabledis a setting and has noscene-config.jsonkey, because the agent writes that file and has no tool that writes settings. See Watermark.
Two rendering choices are made on the host and have no settings key. A container's GPU is fixed
when the container is created, so python3 onboard.py --step gpu chooses it
(GPU rendering). Letting renderers on other machines connect
publishes a port, which python3 onboard.py --step renderers does
(Remote renderers).
Scheduling
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
max_concurrent_agent_sessions | int | 3 | 1 to 10 | scripts/poll.py, on every pass. Pipeline sessions run at once, one video each |
agent_session_timeout_secs | int | 5400 | At least 60 | scripts/poll.py. Wall clock for one agent session, its model and effort retries included, before its process group is stopped |
Research and script-profile sessions run beside the pipeline sessions and outside the limit. The dashboard shows the timeout in minutes. See The Poller.
Logs
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
log_retention_days | int | 14 | 1 to 365 | Each service's log maintenance pass (tubematic_core/logging.py::prune_logs) |
Each service prunes its own log files when it starts and at each daily rollover, so a change takes
effect at the next pass. 0 is refused because it would delete the file the service is writing.
Video retention
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
retention_days | int | 7 | 0 to 365. 0 disables the sweep | The worker's hourly retention sweep |
unpublished_retention_days | int | 0 | 0 to 365. 0 disables the sweep | The same sweep |
retention_dayssweepsPUBLISHEDvideos, dated from the latest successful publication'spublished_at.unpublished_retention_dayssweepsFAILEDandTOPIC_REJECTEDvideos, dated fromupdated_at. It defaults to off because a failed video is paid-for output someone may still want to inspect.- The sweep touches no other status.
GET /retention/backlogreports how many failed and rejected videos exist and how much disk they hold.
See The Worker.
Research
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
max_curriculum_per_run | int | 2 | scripts/poll.py, in the research prompt | |
max_trending_per_run | int | 2 | scripts/poll.py, in the research prompt | |
max_mining_per_run | int | 2 | scripts/poll.py, and the MCP mine_youtube_topics tool, which enforces it. 0 turns mining off | |
research_pending_cap | int | 15 | scripts/poll.py. No research starts once this many videos sit at TOPIC_PROPOSED | |
max_research_runs_per_day | int | 8 | scripts/poll.py. A rolling 24-hour cap on research sessions | |
trending_sources | json_list | ["GitHub Trending", "Hacker News"] | A list of strings. The contents are not checked | scripts/poll.py, in the research prompt |
The API reports research_pending_cap and max_research_runs_per_day, and scripts/poll.py
enforces them. mine_youtube_topics asks Gemini for no more topics than max_mining_per_run and
makes no more Gemini calls than that in one run
(MCP server).
Voice
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
elevenlabs_voices | voice_list | [] | At most 10 entries of {name, voice_id, model_id} with an optional speed. Names and ids are unique and non-empty. model_id is a supported ElevenLabs model | Voice generation, voice previews, and every check of a video's or domain's voice |
elevenlabs_voice_id | str | "" | "" or a roster voice. See above | Voice generation, for a video with no voice of its own |
pronunciation_lexicon | lexicon | [] | At most 500 {term, respell} entries. term is unique. respell has no whitespace | The MCP generate_voice tool, when it builds the text to speak |
- Onboarding stores a starting roster on a new install (The roster).
- Each voice carries its own
model_id, and no install-wide model key exists, because the model decides which pronunciation and pause markup a script may carry (The model follows the voice). - A video whose
voice_idhas left the roster fails before any ElevenLabs call. It does not fall back to the install default. - A voice's
speedis 0.7 to 1.2 in steps of 0.05, allowed only on a model that honours it, and never stored at 1.0 (Speed). - A
respellshould be one plain word that spells the sound. See Respelling and the lexicon.
Images
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
image_model | str | gpt-image-2.5-flare | One of OPENAI_IMAGE_MODELS: gpt-image-2.5-flare, gpt-image-2.5-sunburst | The MCP generate_image tool |
character_model | str | gpt-image-2.5-flare | The same list | The MCP generate_character tool, for the illustrated style's characters |
OpenAI is the only image provider, so both tools need openai_api_key.
- The two keys share one list, and
character_modelis checked against it. A character needs a transparent background, so every model in the list must support one. To add a model that cannot, givecharacter_modelits own list first. character_modelis a setting so that a model a provider withdraws can be replaced from the dashboard.scripts/probe_openai_images.pychecks a model for everything both tools rely on. It makes billed calls.- OpenAI grants model access per project. A key from a project without access to the chosen model
gets a
403, which both tools turn into an error naming the model and the project.GET /v1/modelscan list a model the project cannot call, and OpenAI validates a request body before it checks access, so no free call checks access ahead of time. - A character's first asset is a generation and every later pose is an edit that sends the reference image as input. An edit costs about three times the tokens of a generation (1834 against 608 for a portrait, measured).
Agent
No settings key selects an agent, a model or an effort level. Installed agents, the default agent
and each agent's models and effort are rows in the agents table,
written by python3 onboard.py --install-agent <name>. A video's own choices are
videos.agent_model and videos.agent_effort. Model names are probed against the installed CLI
at install time and are not kept in a catalog in the repo. See
The Agent Layer.
Script formulas
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
auto_experimental_formulas | bool | false | The MCP choose_script_formula tool and get_video, on every call | |
learned_routing | bool | true | The MCP choose_script_formula tool and get_video, on every call |
auto_experimental_formulas lets Auto pick a script
formula marked experimental. While it is
off, such a formula is used only where a person chose it: a domain's default_formula_id or a
video's formula_choice.
learned_routing lets formula routing read the install's own watch figures (see
Learned routing). It is on by default because it
changes nothing until a domain has enough published videos with figures. With
publishing_enabled off it reads as off.
User preferences
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
user_preferences | str | "" | At most 6000 characters (MAX_USER_PREFERENCES_CHARS). A NUL character is refused. Line breaks are kept | scripts/poll.py and the MCP get_pipeline_status tool |
scripts/poll.pyputs the text into every prompt it builds (pipeline, research and script profile) as aUSER PREFERENCESblock. An empty value adds no block.get_pipeline_statusreturns it asuser_preferencesfor interactive sessions. The Agent Layer has the block's wording.- The cap exists because
poll.pypasses the whole prompt to the agent CLI as one command-line argument, and Linux limits one argument to 128 KiB (MAX_ARG_STRLEN). A longer prompt fails every agent run withE2BIG. The cap is far below that because the text costs tokens on every session. execrefuses an argument that contains a NUL, so a stored one would fail every scheduled run.- The API and the dashboard both count code points, as Python's
len()does. The dashboard truncates input at the cap withdashboard/lib/utils.ts::codePoints. It does not use a textarea'smaxLength, which counts UTF-16 units (two per emoji).
Publishing
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
publishing_enabled | bool | false | The publish routes and the worker. When false, VIDEO_APPROVED is where a video ends |
With this key alone, every step of publishing is started by a human. See Publishing internals.
Auto Pilot
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
auto_pilot_enabled | bool | false | The worker's Auto Pilot pass. On with no domain selected, it does nothing | |
auto_pilot_gap_mins | int | 240 | 0 to 10080 (a week) | The same pass. The shortest time between two posts on one account |
auto_pilot_max_in_flight | int | 0 | 0 to 500. 0 means no limit | The same pass. See The in-progress limit |
Settings → Auto Pilot saves all three through POST /autopilot, together with the
auto_pilot_config row, behind a confirmation. POST /settings accepts them too, with no
confirmation.
Notifications
| Key | Type | Default | Bounds | Read by |
|---|---|---|---|---|
discord_webhook_url | secret | "" | A Discord webhook URL, checked as described below | The worker's notification pass |
notify_topic_proposed | bool | false | The same pass. One message per research run | |
notify_script_ready | bool | false | The same pass | |
notify_video_ready | bool | false | The same pass | |
notify_partially_published | bool | false | The same pass. Alerts when a publish failed on some accounts | |
notify_failed | bool | false | The same pass. Alerts when a video reaches FAILED | |
dashboard_base_url | str | "" | "", or a URL that starts with http:// or https://. A trailing / is removed | The same pass, to build links. "" means messages carry no links |
- A message needs both a webhook URL and an enabled trigger. The stuck-in-voicing alert is the exception: the worker sends it whenever a webhook URL is set (Troubleshooting).
dashboard_base_urlhas no default because a container cannot know the host name a person reaches the dashboard by.post_settingschecks a webhook URL twice.discord_notify.parse_webhook_urlchecks its shape.discord_notify.verify_webhookthen sends an unauthenticatedGETto the URL, which returns the webhook object and posts no message. A definite rejection (401 Invalid Webhook Tokenor404 Unknown Webhook) refuses the save with400. A timeout, a DNS failure or a5xxstores the URL, so an outage at Discord cannot block a settings save.
Notifications covers what triggers a message.
Costs
SETTINGS_SPEC has no cost keys. Model prices are rows in model_prices. See
How a call is priced.
Credentials
| Key | Type | Default | Read by |
|---|---|---|---|
elevenlabs_api_key | secret | "" | Voice generation and voice previews |
gemini_api_key | secret | "" | Topic mining and AI review. Optional |
openai_api_key | secret | "" | Scene images and illustrated characters. Required |
youtube_transcript_api_key | secret | "" | Transcript fetching for script profiles |
postforme_api_key | secret | "" | Publishing and analytics |
A secret value may not contain whitespace. While gemini_api_key is unset, mining is left out
of the active research modes and review is skipped. While openai_api_key is unset,
generate_image fails and illustrated is refused wherever a visual style is chosen.
Undeclared rows
These keys live in the settings table outside SETTINGS_SPEC. POST /settings rejects them as
unknown, and GET /settings does not return them.
| Key | Written by | Shape |
|---|---|---|
active_strategies | POST /research/strategies. Onboarding seeds curriculum,trending,mining | Comma-joined string |
publishing_accounts | POST /publishing/accounts | JSON array of allowed account ids |
auto_pilot_config | POST /autopilot | JSON object. projects maps a domain id to the account ids it posts to. account_limits maps an account id to its posts per day |
mining_youtube_urls | POST /research/mining-sources and the MCP set_mining_sources tool | JSON array of at most 50 distinct https://www.youtube.com/watch?v=<id> URLs |
mining_url_cursor | The MCP mine_youtube_topics tool | Integer as a string: the index of the URL the next run starts from |
research_run_timestamps | POST /research/record-run | JSON array of ISO timestamps, pruned to 24 hours |
last_research_at | The MCP mark_research_done tool | ISO timestamp |
last_metrics_poll_at | The worker's hourly metrics pass | ISO timestamp |
last_price_sync_at | The worker's weekly price sync, before it runs | ISO timestamp |
last_price_sync_ok_at | The price sync, when it succeeds | ISO timestamp, shown on Settings → Costs |
last_price_sync_error | The price sync | The last failure's message, or "" after a success |
last_retention_sweep_at | The worker's retention sweep, before it runs | ISO timestamp |
voicing_stall_paused_at | The worker's voicing-stall check, on every pass while the pipeline is paused | ISO timestamp |
render_claim_hold_until | onboard.py --step gpu, around its recreate of the built-in renderer | ISO timestamp (seconds, Z) |
render_gateway_address | onboard.py --step renderers (onboard/actions.py::apply_renderers) | host:port, with an IPv6 host in brackets. "" or no row means remote renderers are off |
mcp_port | Onboarding's install_config step | Integer as a string |
poll_interval_mins | Onboarding's cron step | Integer as a string |
admin_password_hash | Onboarding's auth step and onboard.py --set-password | scrypt$N$r$p$salt$hash |
What reads them:
active_strategiesis read throughpipeline.py::_active_strategiesandmcp/server.py::_active_strategies, which leave outminingwhile nogemini_api_keyis stored. The filter does not rewrite the row. A save made while there is no key keeps a storedmining, because the caller was shown only the filtered list, so a key added later brings mining back.- A missing or malformed
auto_pilot_configreads as no domain selected. - Both writers of
mining_youtube_urlsrefuse any entry that is not a YouTube video URL (Mining sources).mining_url_cursormakes runs rotate through the list. - The worker flags a stalled voicing only when enough time has passed since the later of
voicing_stall_paused_atand the video's own last change, so a long pause does not flag every video when it ends. The same check readspoll_interval_mins(The Worker). - The render gateway hands the built-in renderer no render until
render_claim_hold_untilhas passed, and the step deletes the row when it is done (The claim). Other renderers are not held. - Every enrollment token carries
https://<render_gateway_address>, andGET /renderersreports it asremote_enabledandgateway_address. It is undeclared because turning remote renderers on also publishes a port, which onboarding alone can do (Remote-renderers override). - Onboarding and
--install-agentreadmcp_portto build the MCP URL.mcp_portandpoll_interval_minshave no route, because each feeds something onboarding generates (the MCP registration and the crontab line), and a dashboard edit would change neither. POST /auth/loginis the one reader ofadmin_password_hash.
How credentials are stored
Credentials are plain-text rows in the SQLite database. No .env file or service environment
holds them.
- A key changed on the dashboard applies to the next call, with no restart.
docker inspectshows no key, because no service has anenv_file.- Onboarding can check a key with its provider as you type it.
- The database file holds every key. Treat
~/.tubematic-data/data/tubematic.dband its backups as secrets.
The file cannot be hidden from the host user: WAL mode needs write access to the -shm file even
to read. renderer/entrypoint.sh restricts the file to the host user's group where it can (0660
plus setgid on the directory) and falls back to world-writable when the mount directory is owned
by root. Claude Code and OpenCode agents are denied reading the data directory. Codex's read-only
sandbox has no per-path rule (Deployment).
Each process reads a key from the settings table on every call. When the row is empty it uses the
matching environment variable (OPENAI_API_KEY for openai_api_key, and so on)
(pipeline.py::_secret). The test compose file supplies its dummy keys that way. A normal install
sets none.
Masking
pipeline.py::_mask_settings masks secret keys in the response of GET /settings and of
POST /settings, which re-reads and returns everything. Internal callers read the raw values.
| Stored value | Mask |
|---|---|
| Empty | "" |
| Four characters or fewer | One bullet per character |
| Longer | Eight bullets and the last four characters |
post_settings drops a posted secret that equals the current mask of a stored value. The
dashboard can therefore GET the settings, edit one field and POST the whole object back
without overwriting stored keys with bullets.
Never log a key
- Send API keys as headers. HTTP client libraries put the request URL in their exception strings,
and error text is stored in the
commentstable, which the dashboard displays. A key in a query parameter would end up there. - Do not log or display OpenAI's
401message. It echoes twelve characters of the submitted key. discord_webhook_urlissecret-typed because the URL is the credential: anyone holding it can post to the channel. Its credential is in the URL path, so an HTTP client's request log prints it. Log redaction matches stored secret values and key-shaped patterns. The save-time probe runs before the value is stored, sotubematic_core/logging.pycarries a pattern for the webhook path.discord_notify.pyalso installs a filter on thehttpxlogger, because the plain stdout handler is not redacted.
Rejection signatures
Onboarding checks each key with its provider when you enter it (onboard/api_keys.py). A check
answers valid, invalid or unknown. Onboarding refuses a key on invalid alone. A timeout or an
unreachable provider says nothing about the key, so onboarding accepts it with a warning.
| Service | Probe | A bad key answers |
|---|---|---|
| ElevenLabs | Four requests with xi-api-key, one per permission Tubematic needs (see below) | 401, {"detail": {"status": "invalid_api_key"}} |
| Gemini | GET /v1beta/models, x-goog-api-key | 400, with error.details[].reason == "API_KEY_INVALID" |
| OpenAI | POST /v1/images/generations with an empty body, Authorization: Bearer | 401, {"error": {"code": "invalid_api_key"}} |
| youtube-transcript.io | POST /api/transcripts, Authorization: Basic, body {"ids": []} | 401, plain text |
| postforme.dev | GET /v1/social-accounts, Authorization: Bearer | 401, {"error": {"code": "err:frontline:client:invalid_key"}} |
- ElevenLabs keys are scoped when they are created, so the check probes each permission:
text-to-speech (a
POSTto a voice that does not exist), voices, studio projects and pronunciation dictionaries (_ELEVENLABS_PROBES). A401withmissing_permissionsmeans the key is real and lacks that permission. The check tries all four and names every one that is missing. - The OpenAI check calls the endpoint
generate_imageuses. OpenAI evaluates the key before the body, so a key that may generate images answers400for the missing prompt, and nothing is generated or spent.GET /v1/modelsneeds a permission the pipeline does not use, so a restricted key that works would fail it. A401or403withinsufficient_permissionsmeans the key is real and cannot generate images. - Gemini answers
400. A shared "401 or 403 means invalid" rule would accept every bad Gemini key, so the check readserror.details[].reason. - postforme answers
401for a wrong key (invalid_key) and for a request with noAuthorizationheader (missing_credentials). The second is a fault in the caller, so the check readserror.codeand reports invalid for the first alone. - youtube-transcript.io has no account endpoint. It rejects on authentication before it validates
the body, so an empty
idslist answers401for a bad token, fetches nothing and spends no transcript quota.
A pasted key is checked before it is sent
onboard/api_keys.py::resolve_secret strips surrounding whitespace from a key and stores the
stripped value, so the key that is checked is the key that is saved.
onboard/api_keys.py::malformed_reason then refuses a key that contains anything outside
printable ASCII (a line break, a tab, a non-printable or non-ASCII character) before any request
is made, and reports it as a copy-and-paste error.
The check runs first because such a key fails on the wire in ways that look like something else:
- A line break raises
httpx.LocalProtocolError, a subclass ofhttpx.HTTPError. The checker's transport handler would read it as an unreachable provider and accept the key. - A non-ASCII character raises
UnicodeEncodeError, which the handler does not catch.
Interior spaces pass this check. httpx sends them, and the provider rejects the key.
Adding a setting
- Add the key to
SETTINGS_SPECinrenderer/api/pipeline.pywith its type and default. Add a coercion branch to_coerce_settingif the type is new or the key has bounds. - Add it to the
Settingstype indashboard/lib/types.tsand to a tab indashboard/app/settings/page.tsx. - If onboarding should ask for it, add a
Fieldtoonboard/config.pyand map it inENV_FIELD_TO_SETTING. - Read it where it is used, on each call. Do not read it at import.
- Add it to the key reference and to the user guide's
Settings. Grep
docs/for a stated key count and update it.
Several settings repeat their literal default in three to five places: the spec, the
v.get(key, "<literal>") fallback of an apply_* action, a consumer's own
os.getenv(..., default), and sometimes a status endpoint. Most carry no "keep in sync" comment.
Grep for the value as well as the key before you change a default.