Skip to main content
The direct OpenAI and LiteLLM provider adapters have been removed. Any use_chatgpt field shown below is a migration-error shim: setting it to True raises before inference. Use the Lemonade gateway path.
Import: from gaia.chat.sdk import AgentSDK, AgentConfig, SimpleChat, AgentSession, quick_chat
See also: User Guide · API Specification

Core Classes

AgentConfig

Configure your chat session:
The SDK applies the system prompt once per request. 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:
A reasoning model (Gemma-4, Qwen3) can spend the whole 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

With RAG enabled, 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) -> AgentResponse
  • send_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() -> Dict
  • display_stats(stats=None)
  • start_interactive_session()

SimpleChat Methods

  • ask(question: str) -> str — Ask question, get response
  • ask_stream(question: str) — Ask question, stream response
  • clear_memory() — Clear conversation memory
  • get_conversation() -> List[Dict] — Get conversation history

AgentSession Methods

  • create_session(session_id, config=None, **kwargs) -> AgentSDK — Create new session
  • get_session(session_id) -> AgentSDK — Get existing session
  • delete_session(session_id) -> bool — Delete session
  • list_sessions() -> List[str] — List all sessions
  • clear_all_sessions() — Delete all sessions

Utility Functions

  • quick_chat(message, system_prompt=None, model=None, assistant_name=None) -> str
  • quick_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 apps

Memory Management

Configure max_history_length based on memory constraints

Performance

Enable show_stats=True during development

Resource Cleanup

Clear sessions when done to free memory