Source Code:
src/gaia/chat/sdk.py · src/gaia/rag/sdk.pyImport:
from gaia.chat.sdk import AgentSDK, AgentConfig, SimpleChat, AgentSession, quick_chatCore Classes
AgentConfig
Configure your chat session:set_system_prompt() and
update_config(system_prompt=...) take effect on the next request; structured
message calls can override it for one request without changing the stored prompt.
Custom prompts use the native system-message channel for every provider.
AgentResponse
Responses include text, history, and optional statistics:max_tokens budget
thinking. The reply then has empty text, finish_reason == "length", and the
partial thought in reasoning. send() and send_messages() also log a warning
naming the budget; the streaming methods report it on the final chunk. Raise
max_tokens when that happens.
SimpleChat
Lightweight wrapper for basic chat without complex configuration. Perfect for getting started quickly.Quick Chat (One-Off)
Chat with Memory
Streaming
Custom Assistant
Session Management
Manage multiple conversation contexts:Conversation History
Failed requests and streams cancelled before the final chunk preserve the previous history. Once the final chunk arrives, the completed turn remains in history even if the caller stops reading immediately.Chat with RAG
send() and send_stream() raise RAGContextError instead of answering without your documents. It fires when retrieval fails, or when the model’s window leaves under 500 tokens for document context after the system prompt, history, question and reply reserve. The message says what to shrink or what broke, and history is left as it was.
Advanced RAG Configuration
Custom Messages
API Reference
AgentSDK Methods
Messaging
send(message: str) -> AgentResponsesend_stream(message: str)send_messages(messages, system_prompt) -> AgentResponse
History
get_history() -> List[str]clear_history()get_formatted_history() -> List[Dict]conversation_pairs(property)
RAG (Document Q&A)
enable_rag(documents=None, **kwargs)disable_rag()add_document(path: str) -> bool
Configuration
update_config(**kwargs)get_stats() -> Dictdisplay_stats(stats=None)start_interactive_session()
SimpleChat Methods
ask(question: str) -> str— Ask question, get responseask_stream(question: str)— Ask question, stream responseclear_memory()— Clear conversation memoryget_conversation() -> List[Dict]— Get conversation history
AgentSession Methods
create_session(session_id, config=None, **kwargs) -> AgentSDK— Create new sessionget_session(session_id) -> AgentSDK— Get existing sessiondelete_session(session_id) -> bool— Delete sessionlist_sessions() -> List[str]— List all sessionsclear_all_sessions()— Delete all sessions
Utility Functions
quick_chat(message, system_prompt=None, model=None, assistant_name=None) -> strquick_chat_with_memory(messages, system_prompt=None, model=None, assistant_name=None) -> List[str]
Best Practices
Choose the Right Interface
SimpleChat for basic needs, AgentSDK for full features, AgentSession for multi-context appsMemory Management
Configure
max_history_length based on memory constraintsPerformance
Enable
show_stats=True during developmentResource Cleanup
Clear sessions when done to free memory
Related
- User Guide — CLI usage, RAG commands, troubleshooting
- GAIA Chat Desktop — Desktop app with GUI and document Q&A
- Agent UI SDK — Python backend for the desktop application (FastAPI, SQLite, REST API)
- LLM Client — Language model integration
- API Specification — Technical specification