API Reference
Every function, hook, and type that the @emend/ai package exports.
This section lists what the @emend/ai package gives you. If you use the
ready-made AI components, you only need a few of these. Read on if you want to
build your own AI UI or server route.
Where to import from
The package is split into parts, so browser code and server code only load what they need.
| Import from | What it has |
|---|---|
@emend/ai/react | useEditorAi, the React hook for running AI requests |
@emend/ai/tiptap | The EmendAi Tiptap extension, plus preview and apply helpers |
@emend/ai/transport | Transports that send requests from the browser, including a mock |
@emend/ai/server | The server route handler and a mock AI for testing |
@emend/ai/protocol | Types for requests, streamed answers, actions, and errors |
@emend/ai | The most common exports from all of the above |
Start here
useEditorAiThe React hook that runs AI requests and tracks the answer, preview, and errors.EmendAi extensionThe Tiptap extension every emend editor needs.createFetchTransportSend AI requests from the browser to your server route.createEmendAiHandlerBuild the server route that checks requests and calls the AI model.
Also useful
- Action manifest: the built-in actions like Improve and Shorten, and what each one is allowed to do.
- Error codes: every error emend can return, and what to show the user.