fix: handle grok2 synchronous video response, skip async polling
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -176,6 +176,15 @@ export async function generateVideoViaOpenAICompat(request: OpenAICompatVideoReq
|
|||||||
input_reference: inputReference,
|
input_reference: inputReference,
|
||||||
} as Parameters<typeof client.videos.create>[0])
|
} 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') {
|
if (!response.id || typeof response.id !== 'string') {
|
||||||
throw new Error('OPENAI_COMPAT_VIDEO_CREATE_INVALID_RESPONSE: missing video id')
|
throw new Error('OPENAI_COMPAT_VIDEO_CREATE_INVALID_RESPONSE: missing video id')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user