[Bugfix] Fix /v1/audio/speech usage token accounting for Qwen3-TTS (#4646) (#4673)

Signed-off-by: Yueqian Lin <linyueqian@outlook.com>
Co-authored-by: Sy03 <1370724210@qq.com>
This commit is contained in:
Yueqian LinandSy03 authored and GitHub committed 2026-06-27 06:13:31 +08:00
1 parent c582805e7a
commit b66cd024b9
7 files changed
+697 -8

No files matched your search

+4 -1
View File
@@ -1317,7 +1317,10 @@ async def create_speech_batch(request: BatchSpeechRequest, raw_request: Request)
result = await handler.create_speech_batch(request)
if isinstance(result, ErrorResponse):
return _error_response_to_json_response(result)
return JSONResponse(content=result.model_dump())
# exclude_none so optional per-item fields are omitted rather than
# serialized as null: errored items drop `usage`/`audio_data`/`media_type`,
# successful items drop `error`. Matches the documented batch response shape.
return JSONResponse(content=result.model_dump(exclude_none=True))
except (EngineGenerateError, EngineDeadError) as exc:
return _create_engine_error_json_response(raw_request, exc)
except ValueError as e: