Skip to main content

Setup

Step 1: Enable Rewriter

Step 2: Subscribe to text selection events

Subscribe to Rewriter events. Supports 'textSelected' to receive a TextSelectedEvent whenever a user selects text in a Rewriter-enabled region.

Step 3: Send a prompt to AI

Send a text-generation prompt to any AI model via Velt’s api. The provider is resolved automatically from the model name prefix (gpt-*/o1-*/o3-*/o4-* → OpenAI, claude-* → Anthropic, gemini-* → Gemini).

Step 4: Take action on the returned result

Once you have the AI response, you can either replace the selected text in the DOM or anchor a comment to it. Choose the option that fits your use case, or combine both.
Replace the DOM text identified by a TextSelectedEvent with new text.

Complete Example