> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/reference/appfarm-ai/ai-credits.md).

# AI credits

AI credits are a prepaid balance for using certain features of Appfarm AI. When you use [Build](https://docs.appfarm.io/reference/appfarm-ai/build.md) mode, credits are automatically deducted from your balance based on usage. [Ask](https://docs.appfarm.io/reference/appfarm-ai/ask.md) mode is free to use.

AI credits are allocated to a specific [Solution](https://policies.appfarm.io/glossary/product-glossary#solution). Credits come in three kinds: granted, subscription and purchased. Each kind expires after a set time, see the [AI credits terms of use](https://policies.appfarm.io/service-and-usage/ai-credits-terms-of-use). Appfarm AI uses granted credits first, then subscription credits, then purchased credits. Your balance is shown in **Settings** > **Appfarm AI**.

All users working within a Solution in Appfarm Create share the same credit pool. Credits belong to the Solution and cannot be transferred or reallocated to other Solutions.

### Check your balance and purchase credits

You can check the current balance in your Solution by clicking the mode button (**Build** or **Ask**) at the bottom of the Appfarm AI sidebar. The menu shows the credits left and an **Add credits** button.

<figure><img src="https://29237295-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MiLU-xcHu0eLZiTxcmZ%2Fuploads%2Fae6gafl0qy9ZlXETlX4x%2Fimage.png?alt=media&amp;token=ce960e8a-1631-4f06-9826-a117e9b0dac1" alt=""><figcaption></figcaption></figure>

The balance and **Add credits** are also shown in the menu at the top of the Appfarm AI sidebar, under **Settings** > **Appfarm AI**, and as **Credits left** on the **Usage** tab of the **Home** page.

Click **Add credits** to visit a new page where you can purchase a block of credits using your credit/debit card. After your purchase, refresh your Solution to ensure the new credits are available.

### Credit usage

Credits are used every time Build mode performs a task in your solution. The number of credits follows the work the AI models do for the task: which model handles each step, how much it reads and writes, and how much context it can reuse from earlier steps. Reused context costs much less than new context. A small change, such as changing the color of a button, uses fewer credits than creating a complete dashboard view. A large app or a long thread gives the models more to read, so it also uses more credits.

Function edits you start from the [function editor](https://docs.appfarm.io/reference/appfarm-ai/build.md#function-editor-ai) run in the Appfarm AI sidebar and use credits like any Build message. **Generate objects** in the data table of an object class also uses credits. Only Ask is free.

For more details around the use of AI credits, refer to the [Terms of use](https://policies.appfarm.io/service-and-usage/ai-credits-terms-of-use).

### Credits used in a thread

After every response, the total credits used in the thread so far are shown under it, for example `24 credits`. The number includes the work of all subagents in the thread. Expand a subagent to see the credits that subagent used. Credits are shown in whole numbers, rounded up.

{% hint style="info" %}
**Good to know**

The background review that suggests changes to [Solution memory](https://docs.appfarm.io/reference/appfarm-ai/build.md#solution-memory) also uses credits. These credits are taken from the balance but are not included in any thread's number.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/reference/appfarm-ai/ai-credits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
