Create your first AI Gateway using Workers AI
This tutorial guides you through creating your first AI Gateway using Workers AI on the Cloudflare dashboard. The intended audience is beginners who are new to AI Gateway and Workers AI. Creating an AI Gateway enables the user to efficiently manage and secure AI requests, allowing them to utilize AI models for tasks such as content generation, data processing, or predictive analysis with enhanced control and performance.
- Sign up: If you do not have a Cloudflare account, sign up.
- Log in: Access the Cloudflare dashboard by logging in to the Cloudflare dashboard.
- Go to AI > AI Gateway in the Cloudflare dashboard.
- Select Create Gateway:
- Enter a name for your gateway (up to 64 characters).
- Select Create.
- In the AI Gateway section, select the gateway you created.
- Select Workers AI as your provider to set up an endpoint specific to Workers AI. You will receive an endpoint URL for sending requests.
-
Go to AI > Workers AI in the Cloudflare dashboard.
-
Select Use REST API and follow the steps to create and copy the API token and Account ID.
-
Send Requests to Workers AI: Use the provided API endpoint. For example, you can run a model via the API using a curl command. Replace
{account_id}
,{gateway_id}
and{cf_api_token}
with your actual account ID and API token:
The expected output would be similar to :
Monitor your AI Gateway to view usage metrics.
- Go to AI > AI Gateway in the dashboard.
- Select your gateway to view metrics such as request counts, token usage, caching efficiency, errors, and estimated costs. You can also turn on additional configurations like logging and rate limiting.
To build more with Workers, refer to Tutorials.
If you have any questions, need assistance, or would like to share your project, join the Cloudflare Developer community on Discord to connect with other developers and the Cloudflare team.