How to make Cursor aware of updated OpenAI API documentation?

When I try to ask Cursor to generate or edit Python scripts that use the OpenAI API, it is using old formats that no longer work, and language models that are deprecated. Is there any way to make it aware of updated API changes?

When I paste the current OpenAI chat completion script from the api reference page, and ask Cursor if this is correct, I get the following response:

No, the code you provided is not correct. The OpenAI Python client library does not have a class named OpenAI. Instead, you should use the openai.ChatCompletion.create method to generate chat completions.

And then if continues to give me corrected code that will not work.

Likewise it is not aware of the model deprecations that just occured at the start of January, and gives me new code with language models that no longer function.

You can always add the latest API docs via @Docs → +Add new doc and point it to the section of the API docs you need.
I used this successfully to get code generated for the assistants API.

1 Like

What do I do if I’ve added new reference docs but cursor is ignoring them?
I’ve added openai’s docs and their api reference on github, and @ mentioned them in the generation, but it’s still using pre-1.0.0 options like and import openai.