MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / generateVideoWithOpenAIRest

Method generateVideoWithOpenAIRest

ai/ai.ts:3147–3221  ·  view source on GitHub ↗
(
    providerConfig: ProviderConfig,
    model: string,
    prompt: string,
    images: AIContentPart[],
    imageMode: VideoImageMode,
    modeConfig: ProviderModeConfig,
    token?: AbortToken,
  )

Source from the content-addressed store, hash-verified

3145
3146 private async generateVideoWithOpenAIRest(
3147 providerConfig: ProviderConfig,
3148 model: string,
3149 prompt: string,
3150 images: AIContentPart[],
3151 imageMode: VideoImageMode,
3152 modeConfig: ProviderModeConfig,
3153 token?: AbortToken,
3154 ): Promise<AIVideo[]> {
3155 const baseUrl = resolveBaseUrl(providerConfig, modeConfig);
3156 const url = resolveEndpointUrl(
3157 baseUrl,
3158 modeConfig.endpoint || "chat/completions",
3159 );
3160 const authMode = resolveAuthMode(
3161 getProviderProfile(providerConfig),
3162 modeConfig,
3163 providerConfig,
3164 );
3165
3166 const authConfig = applyAuthConfig(authMode, providerConfig, url, {
3167 "Content-Type": "application/json",
3168 });
3169
3170 const content: any[] = [];
3171 if (prompt.trim()) {
3172 content.push({ type: "text", text: prompt.trim() });
3173 }
3174
3175 const safeImages = images.filter(
3176 (part) => part.type === "image_url" && !!parseDataUrl(part.image_url.url),
3177 );
3178 for (const img of safeImages) {
3179 content.push(img);
3180 }
3181
3182 let userContent: any = content;
3183 if (content.length === 1 && content[0].type === "text") {
3184 userContent = content[0].text;
3185 } else if (content.length === 0) {
3186 userContent = prompt || "Generate a video";
3187 }
3188
3189 const data: any = {
3190 model,
3191 messages: [{ role: "user", content: userContent }],
3192 stream: providerConfig.stream,
3193 };
3194
3195 const response = await this.httpClient.request(
3196 {
3197 url: authConfig.url,
3198 method: "POST",
3199 headers: authConfig.headers,
3200 data,
3201 ...(providerConfig.stream ? { responseType: "stream" } : {}),
3202 },
3203 token,
3204 );

Callers 1

Calls 8

resolveBaseUrlFunction · 0.85
resolveEndpointUrlFunction · 0.85
resolveAuthModeFunction · 0.85
getProviderProfileFunction · 0.85
applyAuthConfigFunction · 0.85
parseDataUrlFunction · 0.85
parseOpenAIResponseDataFunction · 0.85
requestMethod · 0.45

Tested by

no test coverage detected