useAllemChat
Chat hook with streaming, message history, and provider context. Built on the Vercel AI SDK.
import { useAllemChat } from "@allem-sdk/ai";
Options
| Prop | Type | Default | Description |
|---|
| api | string | — | Override API endpoint from provider |
| model | string | — | Model identifier (e.g. "gemini-2.0-flash") |
| provider | "google" | "anthropic" | "openai" | — | Provider name |
| systemPrompt | string | — | System prompt sent with requests |
| headers | Record<string, string> | — | Extra headers merged with provider headers |
| experimental_throttle | number | — | Throttle wait in ms for updates |
Returns
| Property | Type | Description |
|---|
| messages | UIMessage[] | Array of chat messages |
| sendMessage | ({ text }): Promise | Send a message |
| status | "ready" | "submitted" | "streaming" | Current chat status |
| stop | () => void | Stop streaming |
| setMessages | (msgs) => void | Replace message history |
Usage
const { messages, sendMessage, status } = useAllemChat({
provider: "anthropic",
model: "claude-sonnet-4-20250514",
systemPrompt: "You are a helpful assistant.",
});
const isLoading = status === "submitted" || status === "streaming";
// Send a message
await sendMessage({ text: "Hello!" });
// Render messages
messages.map((m) => (
<div key={m.id}>
{m.parts?.filter((p) => p.type === "text").map((p) => p.text).join("")}
</div>
));