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) return await sdk.responses.create(payload, options)
} }
public async createVideo(params: CreateVideoParams) { public async createVideo(params: CreateVideoParams): Promise<OpenAI.Videos.Video> {
// TODO: implement it const sdk = await this.getSdkInstance()
throw new Error('Not implemented') return await sdk.videos.create(params.params, params.options)
} }
private async handlePdfFile(file: FileMetadata): Promise<OpenAI.Responses.ResponseInputFile | undefined> { 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> { public async createVideo(params: CreateVideoParams): Promise<CreateVideoResult> {
throw new Error('Not implemented') if (this.apiClient instanceof OpenAIResponseAPIClient) {
// if (this.apiClient instanceof OpenAIResponseAPIClient) { return this.apiClient.createVideo(params)
// return this.apiClient.createVideo(params) } else {
// } else { throw new Error('Video generation is not supported by this provider')
// throw new Error('Video generation is not supported by this provider') }
// }
} }
public getBaseURL(): string { public getBaseURL(): string {

View File

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