Managing Cost

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

When you use Wing's AI assisted development features, it sends requests to OpenAI, who charges your account according to the size of the request and response.

You can see the actual cost of your last request, and the cost of all requests made so far, at the bottom of the AI Refactoring and AI Chat pages of the AI tool. These totals are stored on a per-project basis and can be reset to zero with Reset Costs in the AI tool's Options menu.

Note that you may need to configure the currency and token costs on the Config: AI Provider page of the AI tool if your account is charged at a different rate or in a different currency.

Controlling Costs

The most important way in which you can control costs is to limit the amount of context that you include with requests, as described in AI Request Context. In short, only include extra context when it is necessary.

Note that the size of the Target in AI refactoring and Focus in AI chat also add to costs, so it's best to use the smallest target or focus that still allows the AI to provide accurate responses.

Learning what sorts of requests are likely to return useful results is also important. See Improving Results Obtained from AI Assisted Development for details.

**Data Storage Costs*

System Message: WARNING/2 (<string>, line 26); backlink

Inline strong start-string without end-string.

The costs reported by Wing do not include storage costs for any uploaded files left in your AI provider account. Although Wing tries to remove all files that it uploaded after they are no longer needed, this may fail in the case of a network outtage. In that case, files may be left in your account until Wing retries removing them, and you may be charged by the AI provider for their storage during that time.

You can remove all resources created by Wing from your OpenAI account by selecting menu item Edit > Command by Name and entering commend internal-ai-delete-resources. You will need to restart all instances of Wing that were using the deleted resources before AI chat will work again.

OpenAI Rate Limits

OpenAI imposes rate limits that depend on how much you have spent with them and how old your account is. These are expressed in token counts per minute or day and not in terms of cost or raw request size.

The approximate maximum number of tokens consumed by a request can be computed by adding the configured maximum context size to the size of the returned code, dividing this by 5, and adding 500. Thus a request with 150KB of context that returns 10KB of code will consume about (150000 + 10000) / 5 + 500 = 32500 tokens.

The number of tokens that might be consumed should be compared to your OpenAI account's rate limits to determine the number of requests you will be able to make per minute and per day. If you run into rate limits, you can add more money to your OpenAI account to reach a usage tier that provides high enough rate limits for your usage.