You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: OpenAITTSTarget sends speed=null, which gpt-4o-mini-tts rejects #4485
OpenAITTSTarget sends "speed": null when no speed is configured. gpt-4o-mini-tts rejects the request with a 400, so the target fails against that model unless the caller passes an explicit speed.
BadRequestError: Error code: 400 - Invalid type for 'speed': expected a decimal, but got null instead.
param: "speed", code: "invalid_type"
Cause
_send_prompt_to_target_async leaves speed out of body_parameters when it is None (pyrit/prompt_target/openai/openai_tts_target.py:154-155). But the SDK call then passes it anyway:
speed=body_parameters.get("speed"), # line 164
.get("speed") returns None, and the OpenAI SDK serializes an explicit None as JSON null. Only its NOT_GIVEN sentinel, or leaving the argument out, omits the field. The classic tts / tts-hd models apparently tolerate null, which is why this hasn't shown up before.
Repro
frompyrit.modelsimportMessagefrompyrit.prompt_targetimportOpenAITTSTargettarget=OpenAITTSTarget(endpoint=..., model_name="gpt-4o-mini-tts") # no speedawaittarget.send_prompt_async(message=Message.from_prompt(prompt="hello", role="user"))
# -> 400 Invalid type for 'speed'
Passing speed=1.0 works around it.
Suggested fix
Don't pass speed to audio.speech.create when it isn't set. Either spread the optional parameters from body_parameters, or pass NOT_GIVEN/omit instead of None. Add a unit test asserting that the outgoing request body has no speed key when speed is None, and has it when it's set.
Seen with gpt-4o-mini-tts version 2025-12-15 on Azure OpenAI.
Activity