A small, easy-to-use C++ library for REST API requests and LLM chat, built on libcurl. The chat client works with a local model via Ollama or cloud providers (Groq, OpenRouter, DeepSeek, OpenAI, Anthropic) behind one API.
Looking for
ML::File? The filesystem utilities live in File ML now. The class is unchanged; depend onfile-mland#include "fileml.h".
It aims to make two things one-liners from C++:
// HTTP request with a rich response
ML::Requests req;
ML::Response r = req.get("https://api.example.com/data");
if (r.ok()) std::cout << r.status << "\n" << r.body;
// Talk to an LLM (local Ollama here; swap the Provider for a cloud model)
ML::Chat chat(ML::Provider::Ollama, "llama3.2:1b");
std::cout << chat.ask("Explain RAII in one sentence.");Full documentation, including build instructions and usage examples, lives in the project wiki:
- Getting Started: requirements, building, prebuilt binaries
- Requests: the HTTP client
- Chat: the LLM client
ML::Requests: full HTTP verbs (get/post/put/patch/del/head) returning a richResponse, with inline request bodies, multiple request headers, and per-request timeouts. Also filedownload(streamed to disk with optional progress), multipartupload, and opt-in auto-retrieswith backoff. (Legacy string-returninggetReq/postReq/etc. are kept for compatibility.)ML::Auth/ML::Url: helpers for auth headers (bearer/basic/apiKey) and percent-encoded query URLs (Url::build).ML::Response:status,body, responseheaders(a map), andok()(true for any 2xx).ML::Chat: conversational client for Ollama (local), Groq, OpenRouter, DeepSeek, OpenAI, or Anthropic:- one API across every provider
- persistent system prompt and conversation memory
- adjustable temperature and max tokens
- token streaming via a callback
- reasoning-token support for reasoning models (the model's "thinking" streams
to a separate callback, available via
lastReasoning()) - save/load conversation history to a JSON file (
saveHistory/loadHistory)
- All HTTP runs in-process via libcurl (HTTPS through Schannel on Windows), with
no
curlsubprocess and no temp files.
MIT. See LICENSE.