> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newly.app/llms.txt
> Use this file to discover all available pages before exploring further.

# AI features in your app

> Let your app generate text, images, speech and video with AI models, paid for with your Newly credits and no provider API keys.

Your app can use AI models to generate text, images, speech and video, and to transcribe audio. You don't need an account or API key with any AI provider. Requests are paid for with your organization's Newly credits.

<Note>
  This is about AI inside **the app you build**. It doesn't change the AI that builds your app. Newly chooses the model behind Newly Agent.
</Note>

## Add an AI feature

<Steps>
  <Step title="Open the AI models menu">
    In the prompt box, click **+**, then **AI models**. The menu says "Choose what your app can create".
  </Step>

  <Step title="Pick one or more models">
    Filter by **Text**, **Images**, **Audio** or **Video**, or search by model or provider. Click a model to add it to your message. To add another, open the menu again. Models marked "Unavailable" can't be picked right now. The list can change over time.
  </Step>

  <Step title="Describe the feature">
    Say what the feature should do. For example: "Add a button that turns the user's photo into a watercolor painting" or "Let users ask questions about their saved notes."
  </Step>
</Steps>

The agent turns the models on for your dev backend, writes the server code that calls them and connects your app's screens to it. You can try the feature in your preview.

Turning models on needs the project's owner or a project **Admin**. If you aren't one, the agent can't turn them on and gets "An owner or admin must manage backend AI access."

## How it works

* **Newly Backend with sign-in is required.** Your app calls AI models through its own [Newly Backend](/backend/overview), on behalf of a signed-in user. See [Sign-in for your app](/backend/app-sign-in).
* **No keys in your app.** The access your backend uses to reach AI models is added when the backend is deployed. It never goes into the app itself.
* **Each environment is separate.** Models are turned on separately for dev and production.

## Credits

Every AI request your app makes uses your organization's credits, in dev and in production. That includes requests from your app's users, not only your own testing. It's the same credit balance you use for the agent. There's no separate AI wallet.

* Before a request runs, Newly sets aside the most it can cost. You're never charged more than that amount, and you're charged for what the request actually used.
* Failed requests don't use credits.
* Requests cancelled before they start don't use credits. Once a request has started, it can't be cancelled.

Larger or longer outputs can cost more, for example longer videos or longer text. See [How credits work](/billing/how-credits-work).

<Warning>
  When your app is live, your users' activity spends your credits. Keep an eye on your balance, especially after a launch. If credits run out, AI features in your app stop working until you add more.
</Warning>

## Limits

These limits apply to each project environment, with dev and production counted separately:

| Limit                                 | Value                                       |
| ------------------------------------- | ------------------------------------------- |
| Requests per app user                 | 50 per day. The day resets at midnight UTC. |
| Requests running at once              | 2 per project environment, across all users |
| Uploaded files (photos, audio, video) | 16 MiB in total per request                 |
| How long generated files are kept     | 7 days                                      |

If your app needs to keep a generated image, audio clip or video longer than 7 days, ask the agent to save a copy in your app's storage.

## Messages your app may receive

Ask the agent to show a friendly message in your app for each of these.

| Message                                                       | What it means                                                                                            |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| "Your Newly credits are too low for this request."            | Your organization doesn't have enough credits. [Add credits](/billing/plans-and-top-ups).                |
| "The App AI request limit has been reached. Try again later." | This app user reached the 50 requests for the day, or too many requests are already running.             |
| "App AI is temporarily at capacity."                          | Newly is at a temporary limit across all apps. Try again later.                                          |
| "Enable this model for the project first."                    | The model isn't turned on for this environment. This usually means it's on in dev but not in production. |

## Turn on AI models for production

The agent can only turn models on for dev. For your released app, turn them on for production yourself with the newly CLI. You need to be the project's owner or a project **Admin**. Otherwise you'll see "An owner or admin must manage backend AI access."

<Steps>
  <Step title="Set up the newly CLI">
    Install the tool, sign in and pull your project. Follow the steps in [Production and secrets](/backend/production-and-secrets#deploy-your-backend-to-production).
  </Step>

  <Step title="Find the model ids">
    From your project folder, run:

    ```bash theme={null}
    newly ai status --env prod
    ```
  </Step>

  <Step title="Turn the models on">
    List every model your app uses in dev, separated by commas. The command replaces the production list, so include all of them each time:

    ```bash theme={null}
    newly ai enable --models <model-id>,<model-id> --env prod
    ```
  </Step>

  <Step title="Deploy the backend to production">
    ```bash theme={null}
    newly deploy --env prod
    ```

    The deploy connects your production backend to the models.
  </Step>
</Steps>

## Related

<CardGroup cols={2}>
  <Card title="How credits work" icon="coins" href="/billing/how-credits-work">
    What uses credits and what doesn't.
  </Card>

  <Card title="Production and secrets" icon="key" href="/backend/production-and-secrets">
    Deploy your backend to production.
  </Card>
</CardGroup>
