Portable provider execution
Run provider-neutral chat and model traffic locally or across a trusted control plane while retaining host egress policy, tracing, aborts, and test transports.
Built-in AI streaming with multi-provider support, tool calling, extended thinking, and framework-specific hooks. Add a real-time AI chat to your app with a single Elysia plugin and a one-line hook.
Add AI streaming to your server with the aiChat plugin. It creates a WebSocket endpoint and REST routes for conversation management automatically.
bun add @absolutejs/ai elysiaimport { Elysia } from 'elysia';
import { prepare, networking } from '@absolutejs/absolute';
import { aiChat } from '@absolutejs/ai';
import { anthropic } from '@absolutejs/ai/anthropic';
const { absolutejs, manifest } = await prepare();
new Elysia()
.use(absolutejs)
.use(
aiChat({
provider: () => anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }),
systemPrompt: 'You are a helpful assistant.',
})
)
.use(networking);Per-conversation serialization prevents later turns from overtaking active or failed work while keeping queued state visible to every framework adapter.
The AI integration is organized in three layers that flow from server to client:
@absolutejs/ai@absolutejs/ai/anthropic@absolutejs/ai/reactimport { aiChat } from '@absolutejs/ai'; // Server plugin
import { anthropic } from '@absolutejs/ai/anthropic'; // Provider
import { useAIStream } from '@absolutejs/ai/react'; // Client hook| Provider | Import | Models |
|---|---|---|
| Anthropic | ai/anthropic | Claude Opus 4.6, Sonnet 4.6, Haiku 4.5 |
| OpenAI | ai/openai | GPT-4o, GPT-5.x |
| OpenAI Responses | ai/openai-responses | o3, o4-mini, gpt-image-1.5 |
| Gemini | ai/gemini | Gemini 3 Pro/Flash, 2.5 Pro/Flash |
| Ollama | ai/ollama | Any local model |
| xAI | ai/providers | Grok 4, Grok 3 |
| DeepSeek | ai/providers | DeepSeek V3, R1 |
| Mistral | ai/providers | Large, Small, Codestral |
| Meta | ai/providers | Llama 4 Maverick/Scout |
| Alibaba | ai/providers | Qwen Max/Plus/Turbo |
| Moonshot | ai/providers | Kimi K2 |
Every framework gets an idiomatic binding with the same API surface:
| Framework | Import | API |
|---|---|---|
| React | react/ai | useAIStream() hook + AIStreamProvider |
| Vue | vue/ai | useAIStream() composable + provide/inject |
| Svelte | svelte/ai | createAIStream() with reactive getters |
| Angular | angular/ai | AIStreamService injectable with signals |
| Vanilla / HTML | ai/client | createAIStream() with subscribe callback |
On the client, a single hook connects to the WebSocket and manages all message state. Here is the React example. Vue, Svelte, and Angular have the same API:
import { useAIStream } from '@absolutejs/ai/react';
export const Chat = () => {
const { messages, send, cancel, isStreaming } = useAIStream('/chat');
return (
<div>
{messages.map((msg) => (
<div key={msg.id}>{msg.content}</div>
))}
<button onClick={() => send('Hello!')}>Send</button>
{isStreaming && <button onClick={cancel}>Cancel</button>}
</div>
);
};Current package surface
Import surface · click to copy
Outcomes
Run provider-neutral chat and model traffic locally or across a trusted control plane while retaining host egress policy, tracing, aborts, and test transports.
Serialize concurrent turns, expose queued state to every framework adapter, and create conversation branches without allowing later messages to overtake failures.
Hardening checklist
Follow in order