# AI

Source: https://modulify.ai/docs/built-in/ai

Add chatbots, writing, summaries and search to your site with AI models from Anthropic, OpenAI, Google and more, with no account or API key to set up, paid from your workspace credits.

Every site can use AI, with no plan needed. A chatbot that answers questions about your products, a tool that writes a description from a few words, search that understands what a visitor means: your site's server code calls an AI model through Modulify, and the answer comes back in the format the OpenAI libraries already use. There is no account to open with an AI company, no API key to paste in and no separate bill. What your site uses is paid from your workspace credits.

You rarely need to write the code yourself. Ask in chat for the feature, such as "add a chat assistant that answers questions about my menu", and the chat builds it on your site's AI without asking which provider to use or asking for a key. That stays the default until you tell it otherwise, see [Use your own AI account](https://modulify.ai/docs/built-in/ai#use-your-own-ai-account). Chat can also tell you how much AI the site used, turn AI on or off and rotate the key when you ask it to, see [What the AI can do](https://modulify.ai/docs/built-in/ai#what-the-ai-can-do).

## Before you begin

AI is **on** from the start for every site, and it needs no plan. Your site pays for what it uses straight from the workspace credits.

Your site gets two [managed secrets](https://modulify.ai/docs/data/secrets) on its own, the next time its preview starts and every time it is published: `MODULIFY_AI_URL`, the address it calls, and `MODULIFY_AI_KEY`, its own key. Nobody has to open the **AI** tab first.

Any member of the workspace who can edit the site can turn AI on and off. Showing, copying and rotating the key need the **Delete projects** permission. Without it those buttons are disabled, with a tooltip saying why.

## Open the AI tab

Click **More** in the tab strip, then **AI**. The address ends in `/ai`. In the Modulify app for iPhone and Android, **AI** is in **More** too, with the same tabs, see [On the mobile app](https://modulify.ai/docs/build/site-chat#on-the-mobile-app).

Four tabs sit under the heading:

- **Overview**, the switch, a notice while AI is paused, and this month's usage
- **Insights**, requests, tokens and credits for the period you pick, per day and per model
- **History**, every request the site made, newest first
- **Settings**, the models with their prices, and API access with the key and code examples

## Turn AI off and on

**Use AI on this site** on the **Overview** tab turns AI on or off for the whole site. Turning it off asks first, **Turn off AI?**, because every AI feature on the site stops answering at once. While it is off, every request answers `403`. Turning it back on works straight away.

## What it costs

AI is paid per request, at the model's price per token. Prices are shown on the **Settings** tab under **Models**, in credits per million tokens on your plan, for the text your site sends (**Input**), what the model writes back (**Output**) and text the provider reused from an earlier request (**Cached input**). A short chat answer usually costs a small fraction of a credit. `perplexity/sonar` also adds a search fee to every request, see [Pick a model](https://modulify.ai/docs/built-in/ai#pick-a-model).

Your site does not pay request by request from your balance. It buys AI usage 1 credit at a time from the workspace credits, only when it needs more, and keeps whatever it has not used yet. Each purchase shows on the **Usage** tab of **Plans** as `AI usage added`, under **AI**. See [Credits](https://modulify.ai/docs/plans/credits).

A request that fails is not charged. A streamed answer that your visitor stops partway through is charged for what was written until then.

**This month** on the **Overview** tab shows the **AI requests this month**, the **Credits used** and **Credits bought**, the **Prepaid left**, and the workspace cap that limits AI, **Workspace AI cap** or **Workspace spending cap**, with **Manage caps**, which opens the workspace's **Spending** settings. It counts from the 1st of the month, in UTC.

## When AI pauses

AI pauses instead of running up a bill:

- **AI is paused until credits are added** when the workspace has no credits left. The workspace owner gets an email, and AI starts again on its own within a minute once credits are added. The **Overview** tab says **AI starts again within a minute** once the workspace has credits again. On Free, where credits can only be bought once the workspace has had a paid plan, it offers **See plans** instead of **Add credits**.
- **AI is paused by a spending cap** when the workspace reached its monthly AI cap or its monthly spending cap. **Open spending settings** takes you to the caps: raise or remove the cap, or wait for the 1st.

While AI is paused, every request answers `402` with the reason, so your site can show visitors a friendly message.

## Cap what AI spends

Caps are set for the whole workspace, not for one site. In **Settings** > **Spending**, **AI on sites** caps what the AI of every site spends together in a calendar month, and **All spending** caps everything the workspace spends. Once either is reached, AI pauses on every site until the 1st of next month or until the cap is raised. Only the workspace owner can change them, and every member can see them. See [Spending caps and alerts](https://modulify.ai/docs/plans/spending).

A cap is worth setting when a site has AI features visitors can use freely, such as a public chatbot, since every visitor's question spends your credits.

## Pick a model

Your site names a model in each request. Three names cover most needs:

- `modulify/fast`, quick and low cost answers for chat, summaries, extraction and classification. This is the model your site uses when it names none.
- `modulify/smart`, stronger reasoning and writing for assistants and longer answers.
- `modulify/embed`, embeddings for search and "chat with your documents".

`modulify/fast` and `modulify/smart` move to another provider on their own when one is down, so a provider outage does not stop your site. **Models** on the **Settings** tab lists every other model by name, such as `anthropic/claude-sonnet-5.5` or `google/gemini-3.8-flash`, with its price, and marks the default for each kind.

You can also name one model directly. A model named directly stays on that model:

| Model | Name | Kind | Good for |
|---|---|---|---|
| Claude Haiku 5.5 | `anthropic/claude-haiku-5.5` | Chat | Fast and low cost, with strong writing and tool use |
| Claude Sonnet 5.5 | `anthropic/claude-sonnet-5.5` | Chat | Balanced quality and speed for assistants, writing and tools |
| Claude Opus 5.5 | `anthropic/claude-opus-5.5` | Chat | The most capable Claude for hard reasoning and long tasks |
| GPT-6 Luna | `openai/gpt-6-luna` | Chat | Fast and low cost OpenAI model for everyday tasks |
| GPT-6.1 Terra | `openai/gpt-6.1-terra` | Chat | Mid-sized OpenAI model with a good balance of cost and quality |
| GPT-6.1 Sol | `openai/gpt-6.1-sol` | Chat | Capable OpenAI model for reasoning, writing and tools |
| GPT-6 Astra | `openai/gpt-6-astra` | Chat | The most capable OpenAI model for hard reasoning and long tasks, at a much higher price |
| Gemini 3.5 Flash Lite | `google/gemini-3.5-flash-lite` | Chat | Very fast Google model for simple, high volume tasks |
| Gemini 3.8 Flash | `google/gemini-3.8-flash` | Chat | Fast Google model that reads images, audio and long documents |
| Gemini 4 Argon | `google/gemini-4-argon` | Chat | The most capable Gemini for reasoning over long inputs |
| DeepSeek V4.1 Flash | `deepseek/deepseek-v4.1-flash` | Chat | Open model with very low cost for bulk text work |
| Mistral Small 4 | `mistralai/mistral-small-2603` | Chat | Low cost model from the French company Mistral for everyday tasks |
| Mistral Large 4 | `mistralai/mistral-large-4-0` | Chat | Capable model from the French company Mistral for reasoning, writing and tools |
| Grok 4.7 | `x-ai/grok-4.7` | Chat | Flagship SpaceXAI model for reasoning, coding and tools |
| Kimi K3.1 Pro | `moonshotai/kimi-k3.1-pro` | Chat | Moonshot flagship for long reasoning, coding and writing tasks |
| MiniMax M3.1 Flash | `minimax/minimax-m3.1-flash` | Chat | Low cost MiniMax model for coding, longer tasks and tools |
| GLM 5.3 Flash | `z-ai/glm-5.3-flash` | Chat | Low cost Z.ai model for coding, text work and tools |
| Perplexity Sonar | `perplexity/sonar` | Chat | Searches the web for every answer and lists its sources |
| Text Embedding 3 Small | `openai/text-embedding-3-small` | Embeddings | Low cost embeddings with 1,536 dimensions for search and retrieval |
| Text Embedding 3 Large | `openai/text-embedding-3-large` | Embeddings | Higher quality embeddings with 3,072 dimensions |
| Gemini Embedding 2 | `google/gemini-embedding-2` | Embeddings | Multilingual embeddings from Google for search across languages |

Every chat model reads text and images. The prices of each model are on the **Settings** tab, in credits on your plan.

`perplexity/sonar` searches the web before every answer and lists the pages it used, so it suits questions about current information. Each of its requests also pays a search fee of a few hundredths of a credit on top of its tokens, and the prices on the **Settings** tab cover the tokens only. It does not take `tools`.

## Call it from your site

**API access** on the **Settings** tab shows the address and the **AI key**, and **Code examples** shows the same call three ways: plain `fetch`, the OpenAI SDK and the AI SDK.

```typescript
import OpenAI from 'openai'

const ai = new OpenAI({
    baseURL: process.env.MODULIFY_AI_URL,
    apiKey: process.env.MODULIFY_AI_KEY
})

const completion = await ai.chat.completions.create({
    model: 'modulify/fast',
    messages: [{ role: 'user', content: 'Write a one line welcome for my site.' }]
})
```

> **Warning**
>
> Call AI only from server code, such as an API route, a route handler or a server action. The key spends your workspace credits, so never send it to the browser.

The endpoints, every error and the limits are on [AI HTTP API](https://modulify.ai/docs/built-in/ai-http-api).

## Use your own AI account

Your site's AI is the default, and chat keeps to it until you tell it otherwise. A site can call an account of your own with an AI company instead, such as OpenAI, Anthropic or Google. Ask for it in chat:

```markdown
Build the assistant on my own OpenAI account.
```

Chat sets that feature up on your account, and the features you did not ask to move stay on your site's AI. A site whose code already calls an account of yours keeps building on it.

- **The key.** It goes in [Secrets](https://modulify.ai/docs/data/secrets), never in the code or the chat. When it is not there yet, chat adds it holding the placeholder `REPLACE_ME`, and you paste your real value over it. A secret whose name begins with `ANTHROPIC_` or `CLAUDE_CODE_` never reaches your site, see [Reserved names](https://modulify.ai/docs/data/secrets#reserved-names), so chat gives an Anthropic key another name, such as `MY_ANTHROPIC_API_KEY`.
- **The bill.** That company bills you directly. What your account uses takes no credits, does not count toward your workspace caps and does not show under **Insights** or **History**.

## Rotate the key

The rotate button beside the **AI key** replaces it. It asks first, **Rotate the AI key?**: the old key stops working within a minute, the preview gets the new one right away, and the live site keeps the old key until you publish again, so AI stops answering there until then. Rotate only when the key may have leaked.

## Insights and history

**Insights** shows **Requests**, **Credits**, **Input tokens** and **Output tokens** for the period you pick with the date picker. Click **Requests** or **Credits** to chart it over time, with failed requests shown apart from answered ones. **By model** splits the same numbers per model, with each model's average latency.

**History** lists every request the site made, newest first: when it was made, the model and the one that answered when they differ, whether it was **Answered**, **Failed** or **Stopped**, its tokens, its credits and how long it took. A request whose tokens the provider did not report is marked **Estimated**. Each request stays in the history for 30 days.

Modulify keeps these counts only. It never stores what your visitors asked or what the AI answered.

## Limits

- Each site can send 600 AI requests a minute. Past that, requests answer `429` until the minute rolls on.
- A request can be up to 16 MB, images included.

## Your visitors' data

What a visitor types into an AI feature of your site goes to OpenRouter, which passes it to the model's provider, such as Anthropic, OpenAI or Google, only to return the answer. Through OpenRouter, Modulify only uses providers that do not train on that content and do not routinely store it, although a provider or OpenRouter may keep a message its safety checks flag, for a limited time. If your site offers AI features to its visitors, say so in your own privacy policy. See the [Privacy Policy](https://modulify.ai/legal/privacy-policy#visitors-to-your-sites).

## What the AI can do

The AI in the editor chat builds on your site's AI by default, and can do most of what this tab does with you.

- **Build AI features.** Ask for a chatbot, a writing tool or search that understands meaning, and it uses your site's AI without asking which provider to use or asking for a key. It tells you that visitors using the feature spend your workspace credits. If someone turned AI off, it asks whether you want it back on first.
- **Read the usage.** It tells you whether AI is on, why it is paused if it is, this month's usage, the requests and credits for any period you name, per model, and the requests the site made.
- **Change the settings.** It turns AI on or off when you ask, and rotates the key after asking you first.

Showing and copying the key stay on the **Settings** tab, and the workspace caps stay in **Settings** > **Spending**.

## From an AI client over MCP

A connected AI client, or your own code through the [HTTP API](https://modulify.ai/docs/api), reaches this tab through these tools:

- `get_site_ai_settings`, `get_site_ai_stats` and `list_site_ai_requests` read the switch, the status and this month's usage, the insights for a period and the history, and need `config:read`
- `update_site_ai_settings` turns AI on or off, and `rotate_site_ai_key` replaces the key, and both need `config:write`
- `get_workspace_spending` and `update_workspace_spending` read and set the workspace caps, see [Spending caps and alerts](https://modulify.ai/docs/plans/spending)
- `get_site_ai_key` reads the key in plain text, and needs `credentials:reveal`

`config:write` and `credentials:reveal` are unticked by default. `get_site_ai_key` and `rotate_site_ai_key` also need the **Delete projects** permission, like the buttons beside the **AI key**, and `rotate_site_ai_key` does not return the new key. See [MCP tools](https://modulify.ai/docs/mcp/tools#ai).

## Next

- [AI HTTP API](https://modulify.ai/docs/built-in/ai-http-api): The endpoints, every error and the limits.

- [Emails](https://modulify.ai/docs/built-in/emails): Send email from your site the same way, with nothing to set up.