Tts not working (with fastapi)

Please help me get this right. I’ve been struggling here!

using fastapi:

@app.post("/text_to_speech/")
async def text_to_speech(request: QueryRequest, authenticated: bool = Depends(api_key_auth)):
    speech_file_path = Path(__file__).parent / "speech.mp3"
    with client.audio.speech.with_streaming_response.create(
            model="tts-1",
            voice="onyx",
            input=request.text,
            response_format="mp3",
    ) as response:
        response.stream_to_file(speech_file_path)
        return {'content': response.content}

Then when I try call the method:

data = {text="Hello world", other_field=2}
response = requests.post(url, json=data, headers=headers)

I get error:

Error: {"detail":[{"type":"model_attributes_type","loc":["body"],"msg":"Input should be a valid dictionary or object to extract fields from","input":"{\"text\": \"Hello world\", \"other_field\": 2}","url":"https://errors.pydantic.dev/2.7/v/model_attributes_type"}]}