Stream completions from any model into the inline AI menu.
The AI extension adds an Ask AI entry to the toolbar and bubble menu. It opens an inline prompt with shortcuts (improve, shorten, translate, change tone …); the response streams in and can be inserted below or replace the selection.
Provide a completions(history, signal) function that returns an async iterable of chunks. Chunks can be plain strings, OpenAI-style choices[0].delta.content objects, or { text } objects — so any provider works.
Never ship API keys to the browser. Call your own backend and let it talk to the model provider.
The OpenAI SDK's streaming response is already an async iterable of choices[0].delta.content chunks, so it can be returned directly (from a trusted environment):