Repository navigation
feat(ai): connect AI providers once and choose one per job - #3106
Conversation
AI Services now keeps a provider registry (ai.providers, encrypted). Text and speech-to-text each select a provider by id and keep their own model settings; the ChatGPT plan stays a text-only choice through ai.auth_mode. New acting-administrator operations list, create, edit, delete, check, and list models for providers. Stored keys go only to the address saved with them, and a provider a job uses cannot be removed. On first start the server moves ai.base_url/api_key (and the subtitle_ai predecessors) and ai.asr_base_url/asr_api_key into providers, binding each job to the endpoint and key it used. The old rows stay in place unread. Transcription no longer falls back to the text endpoint. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 39 minutes. View limit details
Walkthrough
Merge Risk:
|
|
The Evidence section contains a placeholder, not captures or a published evidence link. The new AI Services interface needs:
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a3b7a5625
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case legacyAITextURLSetting, legacyAITextKeySetting, legacyAISpeechURLSetting, legacyAISpeechKeySetting, | ||
| legacySubtitleURLSetting, legacySubtitleKeySetting: | ||
| return "", fmt.Errorf("%s was replaced by AI providers; connect the provider in AI Services", key) |
There was a problem hiding this comment.
Preserve AI configuration writes through the frozen v1 bridge
Existing v1 clients that configure an endpoint or rotate its key now receive a validation error for previously supported settings. The /api/v1/admin/settings and /api/v1/admin/settings/{key} routes still use the shared handlers and this normalizer (internal/api/router.go:4402–4403), while provider creation is exposed only under v2. Preserve the legacy write behavior through a compatibility adapter rather than rejecting these keys on both API versions; AGENTS.md explicitly requires the v1 bridge contract to remain unchanged.
AGENTS.md reference: AGENTS.md:L249-L250
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Recorded as a deliberate pre-lock change in 4217eca (docs/architecture/v1-scope.md, pre-lock removals table), the same way the Trakt retirement recorded its v1 change. The routes keep their shape and every other key. These six keys stop being read once the server converts them into providers on first start, so accepting a v1 write would store a value that changes nothing, and an admin would believe a key had been rotated. No first-party native client writes them, and the web admin uses v2. #3107 extends the entry with the retired embedding keys.
A server that saved a speech key without a speech URL sent audio to the text endpoint with that key. The conversion now gives that endpoint and key a provider of its own instead of binding speech to the text key. Record the rejected v1 writes of the retired AI endpoint settings in the pre-lock removals table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Minor · Update the transcription error hint to match the provider model. · transcribe.go:275-277
internal/ai/llm/transcribe.go:275-277
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUpdate the transcription error hint to match the provider model.
decorateTranscribeErrorstill tells the administrator to "set a Whisper-compatible Transcription base URL (and model) under Admin Settings → AI Services". This change removes that setting, and the server now rejects writes toai.asr_base_url. An administrator who follows the hint cannot complete it. Tell the administrator to choose a speech-to-text provider that supports transcription.Proposed fix
- return fmt.Errorf("%w — the configured endpoint likely does not support audio transcription; "+ - "set a Whisper-compatible Transcription base URL (and model) under Admin Settings → AI Services "+ - "(e.g. a self-hosted faster-whisper/speaches server, api.groq.com/openai with whisper-large-v3-turbo, or api.openai.com with whisper-1)", err) + return fmt.Errorf("%w — the selected provider likely does not support audio transcription; "+ + "choose a speech-to-text provider (and model) under Admin Settings → AI Services "+ + "(e.g. a self-hosted Whisper server, Groq with whisper-large-v3-turbo, or OpenAI with whisper-1)", err)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c3a4ae60-c784-49e0-bc55-da14a80c7a52
Files selected for processing: 48-
cmd/silo/main.gocontracts/api/v2/openapi.jsondocs/admin-settings-api.mddocs/architecture/ai-provider-authentication.mdinternal/ai/chatgpt/eligibility_test.gointernal/ai/chatgpt/selection.gointernal/ai/chatgpt/selection_test.gointernal/ai/chatgpt/usage_test.gointernal/ai/llm/client.gointernal/ai/llm/client_test.gointernal/ai/llm/models.gointernal/ai/llm/openrouter_test.gointernal/ai/llm/responses_test.gointernal/ai/llm/transcribe.gointernal/ai/llm/usage_callbacks_test.gointernal/api/handlers/admin.gointernal/api/handlers/admin_ai_providers.gointernal/api/handlers/admin_ai_providers_test.gointernal/api/handlers/admin_settings_check_service_test.gointernal/api/handlers/admin_settings_checks.gointernal/api/handlers/admin_settings_checks_test.gointernal/api/handlers/admin_settings_credential_binding_test.gointernal/api/router.gointernal/api/testdata/media_routes.txtinternal/apiv2/admin_ai_providers.gointernal/apiv2/document.gointernal/apiv2/router.gointernal/catalog/encrypted_settings_repo.gointernal/config/admin_settings.gointernal/config/admin_settings_test.gointernal/config/ai_providers.gointernal/config/ai_providers_test.gointernal/config/config.gointernal/config/db_loader.gointernal/contractledger/ledger_test.gointernal/subtitles/ai/config.gointernal/subtitles/ai/connection_test.gointernal/subtitles/ai/reuse_test.gointernal/subtitles/ai/service_test.goweb/src/api/v2/operations.tsweb/src/api/v2/schema.tsweb/src/hooks/queries/admin/aiProviders.tsweb/src/lib/adminSettingsSearch.tsweb/src/lib/aiProviders.tsweb/src/pages/admin-settings/AIProviders.test.tsxweb/src/pages/admin-settings/AIProviders.tsxweb/src/pages/admin-settings/AISettings.test.tsxweb/src/pages/admin-settings/AISettings.tsx
Files with no reviewable changes: 2-
- internal/api/handlers/admin_settings_credential_binding_test.go
- internal/config/admin_settings_test.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4217eca204
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…saves Conversion now runs each adopted provider through the same validation as an admin write, clamping names derived from long hosts, so an address the AI clients never accepted (a query string, credentials in the URL) leaves the job unconfigured instead of storing an entry that blocks every later provider edit. AI Services refetches the provider list after a save, so "used by" follows the job choices at once, and the transcription error hint names the speech-to-text provider instead of the retired base URL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The outside-diff finding on |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Speech resolved its endpoint and key independently of text, so a server that stored only ai.asr_api_key transcribed against the default OpenAI endpoint with it, even when a ChatGPT plan served text. The conversion now resolves that fallback on its own instead of requiring a text provider. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89c964f869
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| provider, err := NormalizeAIProvider(AIProvider{ | ||
| ID: NewAIProviderID(providerType), | ||
| Type: providerType, | ||
| Name: uniqueAIProviderName(r, name), | ||
| BaseURL: providerBaseURL, | ||
| APIKey: apiKey, | ||
| Capabilities: capabilities, | ||
| }) | ||
| if err != nil { | ||
| // An entry that fails validation would block every later provider | ||
| // edit. An address it rejects (a query string, credentials in the URL) | ||
| // never worked with the AI clients, so the job stays unconfigured. | ||
| return "" |
There was a problem hiding this comment.
Backward compatibility regression in internal/config/ai_providers.go: NormalizeAIProvider rejects legacy endpoints using URL-based Basic authentication and silently omits them from conversion, although the existing client passes URL userinfo to net/http and leaves Authorization unset when no API key is configured. Preserve working custom connections such as https://user:[email protected]/v1 with an empty API key instead of leaving the job unconfigured and marking conversion complete.
Prompt for LLM
File internal/config/ai_providers.go:
Line 491 to 503:
Backward compatibility regression in internal/config/ai_providers.go: NormalizeAIProvider rejects legacy endpoints using URL-based Basic authentication and silently omits them from conversion, although the existing client passes URL userinfo to net/http and leaves Authorization unset when no API key is configured. Preserve working custom connections such as https://user:[email protected]/v1 with an empty API key instead of leaving the job unconfigured and marking conversion complete.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Deliberate. A provider's base URL is returned by the provider list operation and shown on its row, so credentials embedded in it would reach every administrator and the UI in plain text; NormalizeAIProvider refuses them for that reason, on create and on conversion alike. Such a setup converts to no provider for that job, and the admin re-adds it with the key in the API key field. Basic auth through URL userinfo was not a documented configuration. Leaving this open for a maintainer to overrule.
There was a problem hiding this comment.
Understood. Rejecting URL userinfo is intentional credential protection, so the fix should not be to allow credentials in a base URL exposed by the provider API and UI.
One caveat: moving a password into the API key field does not preserve HTTP Basic authentication; those are different authentication mechanisms. An affected administrator would need to reconfigure the proxy to accept API-key authentication or use another supported setup.
I would narrow the original suggestion to an upgrade compatibility concern, rather than a validation bug: a previously working, undocumented configuration is skipped, and conversion is marked complete. If that tradeoff is accepted, explicitly documenting the unsupported configuration and providing a credential-safe migration warning would make the behavior clearer. Leaving the decision to a maintainer is reasonable.
There was a problem hiding this comment.
Agreed, and a correction to my earlier reply: moving the password into the API key field does not keep HTTP Basic working. 370fdd6 keeps the refusal but makes it visible. The conversion reports the legacy setting it could not convert, startup logs a warning naming the setting (never the URL), and docs/admin-settings-api.md states that HTTP Basic through the URL is unsupported and such a proxy needs to accept the provider's key. Leaving the thread open for the maintainer decision.
There was a problem hiding this comment.
Thanks for the correction. Based on your description, 370fdd627 addresses the silent-conversion concern without exposing URL credentials: the warning identifies only the legacy setting, and the documentation explains that HTTP Basic is unsupported and API-key authentication is not an equivalent replacement.
The remaining compatibility break is intentional and now visible. I agree with leaving the thread open for the maintainer to decide whether that migration tradeoff is acceptable.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
A job could switch providers but not release one, so an unused provider stayed in use and could not be removed. Each provider select now offers None, which saves an empty binding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35ad67362a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Choosing None for the text model now saves while subtitle and description translation are off; with either on, Save asks to turn them off first. The conversion trims a trailing slash from the stored text URL before deciding whether that endpoint also served speech, so https://api.openai.com/ keeps its speech binding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6737e15a-1140-4d20-91c1-8ed0500d0f4e
Files selected for processing: 8-
docs/architecture/v1-scope.mdinternal/ai/llm/client_test.gointernal/ai/llm/transcribe.gointernal/config/ai_providers.gointernal/config/ai_providers_test.goweb/src/hooks/queries/admin/aiProviders.tsweb/src/pages/admin-settings/AISettings.test.tsxweb/src/pages/admin-settings/AISettings.tsx
Files skipped from review as they are similar to previous changes: 2-
- internal/ai/llm/client_test.go
- internal/ai/llm/transcribe.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
The embedding job joins in the stacked follow-up; declaring it with the new operations avoids a later response-enum addition, which the contract check treats as breaking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Clients added /v1 to a base URL unless it contained the substring /v1, so a host such as v1-embed.internal or a path such as /proxy/v1-router lost its version. llm.HasAPIVersion now checks path segments (v1, v2, v1beta), and the chat client and the provider conversion share it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f44d58da1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
PUT /admin/settings/{key} stored any provider id for a job, so a missing
or unsuitable provider silently disabled the job and blocked later provider
edits. It now runs the same registry check as the batch write.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
A legacy AI endpoint whose URL carries credentials or a query is refused by the registry, so its job stays unconfigured. The conversion now reports the setting, startup logs a warning naming it (never the URL), and the admin settings doc says HTTP Basic authentication through the URL is unsupported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
OpenRouter serves embedding models such as google/gemini-embedding-001 at /api/v1/embeddings, so the type now declares embeddings alongside chat and speech. A known type's capabilities are applied when the registry is read, so OpenRouter providers saved earlier can be chosen for embeddings too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c3634e0b-ed56-44e6-9412-41dc775c817b
Files selected for processing: 14-
cmd/silo/main.gocontracts/api/v2/breaking-approvals.jsoncontracts/api/v2/openapi.jsondocs/admin-settings-api.mdinternal/ai/llm/client.gointernal/ai/llm/client_test.gointernal/api/handlers/admin.gointernal/api/handlers/admin_settings_checks_test.gointernal/apiv2/admin_ai_providers.gointernal/config/ai_providers.gointernal/config/ai_providers_test.goweb/src/api/v2/schema.tsweb/src/pages/admin-settings/AISettings.test.tsxweb/src/pages/admin-settings/AISettings.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
When only subtitle_ai.base_url held a URL the registry refuses, the startup warning named ai.base_url, which was empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #3082
Validation tasks: changes #1165 C1 (passed 2026-10-11 on c32feb1). The case's AI Services steps now connect a provider and choose it for the text model and speech-to-text, instead of entering a base URL and key per model; the criterion (both models configured, connection tests pass, the feature switches work) is unchanged.
Each AI feature keeps its own copy of the provider it calls. Text translation reads
ai.base_urlandai.api_key, speech-to-text readsai.asr_base_urlandai.asr_api_key(falling back to the text endpoint and key when empty), and Recommendations keeps a third base URL and token. An admin enters the same OpenAI key on several pages, and a rotated key that misses one copy shows up later as failed jobs. Adding a provider means adding presets to each page.This PR adds one provider list to AI Services and makes text and speech-to-text choose a provider from it. The stacked follow-up moves recommendation embeddings onto the same list.
Approach
ai.auth_mode; choosing it keeps the API-key provider selected for when the admin switches back.ai.providers, edited only through new acting-admin operations under/api/v2/admin/ai/providers(list, create, update, delete, check, list models). The bindingsai.text_provider_idandai.speech_provider_idare ordinary settings validated against the list. Each node reloads after a provider write.ai.base_url/ai.api_key(and the oldersubtitle_ai.*rows) andai.asr_base_url/ai.asr_api_keyinto providers, so each job keeps the endpoint and key it used. The old rows stay in place, unread, so an older build still runs against the same database; writes to them are rejected.Web admin and server only. Apple, Android, and jellycompat clients do not read these settings.
docs/admin-settings-api.mdanddocs/architecture/ai-provider-authentication.mddescribe the contract.Validation
make lint-changedclean; tests pass for config, ai, api/handlers, apiv2, subtitles, contractledger, and contractspec.verify-apiv2-openapi,verify-apiv2-web-types, andverify-apiv2-fixturesare current; media route manifest and ledger updated.make test-webpassed.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3106/
Surface and build: web admin, AI Services, at this branch and the stacked follow-up.
Risks
ai.providersand would return it, keys included, to administrators.ai.*endpoint keys leave the admin settings surface before/api/v2locks.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Replace AI endpoint/key settings with a provider registry selected per job
ai.providers) holding endpoint, key, name, and capabilities per provider, plus text and speech provider-ID bindings that resolve the endpoints and keys used at runtime.llm.Config.ASRConfiguredrequiresASRBaseURLandASRModel, and connection checks select stored providers by binding ID only.ai.base_urlandai.api_keysettings are retired. On startup,convertLegacyAIProvidersin main.go converts stored legacy endpoints and keys into registry entries atomically and warns on refused values.NormalizeAdminSettingin admin_settings.go; a registry parse failure makesLoadFromDBfail;endpointURLonly treats full path segments likev1,v1betaas versioned; provider updates reject type changes and require an explicit key choice before moving a keyed provider to a different endpoint authority.Macroscope summarized 25eba20.