Skip to content

feat: move Kling and Grok video onto the job contract - #350

Merged
kiyeonjeon21 merged 1 commit into
mainfrom
feat/kling-grok-video-contract
Oct 4, 2026
Merged

kiyeonjeon21 merged 1 commit into
mainfrom
feat/kling-grok-video-contract

Conversation

@kiyeonjeon21

Copy link
Copy Markdown
Contributor

Second PR of the provider interface work (after #349).

Kling

  • Service codes decide the error kind (from the official table). Code 1102 "resource pack exhausted" arrives as HTTP 429, and it now reads as quota and is not retried. Codes inside a 200 body are handled too.
  • The job handle records its task type (text2video, image2video, or video-extend), so polling no longer needs it passed in.
  • VideoJobState.outputId carries the Kling video_id that extension needs.
  • Extension is a continuation: from: {kind: "extend"}. Edit throws unsupported. There is no cancel method, since Kling has no cancel API.

Grok

  • Edit and extend are continuations over /videos/edits and /videos/extensions, which are new capabilities.
  • Only classic grok-imagine-video can do them. Probed live: -1.5 and -1.5-lite answer 400 "Video extension is not supported for this model". Continuations default to classic and refuse other models before sending. The catalog note and xai.md record this.
  • An expired job is reported as timeout. Cancel stays out of the contract because xAI documents no cancel endpoint; the legacy best-effort method is unchanged.

Shared

  • providerRequest classifies before deciding to retry, so a 429 meaning "out of credits" is not retried. It also takes a per-provider classify hook.
  • Error parsing: numeric error codes are kept, and "risk control" and "content security" now read as moderation, which is Kling's real wording.

Verification

  • Contract suite: Kling and Grok both pass it. Provider-specific tests cover Kling code mapping, the 429 quota case without retry, a code in a 200 body, image2video polling, rejecting a data URI, and extension by video_id. They also cover Grok edit and extend request shapes, refusing a continuation on the wrong model, and expiry.
  • Checks: pnpm build, lint, typecheck, tests (providers 193, CLI 1215, MCP 73), pre-push gate.
  • Live:
    • vibe generate video -p kling --duration 3: a 3.04 s clip.
    • -p grok --grok-model lite --duration 2: a 2.04 s clip.
    • Grok extend through the contract on classic: 2 s + 2 s = 4.04 s.
    • The rejected model attempts came back as classified invalid-request errors.
    • About $0.43 in total.

https://claude.ai/code/session_011S1BLTaFctZNQzGERpkCuA

Kling and Grok now implement `VideoGenerator` and pass the contract suite;
their older methods wrap it, so CLI callers are unchanged.

Kling
- Its service codes decide the error kind (1102 "resource pack exhausted"
  arrives as HTTP 429 and is quota, not a rate limit), including codes
  inside a 200 body.
- The job handle records the task type, so polling no longer needs it
  passed in, and `outputId` carries the video ID that extension needs.
- Extension is a continuation (`from: {kind: "extend"}`).

Grok
- Edit and extend are continuations over xAI's /videos/edits and
  /videos/extensions. Only classic grok-imagine-video can do them
  (probed live: 1.5 and 1.5-lite answer 400), so continuations default to
  it and refuse other models before sending.
- An expired job is a timeout; cancel stays out of the contract because
  xAI documents no cancel endpoint.

Shared
- providerRequest classifies before retrying, so a 429 that means exhausted
  credits is not retried, and takes a per-provider `classify` hook.
- Numeric error codes are kept; "risk control" and "content security" read
  as moderation (Kling's wording).

Claude-Session: https://claude.ai/code/session_011S1BLTaFctZNQzGERpkCuA
@vercel

vercel Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vibeframe Ready Ready Preview Oct 4, 2026 2:07pm UTC

Request Review

@kiyeonjeon21
kiyeonjeon21 merged commit eb5a367 into main Oct 4, 2026
6 checks passed
@kiyeonjeon21
kiyeonjeon21 deleted the feat/kling-grok-video-contract branch October 4, 2026 14:11

This branch was successfully deployed

1 active deployment
Preview — ac8275dd Deployed Oct 4, 2026 by vercel[bot]
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.

1 participant