Observed since 21 Oct, 10:08 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
ai-chat-kit Python adapters (FastAPI) for streaming chat
A minimal, production-lean AI Chat SDK/library built for:
core/
ChatEngine: orchestrates provider calls, streaming, and optional memory persistenceProvider: provider interface (generate() + stream() async generator)types: strongly typed message/request/stream event typesEventBus: small typed event emitter for observability hooksproviders/
mockProvider: deterministic mock provider that streams token-ish chunksmemory/
inMemory: minimal memory store keyed by userIdadapters/
fastapi: SSE endpoint POST /chat/streamreact: useAIChat hook consuming SSE via fetch + ReadableStreamui/
ChatWindow: minimal React component using useAIChatThe FastAPI adapter emits SSE events:
event: token with JSON {"type":"token","token":"..."} repeated per tokenevent: done with JSON {"type":"done","message":{"role":"assistant","content":"..."}, ...}event: error with JSON {"type":"error","error":{"message":"..."}}The React hook parses SSE frames delimited by blank lines (\n\n).
Install the Python package (local editable install):
python -m pip install -e ai-chat-kit
Create a small server.py (in your own backend project) and pass keys explicitly:
from ai_chat_kit.adapters.fastapi.main import create_app
app = create_app(
# Provide whichever providers you want to enable:
gemini_api_key="YOUR_GEMINI_API_KEY",
# openai_api_key="YOUR_OPENAI_API_KEY",
# anthropic_api_key="YOUR_ANTHROPIC_API_KEY",
)
Start the server:
python -m uvicorn server:app --reload --port 8000
The FastAPI adapter will attempt a real streaming call based on params.model.
API keys are not loaded from .env / .env.local. Pass them to create_app(...) or set process env vars yourself.
By default the FastAPI adapter will persist chat history in a local SQLite DB file. You can control the DB path with:
export AI_CHAT_KIT_SQLITE_PATH="/path/to/chat_history.sqlite3"
Test streaming:
curl -N -X POST "http://localhost:8000/chat/stream" \
-H "Content-Type: application/json" \
-d '{"userId":"u1","messages":[{"role":"user","content":"Hello streaming"}]}'
Example usage with the included UI component:
import React from "react";
import { ChatWindow } from "./ai-chat-kit/ui/ChatWindow";
export default function App() {
return <ChatWindow userId="u1" endpoint="http://localhost:8000/chat/stream" />;
}
Using the core engine directly (no HTTP, no UI):
import { ChatEngine } from "./ai-chat-kit/core/ChatEngine";
import { MockProvider } from "./ai-chat-kit/providers/mockProvider";
import { InMemoryChatMemory } from "./ai-chat-kit/memory/inMemory";
const engine = new ChatEngine(new MockProvider(), { memory: new InMemoryChatMemory() });
const res = await engine.generate({
userId: "u1",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.message.content);
for await (const ev of engine.stream({ userId: "u1", messages: [{ role: "user", content: "Stream this" }] })) {
if (ev.type === "token") process.stdout.write(ev.token);
if (ev.type === "done") process.stdout.write("\n");
}
AIProvider to connect OpenAI/Anthropic/local models, add retries, rate limits, tracing.messages with retrieved context before calling the provider.EventBus for tokens/done/error; forward to logs/metrics/traces.Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 29 Dec 2025 | 3 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 10:08 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:10b9607d1c9ff0bcf598307f32f15c570fcfb88978492079a3afce2a31d4e033