Does Gradio Spaces provide an API endpoint for apps?

Hi, I’m trying to acces the Gradio API via a POST request, this is my current script:

import requests

data = {
    "query": "summarize our conversation",
    "history": [
        []
    ],
    "system": "You are a helpful assistant.",
    "api_name": "/model_chat"
}

r = requests.post("https://qwen-codeqwen1-5-7b-chat-demo.hf.space/api/predict", json=data)

print(r.text)

I keep getting this error:

{"detail":[{"type":"missing","loc":["body","data"],"msg":"Field required","input":{"query":"summarize our conversation","history":[[]],"system":"You are a helpful assistant.","api_name":"/model_chat"},"url":"https://errors.pydantic.dev/2.7/v/missing"}]}

I would appreciate some help, thanks!