GeezerVison is showing github.com — feat(ai): add the xAI video entrypoint and keep video provider option… · anomalyco/opencode@3518013
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/ai/package.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 136 | 136 | "./providers/vercel-ai-gateway/responses": "./src/providers/vercel-ai-gateway/responses.ts", | 137 | 137 | "./providers/xai": "./src/providers/xai.ts", | 138 | 138 | "./providers/xai/images": "./src/providers/xai/images.ts", | | 139 | + "./providers/xai/videos": "./src/providers/xai/videos.ts", | 139 | 140 | "./providers/zai": "./src/providers/zai.ts", | 140 | 141 | "./providers/zai-coding-plan": "./src/providers/zai-coding-plan.ts", | 141 | 142 | "./providers/zai-coding-plan/chat": "./src/providers/zai-coding-plan/chat.ts", | |
Collapse file Copy file name to clipboardExpand all lines: packages/ai/src/providers/google.ts +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -74,7 +74,8 @@ export const configure = (input: Config = {}) => { | 74 | 74 | interactionsRoute(input).model<GoogleInteractions.ProviderOptionsInput>({ id: modelID }), | 75 | 75 | image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => | 76 | 76 | GoogleImages.model({ ...media, id: modelID, providerOptions }), | 77 | | - video: (modelID: string | ModelID) => GoogleInteractionsVideo.model({ ...media, id: modelID }), | | 77 | + video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => | | 78 | + GoogleInteractionsVideo.model({ ...media, id: modelID, providerOptions }), | 78 | 79 | speech: (modelID: string | ModelID) => GoogleSpeech.model({ ...media, id: modelID }), | 79 | 80 | transcription: (modelID: string | ModelID) => GoogleTranscription.model({ ...media, id: modelID }), | 80 | 81 | embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => | @@ -94,7 +95,10 @@ export const imageModel = (modelID: string, settings?: Settings) => { | 94 | 95 | const input = toConfig(settings) | 95 | 96 | return configure(input).image(modelID, input.providerOptions) | 96 | 97 | } | 97 | | -export const videoModel = (modelID: string, settings?: Settings) => configure(toConfig(settings)).video(modelID) | | 98 | +export const videoModel = (modelID: string, settings?: Settings) => { | | 99 | + const input = toConfig(settings) | | 100 | + return configure(input).video(modelID, input.providerOptions) | | 101 | +} | 98 | 102 | export const embeddingModel = (modelID: string, settings?: Settings) => { | 99 | 103 | const input = toConfig(settings) | 100 | 104 | return configure(input).embedding(modelID, input.providerOptions) | |
Collapse file Copy file name to clipboardExpand all lines: packages/ai/src/providers/xai.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,7 +100,8 @@ export const configure = (input: Config = {}) => { | 100 | 100 | chat, | 101 | 101 | image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => | 102 | 102 | XAIImages.model({ ...media, id: modelID, providerOptions }), | 103 | | - video: (modelID: string | ModelID) => XAIVideo.model({ ...media, id: modelID }), | | 103 | + video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => | | 104 | + XAIVideo.model({ ...media, id: modelID, providerOptions }), | 104 | 105 | configure, | 105 | 106 | } | 106 | 107 | } | @@ -114,6 +115,10 @@ export const imageModel = (modelID: string, settings?: Settings) => { | 114 | 115 | const input = toConfig(settings) | 115 | 116 | return configure(input).image(modelID, input.providerOptions) | 116 | 117 | } | | 118 | +export const videoModel = (modelID: string, settings?: Settings) => { | | 119 | + const input = toConfig(settings) | | 120 | + return configure(input).video(modelID, input.providerOptions) | | 121 | +} | 117 | 122 | export const responses = provider.responses | 118 | 123 | export const chat = provider.chat | 119 | 124 | export const image = provider.image | |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +export { videoModel as model } from "../xai.js" | | 2 | +export type { Settings } from "../xai.js" |
Collapse file Copy file name to clipboardExpand all lines: packages/ai/test/provider/media-entrypoints.test.ts +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -561,6 +561,15 @@ const videos: ReadonlyArray<Case<VideoModel>> = [ | 561 | 561 | auth: ["x-goog-api-key", "google-key"], | 562 | 562 | provider: "google", | 563 | 563 | }, | | 564 | + { | | 565 | + name: "xai", | | 566 | + load: async () => { | | 567 | + const { model } = await import("@opencode/ai/providers/xai/videos") | | 568 | + return model("grok-imagine-video-1.5", { ...shared, apiKey: "xai-key" }) | | 569 | + }, | | 570 | + url: "https://api.x.ai/v1/videos/generations", | | 571 | + auth: ["authorization", "Bearer xai-key"], | | 572 | + }, | 564 | 573 | ] | 565 | 574 |
| 566 | 575 | describe("video entrypoints", () => { | @@ -573,6 +582,21 @@ describe("video entrypoints", () => { | 573 | 582 | ) | 574 | 583 | }) | 575 | 584 |
| | 585 | +describe("video entrypoint model options", () => { | | 586 | + // Model-level options from settings (as models.dev or config set them) become defaults on every request. | | 587 | + for (const entry of [ | | 588 | + { name: "xai", modelID: "grok-imagine-video-1.5", load: () => import("@opencode/ai/providers/xai/videos") }, | | 589 | + { name: "google", modelID: "gemini-omni-1.2-flash", load: () => import("@opencode/ai/providers/google/videos") }, | | 590 | + ]) | | 591 | + it.effect(`providers/${entry.name}/videos keeps provider options from settings`, () => | | 592 | + Effect.gen(function* () { | | 593 | + const { model } = yield* Effect.promise(entry.load) | | 594 | + const calls = yield* sentVideo(model(entry.modelID, { apiKey: "key", future_option: true })) | | 595 | + expect(JSON.parse(calls[0].body).future_option).toBe(true) | | 596 | + }), | | 597 | + ) | | 598 | +}) | | 599 | + | 576 | 600 | describe("decision entrypoints", () => { | 577 | 601 | for (const entry of decisions) | 578 | 602 | it.effect(`providers/${entry.name}/decisions sends a configured request`, () => | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/src/provider.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -180,6 +180,7 @@ const builtins = new Map<string, () => Promise<unknown>>([ | 180 | 180 | ], | 181 | 181 | ["@opencode/ai/providers/xai", () => import("@opencode/ai/providers/xai")], | 182 | 182 | ["@opencode/ai/providers/xai/images", () => import("@opencode/ai/providers/xai/images")], | | 183 | + ["@opencode/ai/providers/xai/videos", () => import("@opencode/ai/providers/xai/videos")], | 183 | 184 | ["@opencode/ai/providers/zai", () => import("@opencode/ai/providers/zai")], | 184 | 185 | ["@opencode/ai/providers/zai/chat", () => import("@opencode/ai/providers/zai/chat")], | 185 | 186 | ["@opencode/ai/providers/zai/images", () => import("@opencode/ai/providers/zai/images")], | |
|