The Cloudflare AI Gateway proxy is a great way to get more usage insight. It is also plug and play.
You can use it in python
by creating a AI Gateway in your Cloudflare Dashboard.
Here is an example code.
import os
account_id = os.getenv('ACCOUNT_ID')
gateway_id = os.getenv('GATEWAY_ID')
base_url = f"https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai"
from openai import OpenAI
client = OpenAI(
base_url=base_url,
)
It is as simple as that.
You can see how the requests look in the example below.
Top comments (1)
This is a cool way to integrate AI with Cloudflare! It’s awesome how simple it is to set up the AI Gateway. For hosting, Cloudways is a great option if you’re looking for scalable and managed hosting solutions with Cloudflare integration. Other alternatives like SiteGround or Kinsta are also worth checking out for their seamless performance and security features.