Skip to content

feat(ai): add OpenAI text service tiers - #3285

Merged
Quick104 merged 3 commits into
mainfrom
codex/openai-service-tiers
Oct 30, 2026
Merged

Quick104 merged 3 commits into
mainfrom
codex/openai-service-tiers

Conversation

@Quick104

@Quick104 Quick104 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Administrators cannot choose an OpenAI processing tier for subtitle and metadata translation. Add Default, Fast/Priority, and Ultrafast under Text model → Advanced for OpenAI API-key providers.

Related issue: N/A
Validation tasks: changes #1165 C1; changes #1164 C4; changes #1213 C2

Approach

Persist ai.service_tier with the text configuration. Fast/Priority uses Chat Completions; Ultrafast uses API-key-authenticated Responses with storage disabled, following OpenAI's Ultrafast guide. Incomplete or refused responses cannot replace source text. Default omits the parameter and preserves the OpenAI project's setting. Other providers, ChatGPT plans, speech, and embeddings ignore the saved tier.

An optional openai_service_tiers capability keeps older backends from offering an unsupported control. The API documentation and generated contracts are updated. Apple, Android, and Jellyfin need no protocol changes; the tier is applied by the server. Manual follow-up: Silo-Server/siloserver.org#157.

Validation

  • Isolated sandbox: all three choices passed unsaved connection tests and persisted through the real settings API. The local fixture provider received priority, ultrafast, or no tier as appropriate.
  • Desktop and phone-width browser checks passed without page errors. No paid OpenAI requests were made.
  • Focused Go tests cover endpoint selection, request/response contracts, transient retries, refusal/incomplete-output guards, provider scoping, atomic configuration snapshots, and connection checks. Full web tests, build, lint, formatting, and contract checks passed.
  • Full pre-PR gate attempted. Go build, vet, formatting, lint, generated contracts/fixtures, and hygiene checks passed. Production-target route inventory and Prometheus checks passed on Linux. The full local Go suite still fails in untouched media-routing, filesystem, and real-FFmpeg tests; the Jellyfin-routing and NFO failures also reproduce on unchanged main. The separate query-attribution race test passed.
  • Recheck AI generated subtitles — Web admin #1165 C1 configuration, AI generated subtitles — Server #1164 C4 provider failure/cost behavior, and AI metadata translation — Server #1213 C2 provider guards. Existing rate limits, concurrency bounds, and translation-preservation rules are unchanged. This does not resolve the separate provider-compliance review.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3285/

Surface and build: Web admin AI Services; baseline 5720a6465, changed ce55364b6.

Risks

Fast/Priority and Ultrafast can increase provider charges. Availability depends on the model and account; Silo does not silently retry at a lower tier after rejection. The backend must be updated before the frontend offers this control.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each new test meets Decide what to test in CONTRIBUTING.md.
  • Evidence includes the changed controls at desktop and phone widths.

AI Disclosure

  • Harness: OpenAI Codex desktop app.
  • Tool(s): Codex shell and agent tools, GitHub connector, Playwright, Fleet sandbox controller, and @silo-server/evidence.
  • Model(s): gpt-6.1-sol.
  • Involvement: Fully AI-generated implementation; human verification pending.
  • Adversarial review: Independent review found that Ultrafast needs Responses and that transient Responses failures must retry. Both are corrected with protocol and failure-handling tests; independent re-review found no remaining actionable issues.

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T18:00:43.240387Z ce55364 New commits
🔒 Security Review ✅ Completed 2026-10-30T18:02:35.825737Z ce55364 New commits
ℹ️ 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" or "@codex security review".

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

silo-kody Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Findings

Actionable comments posted: 1

Recent 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: 1cc47ffc-1388-480d-a22b-bee31766b189
Commits

Reviewing files that changed from the base of the PR and between 0be7614 and ce55364.

Files selected for processing: 6
  • docs/admin-settings-api.md
  • internal/ai/llm/api_responses.go
  • internal/ai/llm/client.go
  • internal/ai/llm/client_test.go
  • internal/ai/llm/responses.go
  • internal/ai/llm/responses_test.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.

Walkthrough

This change adds a configurable service tier for OpenAI API-key text requests. It resolves the setting for supported providers, routes ultrafast requests through the Responses API, advertises available choices through admin capabilities, and adds a selector to admin settings.

Changes: OpenAI service tiers

Layer / File(s) Summary
Resolve and load service-tier settings
internal/config/*, internal/ai/chatgpt/selection.go, internal/ai/chatgpt/selection_test.go
Configuration accepts an empty tier, priority, or ultrafast. Resolution excludes ChatGPT auth and unsupported or invalid providers. Text configuration reads the effective setting.
Send service tiers through the LLM client
internal/ai/llm/*, internal/api/router.go, internal/api/handlers/admin_settings_checks.go, internal/api/handlers/admin_settings_checks_test.go, internal/api/handlers/admin_settings_check_service_test.go
The LLM client sends non-empty tiers through Chat Completions. For ultrafast, it uses the Responses API. The Responses path handles response content and retryable or permanent errors. Server configuration and connection checks pass the tier to the client.
Advertise tiers and add the admin selector
internal/apiv2/admin_ai_chatgpt.go, internal/apiv2/admin_ai_chatgpt_test.go, web/src/api/v2/schema.ts, contracts/api/v2/openapi.json, web/src/pages/admin-settings/AISettings.tsx, web/src/lib/adminSettingsSearch.ts, docs/admin-settings-api.md
Capabilities advertise default, priority, and ultrafast. The admin selector uses the advertised choices for supported OpenAI providers and stores Default as an empty value. Schemas and documentation describe the choices and behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClientChat
  participant ChatCompletions
  participant APIResponses
  ClientChat->>ChatCompletions: Send request for non-ultrafast tier
  ClientChat->>APIResponses: Send request for ultrafast tier
  APIResponses-->>ClientChat: Return completed text or error
Loading

Possibly related PRs

Suggested reviewers: rhainland

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding OpenAI text service tiers.
Description check Passed The description directly explains the problem, implementation, validation, risks, and scope of the service-tier changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 15 functions across 21 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0be76145f3

ℹ️ 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".

Comment thread internal/ai/llm/client.go
Model: cfg.ChatModel,
Messages: messages,
ReasoningEffort: cfg.ReasoningEffort,
ServiceTier: cfg.ServiceTier,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route Ultrafast requests through the Responses API

When an administrator selects Ultrafast for an OpenAI API-key provider, this sends service_tier: "ultrafast" to /v1/chat/completions, so connection checks and translation requests use a tier unsupported by that endpoint. The official Chat Completions reference lists only auto, default, flex, scale, priority, and fast; the Ultrafast documentation configures it through Responses. Route this selection through an API-key-authenticated Responses implementation, or stop advertising Ultrafast until that path is supported. The current serialization test uses a fake transport that accepts any tier, so it does not catch this incompatibility.

Useful? React with 👍 / 👎.

@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown

The new Service tier selector and explanatory text in Text model → Advanced (web/src/pages/admin-settings/AISettings.tsx) lack reviewable evidence. The PR says desktop and phone-width comparisons and a recording are prepared, but no captures or published evidence-page link are included. Please attach or publish before-and-after evidence for desktop and mobile web on the Web admin AI Services surface; the PR already names the baseline and changed commits.

Suggested fix: No diff — publish the prepared evidence and add its link under Evidence, or attach the captures to the PR.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added enhancement New feature or request priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Oct 30, 2026
"ai.chat_model",
"ai.auth_mode",
"ai.reasoning_effort",
"ai.service_tier",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules high

Unsupported settings requests occur because adding ai.service_tier unconditionally to TEXT_AI_KEYS also adds it to KEYS, causing useSettingsForm to request it from older servers; hiding the control when openai_service_tiers is absent does not gate that request. Keep the base keys separate, request ai.service_tier only when the server's settings capability revision supports it, and use the supported key set for connection checks.

Kody rule violation: Preserve explicit unlimited settings and apply metered defaults before playback

Prompt for LLM

File web/src/pages/admin-settings/AISettings.tsx:

Line 48:

Unsupported settings requests occur because adding ai.service_tier unconditionally to TEXT_AI_KEYS also adds it to KEYS, causing useSettingsForm to request it from older servers; hiding the control when openai_service_tiers is absent does not gate that request. Keep the base keys separate, request ai.service_tier only when the server's settings capability revision supports it, and use the supported key set for connection checks.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. size/XL 500–999 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body labels Oct 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: 733ee724-441e-4522-950d-d8ad5aa086ae
Commits

Reviewing files that changed from the base of the PR and between e9bea94 and 0be7614.

Files selected for processing: 21
  • contracts/api/v2/openapi.json
  • docs/admin-settings-api.md
  • internal/ai/chatgpt/selection.go
  • internal/ai/chatgpt/selection_test.go
  • internal/ai/llm/client.go
  • internal/ai/llm/client_test.go
  • internal/ai/llm/text_config_test.go
  • internal/api/handlers/admin_settings_check_service_test.go
  • internal/api/handlers/admin_settings_checks.go
  • internal/api/handlers/admin_settings_checks_test.go
  • internal/api/router.go
  • internal/apiv2/admin_ai_chatgpt.go
  • internal/apiv2/admin_ai_chatgpt_test.go
  • internal/config/admin_settings.go
  • internal/config/ai_providers.go
  • internal/config/ai_settings_test.go
  • internal/config/config.go
  • internal/config/db_loader.go
  • web/src/api/v2/schema.ts
  • web/src/lib/adminSettingsSearch.ts
  • web/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; 1 remain after this review.

Comment thread internal/apiv2/admin_ai_chatgpt.go Resolved
@silo-triage silo-triage Bot removed the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 30, 2026
@silo-kody

silo-kody Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 force-pushed the codex/openai-service-tiers branch from 8298209 to ce55364 Compare October 30, 2026 17:59
@silo-kody

silo-kody Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown

Major changes

Minor change

The Validation tasks: line already names these cases.

Suggested fix: No diff — keep the line and record the cases for re-validation after merge.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: 1cc47ffc-1388-480d-a22b-bee31766b189
Commits

Reviewing files that changed from the base of the PR and between 0be7614 and ce55364.

Files selected for processing: 6
  • docs/admin-settings-api.md
  • internal/ai/llm/api_responses.go
  • internal/ai/llm/client.go
  • internal/ai/llm/client_test.go
  • internal/ai/llm/responses.go
  • internal/ai/llm/responses_test.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.

Comment on lines +144 to +145
requests Fast/Priority processing through Chat Completions; `ultrafast` uses
API-key-authenticated Responses with storage disabled. Only completed text

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Enforce the output guard for Chat Completions or narrow this statement.

priority uses Chat Completions, but chatCompletionResponse only checks for non-empty message.content. It does not inspect the response completion state. A response with partial content and a non-complete finish_reason can therefore return as successful text. The Responses path has separate completion and refusal checks, but those checks do not cover priority. Add equivalent validation to Chat Completions, or scope this guarantee to ultrafast Responses requests. (raw.githubusercontent.com)

@Quick104
Quick104 merged commit f6a7e44 into main Oct 30, 2026
26 of 27 checks passed
@Quick104
Quick104 deleted the codex/openai-service-tiers branch October 30, 2026 18:08
@macroscopeapp

macroscopeapp Bot commented Oct 30, 2026

Copy link
Copy Markdown

Major validation impact: the shared Client.Chat path now sends priority to Chat Completions and routes ultrafast through the Responses API. The recorded #1164 C4 and #1213 C2 checks used the local/default provider path, so they do not cover these tier-specific provider-failure and cost paths. The PR must explain why the previously validated configuration, failure, and cost behavior changes; #1165 C1, #1164 C4, and #1213 C2 need re-validation after merge.

The separate provider-compliance gate recorded under #1164 C4 remains blocked pending maintainer review; this PR does not unblock it.

Validation tasks: changes #1165 C1; changes #1164 C4; changes #1213 C2

Suggested fix: No diff — keep the current task line and document the tier-specific re-validation rationale in the PR description.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant