Welcome to the ClientAgentJS documentation. This library is designed to add AI agent capabilities to your web applications with a Zero-Backend approach.
- API Contract: Detailed reference for
createAgent, sessions, profiles, and MCP management. - Architecture Overview: Learn how the library handles storage, provider adapters, and the event system.
- Global Variable Support: You can use
ClientAgentas a global object if you includedist/clientagentjs.global.jsvia a<script>tag. - Robust Networking: Includes automatic retries for network errors and 429/5xx status codes.
- Improved Debugging: Error messages now include full details from AI providers.
Explore these examples to learn how to integrate ClientAgentJS into different scenarios:
The flagship example. A professional chat interface that includes session management, streaming cancellation, Markdown rendering, and real-time event logging.
AI-powered forms. Demonstrates how to add AI help to standard text fields for content improvement and generation based on form context.
Model Context Protocol. A technical example on connecting the agent to external MCP servers to access databases or local files.
To test any example locally:
- Build the library:
npm run build - Serve the project root with a static server (e.g.,
npx serveorpython3 -m http.server) - Open the example path in your browser.
See license: ClientAgentJS