Communicating with the API in vanilla js (no server side stuff)

For instance, I can see that the CURL to communicate with openAI is:

curl https://api.openai.com/v1/engines/davinci/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "prompt": "", "temperature": 0.7, "max_tokens": 64, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0 }'

What would a fetch request look like for this?