Repository navigation
get_video_content raise error because of the mismatch Content-Type #175
Description
Activity
This error happened for me as well.
To be specific, this line:
python-sdk/src/openrouter/video_generation.py
Line 758 in ec85ab2
if utils.match_response(http_res, "200", "application/octet-stream"): is the offending line.
Reacted by Ivo StratevApologies for the noise if this is already known.
The originally reported symptom looks fixed.
get_video_contentnow sendsAccept: video/mp4and matches the200 video/mp4response, so theapplication/octet-streamvsvideo/mp4mismatch from the original report is gone (see #363).There is a narrower remaining case that I think is worth fixing, because it is a spec problem rather than an SDK problem.
What's still broken
The spec declares exactly one media type for a successful response:
.speakeasy/in.openapi.yaml,/videos/{jobId}/content:'200': content: video/mp4: schema: { format: binary, type: string } description: 'Video content stream. The body is the raw video bytes proxied from the upstream provider, and the Content-Type reflects the provider media type (video/mp4).'
which generates an exact-match assertion:
src/openrouter/video_generation.py:1028if utils.match_response(http_res, "200", "video/mp4"): return http_res
utils.match_content_typeis an exact match (plus*/<type>/*handling). So a200that carries a media type other thanvideo/mp4falls through every branch to:raise errors.OpenRouterDefaultError("Unexpected response received", http_res, http_res_text)
Reproducing against the SDK's own
match_responseat v1.3.19:Content-Typematches video/mp4result video/mp4yes returns the httpx.Responsevideo/mp4; charset=binaryyes returns the httpx.Responsevideo/webmno raises Unexpected response receivedvideo/quicktimeno raises Unexpected response receivedapplication/octet-streamno raises Unexpected response receivedThe last row is worth calling out: that is the exact Content-Type from the original report, so any provider or proxy pass that does not set a
video/mp4type still reproduces the original error.Suggested fix
In the OpenAPI source (not in the generated SDK), widen the
200response for/videos/{jobId}/content:'200': content: '*/*': schema: { format: binary, type: string } description: 'Video content stream. The body is the raw video bytes proxied from the upstream provider. Content-Type reflects the provider media type.'
match_content_typealready treats*and*/*as an unconditional match, which is the same mechanism the generated4XX/5XXfallbacks rely on.If
*/*is not accepted by the generator for a response body,video/*is the conservative alternative./audio/speechalready declaresaudio/*in the same spec and generatesmatch_response(http_res, "200", "audio/*"), which matches every audio subtype. Note thatvideo/*on its own would still not coverapplication/octet-stream, so it fixes thewebm/quicktimecases but not the originally reported one.This is not Python-specific
The same spec drives the other SDKs, and they carry the same exact-match assertion. In
typescript-sdkv-current,src/funcs/videoGenerationGetVideoContent.ts:222:M.stream(200, z.custom<ReadableStream<Uint8Array>>(...), { ctype: "video/mp4" }),
so a non-
video/mp4response surfaces there as aResponseValidationErrorrather than a return value. A one-line spec change fixes all of them at once.
in openrouter/video_generation.py
if utils.match_response(http_res, "200", "application/octet-stream"):return http_resbut the model like seedance 2.0 returns content with type "video/mp4"
she would go to there then raise error
raise errors.OpenRouterDefaultError("Unexpected response received", http_res, http_res_text)like that
Unexpected response received: Status 200 Content-Type video/mp4. Body: \x00\x00\x00 ftypisom\x00\