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 the amount of code returned.

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 page 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 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 queries, as described in AI Request Context. In short, only include extra context when it is necessary.

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

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 query 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.