Cursor ↗︎ supports a custom OpenAI base URL for models that use a custom API key. Point it at AI Gateway's REST API to route Cursor chat and agent requests through AI Gateway. Cursor sends requests through its servers, so your AI Gateway endpoint must be publicly reachable.
Before you start, you need:
- Your Cloudflare account ID. To find it, refer to Find your account and zone IDs.
- A Cloudflare API token with Account > Workers AI > Read permission.
- Credits loaded on your account for third-party models.
- Cursor ↗︎ installed and updated to the latest version.
-
In Cursor, go to Cursor Settings > Models. Under API Keys, enter your Cloudflare API token in the OpenAI API Key field, then select Save.
-
Turn on Override OpenAI Base URL. Enter the following value, replacing
<ACCOUNT_ID>with your Cloudflare account ID:https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/ai/v1 -
Select + Add Custom Model. Enter a model name, then turn on the model.
Use a Workers AI model for chat, such as
@cf/meta/llama-3.3-70b-instruct-fp8-fast. For agent mode, use a third-party model that supports the OpenAI Responses API, such asopenai/gpt-4.1-mini.For available models, refer to the model catalog.
-
Select the custom model in Cursor and send a prompt. Requests now route through AI Gateway.
To confirm traffic reaches AI Gateway, refer to Verify it works.