Install
Create an API key. Install the SDK for your application.
Terminal, TypeScript
npm install @alethi/pantheon-chat react@18 react-dom@18
Terminal, Python
pip install pantheon-chat
React
Render the component with an agent slug and application tool handlers.
App.tsx
import { PantheonChat } from "@alethi/pantheon-chat/react";
export default function App() {
return (
<PantheonChat
baseUrl="PANTHEON_BASE_URL"
apiKey="PANTHEON_API_KEY"
agentSlug="todo-assistant"
tools={{
echo_tool: async (input) => ({ echoed: input.message }),
todo_ops: {
requireApproval: true,
execute: async (input) => ({ applied: true, operations: input.operations }),
},
}}
/>
);
}
requireApproval shows an in-page Approve or Decline card.
Node client
Use the core client with Node 18 or later.
app.mjs
import { PantheonClient } from "@alethi/pantheon-chat";
const baseUrl = process.env.PANTHEON_BASE_URL;
const apiKey = process.env.PANTHEON_API_KEY;
const client = new PantheonClient({ baseUrl, apiKey });
const session = await client.createSession({ agentSlug: "todo-assistant" });
const run = await client.startRun(session.id, "Hello");
for await (const event of client.streamEvents(session.id)) {
if (event.type === "message.delta") process.stdout.write(event.delta.text || "");
if (event.type === "run.completed") break;
}
Props
| Prop | Use |
|---|---|
baseUrl | Pantheon API base URL. |
apiKey | Bearer API key. |
agentSlug | Agent for a new session. |
deploymentId | Explicit deployment instead of a slug. |
tools | Application tool handlers and approval rules. |
theme | light, dark, or auto. |
title | Session title. |
Python
Use the async client directly.
app.py
import asyncio
import os
from pantheon_chat import PantheonClient
async def main():
async with PantheonClient(
os.environ["PANTHEON_BASE_URL"],
os.environ["PANTHEON_API_KEY"],
) as client:
session = await client.create_session(agent_slug="todo-assistant")
run = await client.start_run(session.id, "What is 15 + 15?")
async for event in client.stream_events(session.id, run_id=run.run_id, stop_on_terminal=True):
print(event.type, event.content or event.data)
asyncio.run(main())
Terminal chat
Terminal
export PANTHEON_BASE_URL="https://pantheon-todo.alethiconsulting.com/pantheon-api"
export PANTHEON_API_KEY="PANTHEON_API_KEY"
export PANTHEON_AGENT_SLUG="todo-assistant"
python -m pantheon_chat
Application tools ask for approval. Pass --auto-approve only for trusted tools.
Streamlit
Terminal
pip install "pantheon-chat[streamlit]"
export PANTHEON_BASE_URL="https://pantheon-todo.alethiconsulting.com/pantheon-api"
export PANTHEON_API_KEY="PANTHEON_API_KEY"
export PANTHEON_AGENT_SLUG="todo-assistant"
pantheon-chat-streamlit
Pitfalls
- Queued text can wait behind approval: Resolve the approval before expecting the queued message to run.
- A network reconnect repeats output: Persist only durable SSE ids. Never use an ephemeral delta's JSON id as the cursor.
- A Stop request fails: Keep the run active and show the error until cancel returns HTTP 202.