feat(video): implement OpenAI video creation support

Add video creation functionality using OpenAI SDK. Update types to match OpenAI's video API and implement the actual creation method in the OpenAI client.
This commit is contained in:
icarus 2025-10-11 19:19:54 +08:00
parent 612d3756cf
commit a1fde0db38
3 changed files with 12 additions and 17 deletions

View File

@ -153,9 +153,9 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient<
return await sdk.responses.create(payload, options)
}
public async createVideo(params: CreateVideoParams) {
// TODO: implement it
throw new Error('Not implemented')
public async createVideo(params: CreateVideoParams): Promise<OpenAI.Videos.Video> {
const sdk = await this.getSdkInstance()
return await sdk.videos.create(params.params, params.options)
}
private async handlePdfFile(file: FileMetadata): Promise<OpenAI.Responses.ResponseInputFile | undefined> {

View File

@ -181,12 +181,11 @@ export default class AiProvider {
}
public async createVideo(params: CreateVideoParams): Promise<CreateVideoResult> {
throw new Error('Not implemented')
// if (this.apiClient instanceof OpenAIResponseAPIClient) {
// return this.apiClient.createVideo(params)
// } else {
// throw new Error('Video generation is not supported by this provider')
// }
if (this.apiClient instanceof OpenAIResponseAPIClient) {
return this.apiClient.createVideo(params)
} else {
throw new Error('Video generation is not supported by this provider')
}
}
public getBaseURL(): string {

View File

@ -1,10 +1,6 @@
export type CreateVideoRequest = {
type: 'openai'
}
import OpenAI from '@cherrystudio/openai'
export type CreateVideoParams = {
providerId: string
modelId: string
}
// Only OpenAI for now.
export type CreateVideoParams = { params: OpenAI.VideoCreateParams; options?: OpenAI.RequestOptions }
export type CreateVideoResult = {}
export type CreateVideoResult = OpenAI.Videos.Video