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

# Rewriter

> Let users select text on your website and use AI to rewrite, improve, or comment on it — powered by any major LLM provider.

<Frame>
  <iframe src="https://landing-page-demo-velt.vercel.app/?feature=rewriter" allow="camera; microphone" frameBorder="0" className="w-full" height="400px" />
</Frame>

[Open in larger window](https://landing-page-demo-velt.vercel.app/?feature=rewriter)

## What is the Rewriter?

The Rewriter lets your users select any text on your website and send it to an AI model for rewriting, then apply the result directly to the page. You can also anchor collaborative comments to any selected text range.

Velt handles the AI API, text selection tracking, and DOM replacement — you control the prompts, model choice, and UX.

## Key capabilities

* **Multi-model AI API** — Route prompts to OpenAI (`gpt-*`, `o1-*`, `o3-*`, `o4-*`), Anthropic (`claude-*`), or Google (`gemini-*`) through Velt's api with no additional backend setup.
* **Text selection tracking** — Subscribe to `textSelected` events to know exactly which text a user highlighted, including its DOM position.
* **In-place text replacement** — Replace the selected DOM text with AI-generated output in one API call.
* **Comment anchoring** — Attach collaborative comment threads to specific text ranges for review workflows.

## Use cases

<CardGroup cols={2}>
  <Card title="Content editing tools" icon="pen-to-square">
    Let writers and editors select a paragraph and ask AI to adjust tone, simplify language, fix grammar, or expand on an idea — all without leaving the page.
  </Card>

  <Card title="Collaborative document review" icon="comments">
    Reviewers select text and leave AI-assisted feedback as anchored comments. Combine `askAi` for suggested rewrites with `addComment` to capture discussion around each change.
  </Card>

  <Card title="CMS and website builders" icon="browser">
    Give non-technical users an AI rewrite button inside your CMS. They highlight a heading or product description, pick a prompt like "Make it shorter" or "Add a call to action," and see the update instantly.
  </Card>

  <Card title="Education and writing platforms" icon="graduation-cap">
    Students select their draft text and get AI-powered suggestions to improve clarity, fix citations, or rephrase for a different audience — with before-and-after visibility.
  </Card>

  <Card title="Localization and translation" icon="globe">
    Users highlight text and prompt the AI to translate it into another language or adapt it for a regional audience, then apply the result directly to the page.
  </Card>

  <Card title="Customer support knowledge bases" icon="headset">
    Support teams review help articles and use AI to simplify technical jargon, adjust tone for end users, or flag outdated content with anchored comments.
  </Card>
</CardGroup>

## How it works

1. **Enable the Rewriter** on any page or section of your app.
2. **Listen for text selections** — when a user highlights text, you receive a `TextSelectedEvent` with the selected content and DOM context.
3. **Send an AI prompt** — call `askAi` with the selected text, a prompt, and your preferred model. Velt routes the request through its api.
4. **Apply the result** — call `replaceText` to swap the original text with the AI output in the DOM.
5. **Optionally add a comment** — call `addComment` to anchor a collaborative comment thread to the text range.

## Supported AI models

| Provider  | Model prefixes                  |
| --------- | ------------------------------- |
| OpenAI    | `gpt-*`, `o1-*`, `o3-*`, `o4-*` |
| Anthropic | `claude-*`                      |
| Google    | `gemini-*`                      |

<Info>
  You can use your own LLM API keys by configuring them in the [Velt Console](https://console.velt.dev/). This gives you full control over billing, rate limits, and model access. If no custom key is configured, Velt's built-in API handles authentication by default.
</Info>

## Get started

<CardGroup cols={2}>
  <Card title="Setup" icon="gear" href="/ai/rewriter/setup">
    Step-by-step guide to enable the Rewriter, subscribe to events, and wire up AI-powered text replacement.
  </Card>

  <Card title="Customize Behavior" icon="sliders" href="/ai/rewriter/customize-behavior">
    API reference for all Rewriter methods — enable/disable, text events, AI prompts, replacement, and comments.
  </Card>
</CardGroup>
