{"id":34632690,"url":"https://github.com/mcpplibs/llmapi","last_synced_at":"2026-02-10T23:07:24.393Z","repository":{"id":330306959,"uuid":"1118791233","full_name":"mcpplibs/llmapi","owner":"mcpplibs","description":"`import mcpplibs.llmapi` | Modern C++ LLM API client with openai-compatible support","archived":false,"fork":false,"pushed_at":"2025-12-24T16:18:11.000Z","size":175,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T21:18:02.082Z","etag":null,"topics":["llm","llm-api","llmapi","modern-cpp","modules","openai-api"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcpplibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-18T09:31:53.000Z","updated_at":"2025-12-27T13:47:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mcpplibs/llmapi","commit_stats":null,"previous_names":["mcpplibs/llmapi"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mcpplibs/llmapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpplibs%2Fllmapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpplibs%2Fllmapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpplibs%2Fllmapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpplibs%2Fllmapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcpplibs","download_url":"https://codeload.github.com/mcpplibs/llmapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcpplibs%2Fllmapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29321277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llm","llm-api","llmapi","modern-cpp","modules","openai-api"],"created_at":"2025-12-24T16:53:54.273Z","updated_at":"2026-02-10T23:07:24.380Z","avatar_url":"https://github.com/mcpplibs.png","language":"C++","readme":"# llmapi\n\n\u003e Modern C++ LLM API client with openai-compatible support\n\n[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)\n[![C API](https://img.shields.io/badge/C_API-ok-green.svg)](https://en.cppreference.com/w/cpp/23)\n[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)\n[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE)\n[![OpenAI Compatible](https://img.shields.io/badge/OpenAI_API-Compatible-green.svg)](https://platform.openai.com/docs/api-reference)\n\n| English - [简体中文](README.zh.md) - [繁體中文](README.zh.hant.md) |\n|:---:|\n| [Documentation](docs/) - [C++ API](docs/cpp-api.md) - [C API](docs/c-api.md) - [Examples](docs/examples.md) |\n\nClean, type-safe LLM API client using C++23 modules. Fluent interface with zero-cost abstractions. Works with OpenAI, Poe, DeepSeek and compatible endpoints.\n\n## ✨ Features\n\n- **C++23 Modules** - `import mcpplibs.llmapi`\n- **Auto-Save History** - Conversation history managed automatically\n- **Type-Safe Streaming** - Concept-constrained callbacks\n- **Fluent Interface** - Chainable methods\n- **C API** - Full C language support with OOP style\n- **Provider Agnostic** - OpenAI, Poe, and compatible endpoints\n\n## Quick Start\n\n### C++ API\n\n```cpp\nimport std;\nimport mcpplibs.llmapi;\n\nint main() {\n    using namespace mcpplibs;\n    \n    llmapi::Client client(std::getenv(\"OPENAI_API_KEY\"), llmapi::URL::Poe);\n\n    client.model(\"gpt-5\")\n          .system(\"You are a helpful assistant.\")\n          .user(\"In one sentence, introduce modern C++. 并给出中文翻译\")\n          .request([](std::string_view chunk) {\n                std::print(\"{}\", chunk);\n                std::cout.flush();\n          });\n\n    return 0;\n}\n```\n\n### C API\n\n```c\n#include \u003cstdio.h\u003e\n\n#include \"llmapi.h\"\n\nvoid stream_print(const char* s, size_t len, void* data) {\n    printf(\"%.*s\", (int)len, s);\n    fflush(stdout);\n}\n\nint main(void) {\n    llmapi_client_t* c = llmapi_client_create(getenv(\"OPENAI_API_KEY\"), LLMAPI_URL_POE);\n\n    c-\u003eset_model(c, \"gpt-5\");\n    c-\u003eadd_system_message(c, \"You are a helpful assistant.\");\n    c-\u003eadd_user_message(c, \"In one sentence, introduce modern C++. 并给出中文翻译\");\n    c-\u003erequest_stream(c, stream_print, NULL);\n    \n    c-\u003edestroy(c);\n    return 0;\n}\n```\n\n### Models / Providers\n\n```cpp\nllmapi::Client client(apiKey, llmapi::URL::OpenAI);    // OpenAI\nllmapi::Client client(apiKey, llmapi::URL::Poe);       // Poe\nllmapi::Client client(apiKey, llmapi::URL::DeepSeek);  // Deepseek\nllmapi::Client client(apiKey, \"https://custom.com\");   // Custom\n```\n\n## 🛠️ Building\n\n```bash\nxmake              # Build\nxmake run basic    # Run example(after cofig OPENAI_API_KEY)\n```\n\n## 📦 Use in Build Tools\n\n### xmake\n\n```lua\n-- 0 - Add mcpplibs's index repos\nadd_repositories(\"mcpplibs-index git@github.com:mcpplibs/mcpplibs-index.git\")\n\n-- 1 - Add the libraries and versions you need\nadd_requires(\"llmapi 0.0.1\")\n-- add_requires(\"llmapi 0.0.1\", configs = { capi = true }) -- if use c api\n```\n\n\u003e More: [mcpplibs-index](https://github.com/mcpplibs/mcpplibs-index)\n\n### cmake\n\n```\ntodo...\n```\n\n## 📚 API Reference\n\n**C++ Core Methods:**\n- `model(name)` - Set model\n- `user/system/assistant(content)` - Add messages\n- `request()` - Non-streaming (returns JSON)\n- `request(callback)` - Streaming\n- `getAnswer()` - Get last assistant reply\n- `getMessages()` - Get conversation history\n- `clear()` - Clear history\n\n**C API:** All methods available via function pointers (`client-\u003emethod(client, ...)`)\n\n## 📄 License\n\nApache-2.0 - see [LICENSE](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcpplibs%2Fllmapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcpplibs%2Fllmapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcpplibs%2Fllmapi/lists"}