Adam
Embeddable AI agent library in C.
Adam gives you a complete agent loop: tool calling, memory, sessions, voice, streaming, structured output, in one #include . Works with cloud APIs (Anthropic, OpenAI, Google Gemini, Groq, Together, xAI) and local models (llama.cpp) through the same interface. Compiles on macOS, Linux, Windows, iOS, Android, and WASM.
Quick Start
#include "adam.h" int main ( void ) { adam_init (); adam_settings_t * s = adam_create_settings (); adam_settings_set_provider ( s , ADAM_API_ANTHROPIC , getenv ( "ANTHROPIC_API_KEY" ), "claude-sonnet-4-20250514" ); adam_history_t * h = adam_history_create (); adam_run_result_t r = adam_run ( s , h , "What is the capital of France?" ); printf ( "%s
" , r . final_response ); // "The capital of France is Paris." adam_run_result_free ( & r ); adam_history_destroy ( h ); adam_settings_destroy ( s ); adam_cleanup (); }
make deps # build llama.cpp + whisper.cpp make all # build libadam.a make test # run 161 tests (ASan + UBSan)
Features
Feature Description Agent loop Tool calling with automatic iteration until final response Three providers Anthropic, OpenAI, Google Gemini + any compatible API + local GGUF via llama.cpp Local vision Multimodal image understanding via llama.cpp + mmproj (Gemma 3, LLaVA, etc.) Image generation Native image output via Gemini image models (gemini-3.1-flash-image-preview) Database extensions SQLite and PostgreSQL extensions — embed Adam as SQL functions that query the same database 13 built-in tools File I/O, shell, calculator, SQL, web fetch/search, HTTP POST, memory, research, multi-agent Long-term memory Hybrid BM25 + vector search via SQLite (sqlite-memory + sqlite-vector) Session persistence Save/load conversations with UUIDv7 keys Telegram bot Full-featured Telegram integration with text, voice, images, tools, and memory Voice STT (Whisper cloud/local) + TTS (cloud/system) + full audio pipeline Streaming Real-time token delivery via callback Structured output adam_run_json() with validation and retry Evolution loop Self-improving agent: iterate, score, refine strategy Research mode Autonomous multi-iteration information gathering with report synthesis Multi-agent Agent A invokes Agent B as a tool, with independent settings/tools Guardrails Pre-send and post-receive validation callbacks Response cache LRU hash table keyed on model + message history History management Clone, summarize (LLM-based compression), token estimation Thread pool Concurrent agent execution with job queue Filesystem sandbox Tools restricted to explicitly allowed directories Cross-platform macOS, Linux, Windows, iOS, Android, WASM (Emscripten) Arena allocator Zero-leak per-iteration memory with automatic cleanup
Build
... continue reading