Inline suggestions for AI chat composers.

Ghost Text shows people the rest of their message as they type, and the next one after a reply. Tab takes it. Open source, for any textarea and any model.

Read the guide

Try it: click the message box, then press Tab. Try it: tap the message box, then tap the suggestion.

  1. Can you plan three days in Lisbon for me?
  2. Happy to. Do you lean toward food and neighborhoods, or museums and day trips? And when are you going?

Wrap your textarea.

Your textarea stays yours: its value, caret, undo and styles. Ghost Text draws over it and listens to keys.

import { useGhostText } from '@ghosttext/react';

const { ghostTextRef } = useGhostText({ source, messages });
<textarea
  ref={ghostTextRef}
  value={value}
  onChange={event => setValue(event.target.value)}
/>

Not using React? ghostText(textarea, options) does the same.

Bring any model.

A source is a function from what is typed to suggestions. Combine them. The first one with an answer wins.

import { cascade, endpoint, history } from '@ghosttext/core';
import { chromeAI } from '@ghosttext/chrome-ai';

const source = cascade(
  history(),
  chromeAI(),
  endpoint({ url: '/api/ghost-text' })
);
History
Messages they sent before. Instant, local, no model.
Chrome AI
Gemini Nano on the device. Free, private, offline.
Your model
Any OpenAI-compatible API, behind your endpoint. The key stays on your server.

Plugins see every step. Skip slash commands, filter links, count what gets accepted.

const commands = definePlugin({
  name: 'commands',
  onContext: context => !context.before.startsWith('/') && context,
  onAccept: ({ suggestion }) => track('accept', suggestion.source),
});

The hard parts are done.

Ready for your coding agent.

Point your agent at the docs and it can add Ghost Text for you.