Cloudflare Docs
AI Gateway
Visit AI Gateway on GitHub
Set theme to dark (⇧+D)


When making requests to OpenAI, replace in the URL you’re currently using with

curl -X POST \
--header 'Authorization: Bearer $TOKEN' \
--header 'Content-Type: application/json' \
--data ' {
"model": "gpt-3.5-turbo",
"messages": [
"role": "user",
"content": "how to build a wooden spoon in 3 short steps? give as short as answer as possible"

If you’re using a library like openai-node, set the baseURL to your OpenAI endpoint like this:

import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: 'my api key', // defaults to process.env["OPENAI_API_KEY"]
baseURL: ""