Chat & Streaming
Send chat requests and render incremental output.
#Chat
import { Elektric } from "elektric-ai";
const elektric = new Elektric({ apiKey: process.env.ELEKTRIC_API_KEY! });
const response = await elektric.chat({
userId: "user_123",
conversationId: "thread_123",
message: "Hello",
});
console.log(response.message);#Streaming
Set stream for Server-Sent Events. Render text deltas and treat [DONE] as completion.
for await (const event of elektric.chat.stream({ message: "Explain DNS" })) {
if (event.type === "text_delta") process.stdout.write(event.text);
}#Cancellation
Abort to stop receiving data. Generated usage may still be billed. Streaming currently does not persist Conversation context.
Authentication →Standard errors →Pricing & Billing →Limits →