Skip to content

feat: generic OpenAI-compatible video custom provider - #9818

Closed
oyi77 wants to merge 0 commit into
diegosouzapw:release/v3.8.50from
oyi77:feat/generic-openai-video-provider
Closed

feat: generic OpenAI-compatible video custom provider#9818
oyi77 wants to merge 0 commit into
diegosouzapw:release/v3.8.50from
oyi77:feat/generic-openai-video-provider

Conversation

@oyi77

@oyi77 oyi77 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a generic OpenAI-compatible video generation path so users can add custom video providers (base URL + API key) without per-provider code changes.

Changes

Core Implementation

  • open-sse/handlers/videoGeneration/openai.ts (new): Generic handler with:

    • resolveVideoEndpoint() - resolves endpoint URL from credentials (prefers providerSpecificData.baseUrl)
    • fetchVideoEndpoint() - fetches with timeout, error handling, and logging
    • handleOpenAIVideoGeneration() - main handler accepting duration parameter
  • open-sse/handlers/videoGeneration.ts:

    • Added resolveVideoBaseUrl() helper (mirrors resolveImageBaseUrl)
    • Added import for handleOpenAIVideoGeneration
    • Added dispatch for openai-video format before vertex-veo
    • Updated synthetic config to use format: "openai-video" for custom providers
    • Fixed fallback to only use OpenAI handler for resolvedProvider (custom models), returning Unsupported video format for unknown built-in formats
    • Restored adobe-firefly-video dispatch branch
  • src/app/api/v1/videos/generations/route.ts: Already had correct custom model logic:

    • Imports getAllCustomModels
    • Scans custom models for supportedEndpoints.includes("videos")
    • Parses providerId/modelId from custom model registry
    • Resolves credentials via getProviderCredentialsWithQuotaPreflight(provider, null, null, requestedModel)
    • Passes resolvedProvider to handler
  • src/shared/validation/schemas/provider.ts: Added "videos" to supportedEndpoints enum

Tests

  • tests/unit/video-generation-handler.test.ts: Added handler-level test for custom provider
  • tests/unit/video-custom-provider-route.test.ts (new): Route-level tests covering:
    • Custom provider with videos endpoint (happy path)
    • Custom provider without videos endpoint (400)
    • Unknown custom provider (400)

Design Decisions (Locked)

  • Video only; model accepts duration
  • Custom models tagged "videos" in supportedEndpoints
  • Handler signature gains resolvedProvider (images parity)
  • New format "openai-video" dispatched FIRST (before vertex-veo)
  • Route builds fallback providerConfig {id, baseUrl, authType:"apikey", authHeader:"bearer", format:"openai-video"} when !providerConfig && resolvedProvider
  • Credentials via getProviderCredentialsWithQuotaPreflight(provider, null, null, requestedModel)
  • Call-log shape mirrors existing video handlers
  • Error text sanitized via sanitizeErrorMessage
  • fetchWithTimeout from @/shared/utils/fetchTimeout (no .ts)

Verification

  • npm run typecheck:core passes
  • 17 video tests pass (3 new route tests + 1 new handler test + 13 existing)
  • No regressions in image generation tests

Verification

  • npm run typecheck:core — PASS (zero output, exit 0)
  • tests/unit/video-custom-provider-route.test.ts — 3/3 pass
  • tests/unit/video-generation-handler.test.ts — 14/14 pass
  • tests/unit/image-generation-handler.test.ts — 43/43 pass (no regression)

Coverage (c8, isolated output dirs)

Suite File stmts funcs lines
route open-sse/handlers/videoGeneration/openai.ts 85.89% 100% 85.89%
handler open-sse/handlers/videoGeneration/openai.ts 84.61% 100%
handler open-sse/handlers/videoGeneration.ts 62.53%
handler open-sse/handlers/imageGeneration.ts 68.32%

Scoping note (official Sora SDK)

The openai-video handler is a gateway-house convention for OpenAI-compatible video
providers — POST /v1/videos/generations → synchronous MP4 response, credentials from the
custom-provider connection (baseUrl + API key). This is not the official OpenAI SDK
Sora job API (POST /v1/videosGET /videos/{id} polling). Sora-style async job providers
are planned in the follow-up mapping layer (generationConfig presets + job/poll branch).

@oyi77
oyi77 requested a review from diegosouzapw as a code owner August 8, 2026 19:54
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs.

2 similar comments
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs.

@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs.

oyi77 added a commit to oyi77/OmniRoute that referenced this pull request Aug 9, 2026
… test coverage (diegosouzapw#9818)

- job.ts: presets (agnes-video-job, muapi-video-job) with submit→poll→done executor
- videoGeneration.ts: generationConfig.preset dispatch branch + mediaGenerationRoute pass-through
- provider-models/route.ts + models.ts: generationConfig persisted on addCustomModel
- provider schema: generationConfig optional field
- tests: resolvedProvider bare-model + job preset happy/failed/unknown paths
- docs/video-preset-generation.md
@diegosouzapw

Copy link
Copy Markdown
Owner

Obrigado pelo PR. Mantive a revisão de fix-in-place e não foi possível concluir o ajuste completo aqui:

  • Para os PRs em fork: não consigo aplicar push de correção diretamente na sua branch.
    Por favor, faça um rebase/sync com release/v3.8.50, resolva conflitos se houver, e rode os checks dessa branch.
    Se preferir, posso aplicar a correção na próxima rodada assim que você mandar o branch atualizado ou confirmar que o PR está limpo pra esse merge.

oyi77 added a commit to oyi77/OmniRoute that referenced this pull request Aug 9, 2026
…ecks

- file-size-baseline: open-sse/handlers/videoGeneration.ts 1063 -> 1197
  with _rebaseline_2026_08_09_9818_openai_video_dispatch justification
  (resolveVideoBaseUrl + getCustomModelVideoPreset dispatch wiring for
  generic OpenAI-compatible video custom provider, PR diegosouzapw#9818)
- job.ts: use explicit `ok === false` for submitResult/pollResult guards so
  TypeScript narrows the union (build reproducibility; real tsc blocker
  when the result type is not a discriminated boolean)
diegosouzapw added a commit that referenced this pull request Aug 9, 2026
…ovider (#9844)

* feat: generic OpenAI-compatible video custom provider

Adds a generic OpenAI-compatible video generation path so users can add
custom video providers (base URL + API key) without per-provider code.

Changes:
- open-sse/handlers/videoGeneration/openai.ts (new): generic handler
  with resolveVideoEndpoint, fetchVideoEndpoint, handleOpenAIVideoGeneration
- open-sse/handlers/videoGeneration.ts: added resolveVideoBaseUrl(),
  dispatch for 'openai-video' format before 'vertex-veo', synthetic config
  for custom providers, fallback for resolvedProvider
- src/app/api/v1/videos/generations/route.ts: scans custom models for
  supportedEndpoints.includes('videos'), resolves credentials via
  getProviderCredentialsWithQuotaPreflight, passes resolvedProvider
- src/shared/validation/schemas/provider.ts: added 'videos' to
  supportedEndpoints enum
- tests/unit/video-generation-handler.test.ts: handler-level test for
  custom provider
- tests/unit/video-custom-provider-route.test.ts (new): route-level tests
  covering custom provider with/without videos endpoint, unknown provider

All verification:
- typecheck:core passes
- 17 video tests pass (3 new route tests + 1 new handler test)
- no regressions in image generation tests

* test(video): drop duplicated test.after cleanup in custom-provider route test

* feat(video): declarative job presets + dispatcher, route, and handler test coverage (#9818)

- job.ts: presets (agnes-video-job, muapi-video-job) with submit→poll→done executor
- videoGeneration.ts: generationConfig.preset dispatch branch + mediaGenerationRoute pass-through
- provider-models/route.ts + models.ts: generationConfig persisted on addCustomModel
- provider schema: generationConfig optional field
- tests: resolvedProvider bare-model + job preset happy/failed/unknown paths
- docs/video-preset-generation.md

* fix(video): restore dashscope + novita handler imports dropped in refactor

* refactor(video): extract Runway helpers

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: oyi77 <oyi77@users.noreply.github.com>
@oyi77 oyi77 closed this Aug 9, 2026
@oyi77
oyi77 force-pushed the feat/generic-openai-video-provider branch from 8033525 to 382449d Compare August 9, 2026 17:07
@mergify

mergify Bot commented Aug 9, 2026

Copy link
Copy Markdown

⚠️ The sha of the head commit of this PR conflicts with #8875. Mergify cannot evaluate rules on this PR. Once #8875 is merged or closed, Mergify will resume processing this PR. ⚠️

@oyi77

oyi77 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the feature content is already merged upstream:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants