Configuring the AI Provider

Index of All Documentation » Wing Pro Reference Manual » AI Assisted Development »

Wing currently supports only OpenAI as the AI provider, and you must have your own paid OpenAI account and API key in order to use this feature in Wing. Free OpenAI accounts will not work because those do not have access to the language models that are needed to run Wing's AI assisted development features.

AI-assisted development is disabled by default. To enable it and set up the AI provider, open the AI tool from the Tools menu in Wing, select the Provider page, and then choose OpenAI as your provider and enter your OpenAI API key. You can generate API keys by logging into your OpenAI account, going to the API section, and then clicking on API Keys.

You can either place your API key into a file (the default location is openai.key in your User Settings directory) or enter it directly in the Configuration page. We recommend using a file so the the key is less likely to be shared accidentally, for example if you commit your project file to revision control. Note, however, that the API key will be written only to the .wpu user and machine specific branch of your project, which typically should not be shared anyway because it is intended only for the local environment.

You can also configure the currency and token costs here to match what you are being charged by OpenAI, so that you can keep track of the cost of requests that you make from Wing.

After your configuration is complete, press Apply to save it into your project.

This setting is stored in your project file so that you can charge different API keys for different projects. You will need to enable the AI integration in the same way in each of your Wing projects.

Testing the Configuration

To test your configuration, try pressing Ctrl-? while focus is in an editor, or select menu item Source > AI Assist > Next AI Suggestion. You should see AI (querying) displayed in the status area in the lower left of Wing's window and a suggestion should appear in the editor after some time (in some cases, a fairly long time). You can remove the suggestion by pressing Esc (or Esc Esc in emacs mode).

Another way to test the installation is to open the AI Refactoring page of the AI tool in the Tools menu, select a small part of a file in the editor, and issue an instruction like Clean up this code. Then press the AI Refactor button. You should see Waiting for OpenAI appear at the bottom of the AI tool. When the operation completes the selected text will be replaced with the AI's response.

If this doesn't work, bring up the AI tool from the Tools menu, and select Show Console in its Options menu. The console shows everything Wing sends to the AI provider and all responses and error messages.