Connect Cursor to AI Gateway
How to connect Cursor to an AI Gateway project model.
This guide explains how to connect Cursor to a model that AI Gateway exposes through its OpenAI-compatible endpoint.
Before you start
Section titled “Before you start”- Install Cursor.
- Issue a Gateway Key from the Gateway Keys menu of the project you want to use. See Issue a Gateway Key.
- Check that the model appears in the Models menu of the same project.
A Gateway Key is a secret. Do not put the key value directly in source control, chat messages, or shared screenshots.
1. Set the Gateway Key
Section titled “1. Set the Gateway Key”Cursor asks for the key in its model settings. If you prefer to keep the value outside Cursor, store it in your usual secret manager and paste it there. The AI Gateway setup dialog shows the environment-variable name AI_GATEWAY_API_KEY, not a key value.
2. Configure Cursor
Section titled “2. Configure Cursor”In AI Gateway, open the project you want to use, then open Models in the top menu. In the row of the model you want, select the gear icon in the Installation column and check the Gateway base URL and model ID. Open Cursor’s Settings → Models page.
Set these values:
- Model: the
provider-name/model-idshown in the setup dialog. - Override OpenAI Base URL: the Gateway base URL shown in the setup dialog.
- OpenAI API Key: your Gateway Key.
Keep the existing Cursor settings that you do not intend to change. Save after the model and base URL are set.
3. Check the connection
Section titled “3. Check the connection”Restart Cursor if it was already running. Open a new chat, choose the configured model, and send a short request. If the response arrives, the connection works.
If the model does not appear
Section titled “If the model does not appear”- Confirm that the model ID and Gateway base URL exactly match the setup dialog.
- Confirm that the API key is the Gateway Key issued for the same project.
- Confirm that the model is allowed in that project’s Models menu.
- If the request still fails, ask the AI Gateway administrator to check the Cursor-facing Gateway route.