’m trying to integrate Azure OpenAI into Cursor under the API Key section. Do I need to manually enable the model, or should it just work? Because when I turn it on, I get an error.
Also, when I use the AI code suggestion shortcut (Ctrl + K) and generate code, Cursor shows in history as Errored, Not Charged — does that mean the request actually went through the API or not?
And currently, if I use OpenAI directly, which model is the best one for generating code?
Currently, Cursor only supports Azure OpenAI for model deployments that support the old completions API (such as 4o, 4.1..). It is not yet working for the new models that only support the responses API (such as gpt-5).
To try to answer your other questions:
Using cursor through Ctrl + K or Ctrl + L works in pretty much the same way in terms of model selection and using your API Keys, provided you have the same model selected as in the chat, such as the custom model gpt-medium with my project mentioned above:
If you are having errors exclusively with Ctrl + K, it might be worth posting a bug report separately in this forum. Just as an observation: in the screenshot you’ve shown, you are using auto model, which AFAIK will not use your custom API key.
As per the best coding model, I’m happy with GPT-5 with reasoning level set to high and verbosity set to high as well, but I’m obviously very biased. Depends a lot on how you intend to use it as well.
*
ps: I’m not affiliated with Cursor in any way*
Thank you so much! I’m really surprised you spent so much time explaining this to me — I’ve read it carefully and I understand now.
Can I ask a follow-up question? You mentioned creating models and selecting them instead of using auto. But when I turn off all models and only add my API key, Cursor still shows an error even though the AI actually generates code. Could this be a Cursor issue?
I’ll definitely check out your guide. Unfortunately, I only have access to the gpt-5-mini API right now, but I’ll also try with GPT-5 as you suggested.
So I think the error you were seeing was probably related to that, as the syntax of the file is correct for its intended python version.
However upon further testing with railway, there is no error in cursor but no completion is visible in the chat. I will investigate further tomorrow. It might be due to the high log rate from the pretty logs, or because cursor is sending the requests differently to it (I’m seeing requests to a new path I haven’t seen before, and I’ve compared side with a cloudflare tunnel, and it only happens on railway).
Oh! And I’ve tried running the project with gpt-5-mini out of curiosity, and it seems to work out of the box after changing AZURE_DEPLOYMENT to my gpt-5-mini deployment:
Just in case: if your organization doesn’t have access to GPT-5 or its reasoning traces, you might have to set AZURE_SUMMARY_LEVEL=none, I haven’t had the opportunity to test it with such organization.
It worked, because I set python to 3.11 so the error then changed to 3.13. And the domain configuration will automatically generate port without intervention.
But when adding cursor it is not working yet, maybe it is because of Free version
Agent and Edit rely on custom models that cannot be billed to an API key. Please use a Pro or Business subscription and/or disable API keys. Ask should still work.
Oh @DonNguyen I have bad news for you… After trying with a free user, I get the same message as you do. And after doing some research, it seems like that’s the direction cursor are going: Reddit - The heart of the internet
I started this project when I ran out of usage (and had free Azure credits), but I always had an active subscription so I didn’t notice it required one to work with BYOK.
What I did notice is that once I ran out of usage, I had to use a "Custom Mode” to bypass one of cursor’s models that were causing issues (as per my README.md). But apparently that’s not enough when no subscription is available
I think I can understand Cursor’s rationale for this change, and there are lots of free alternatives that fully support BYOK, so I don’t think it should be a big issue. Good luck!
Yeah, I just confirmed the same. Looks like Cursor now blocks custom models for Free users. Totally understandable, though a bit limiting for quick BYOK experiments. Appreciate your tests!
I hope it’s not a bother, but I’ve been experimenting with it recently. Could you please give me a Postman request I can use to check whether my proxy configuration is working correctly before I connect it to Cursor?
I’d like to isolate whether the issue is due to an incorrect proxy setup or something on Cursor’s side. Thanks! @gabrii
And also, show me the bottom of the Traceback as well if possivle (scroll down on your logs). Because it might be that there is an issue being raised by Azure, and I think my code had a bug where it crashes when trying to report azure errors if the request doesn’t contain the “tools” parameter.
So the error you see might be obfuscating an error with azure that would otherwise be correctly reported.
Thank you! I’ve understood the issue — it was because I tried running it with a smaller model, thinking that just having chat completions would be enough. Thanks a lot! I’ll test it again with GPT-5 and GPT-5 mini.
Because gpt-5-mini uses the 2025-01-01-preview version, but the system by default calls POST /openai/deployments/gpt-5-mini/completions?api-version=2025-04-01-preview HTTP/1.1,
it throws a 400 error.
If I manually change it, it says the API version must not be lower than 2025-03.
So does that mean it’s mandatory to use API versions from March 2025 onward?
I’m asking because I still want to test it with other models besides GPT-5.
Hm… No idea to be honest. I’ve always used the latest at the time of making the project which is set as the default and seems to work well for gpt-5 and gpt-5-mini models:
AZURE_API_VERSION = env.str("AZURE_API_VERSION") or "2025-04-01-preview"
But you are free to change it and experiment with it. Keep in mind all the request adaptation logic was done for gpt-5 models in mind, which add lots of new parameters, so it will most likely not work well with any other series of models.
Thank you for the past few days!
It also seems that the issue is partly related to the Azure version I’m using — as mentioned, it’s still on 2025-01-01-preview.
Hello, i noticed that recently azure openai added support for chat_completitions api for gpt-5, but still not for gpt-5-codex, anyway i canuse this project(the github one) for the codex?