fix: handle grok2 synchronous video response, skip async polling
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
shiyue
2026-03-12 02:08:04 +00:00
parent ae105d06ef
commit affc689724

View File

@@ -176,6 +176,15 @@ export async function generateVideoViaOpenAICompat(request: OpenAICompatVideoReq
input_reference: inputReference,
} as Parameters<typeof client.videos.create>[0])
// 同步完成的情况(如 grok2api响应里直接携带 url 和 status=completed
const rawResponse = response as unknown as Record<string, unknown>
if (rawResponse.status === 'completed' && typeof rawResponse.url === 'string' && rawResponse.url) {
return {
success: true,
videoUrl: rawResponse.url as string,
}
}
if (!response.id || typeof response.id !== 'string') {
throw new Error('OPENAI_COMPAT_VIDEO_CREATE_INVALID_RESPONSE: missing video id')
}