{"id":15047585,"url":"https://github.com/abeldiress/cohere-cpp","last_synced_at":"2026-02-18T02:03:11.897Z","repository":{"id":256840395,"uuid":"836982540","full_name":"abeldiress/cohere-cpp","owner":"abeldiress","description":"A C++ library providing access to Cohere's API.","archived":false,"fork":false,"pushed_at":"2024-11-04T19:03:50.000Z","size":220,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T02:24:38.420Z","etag":null,"topics":["ai","cohere-ai","cohere-api","cpp17","sdk-cpp"],"latest_commit_sha":null,"homepage":"https://docs.cohere.com/reference/about","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abeldiress.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}},"created_at":"2024-08-02T01:08:35.000Z","updated_at":"2025-10-01T01:26:30.000Z","dependencies_parsed_at":"2025-02-16T06:32:08.698Z","dependency_job_id":"96f7347d-957e-4e2a-9b92-5ae581f90d99","html_url":"https://github.com/abeldiress/cohere-cpp","commit_stats":null,"previous_names":["abeldiress/cohere-cpp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/abeldiress/cohere-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeldiress%2Fcohere-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeldiress%2Fcohere-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeldiress%2Fcohere-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeldiress%2Fcohere-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abeldiress","download_url":"https://codeload.github.com/abeldiress/cohere-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeldiress%2Fcohere-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29566366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"online","status_checked_at":"2026-02-18T02:00:09.468Z","response_time":162,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ai","cohere-ai","cohere-api","cpp17","sdk-cpp"],"created_at":"2024-09-24T21:00:44.215Z","updated_at":"2026-02-18T02:03:11.836Z","avatar_url":"https://github.com/abeldiress.png","language":"C++","readme":"# Cohere C++ SDK\n![cpp badge](https://img.shields.io/badge/version-C++17-blue)\n![MIT badge](https://img.shields.io/github/license/abeldiress/cohere-cpp)\n\n## Introduction\n\n`cohere-cpp` is an unofficial C++17 library to utilize Cohere's API through [libcurl](https://curl.se/libcurl/) and [nlohmann/json](https://github.com/nlohmann/json). Although still a work in progress, it allows thread-safe access to most API endpoints through only a single header file, `cohere.h`.\n\n## Example\n\nPython, from [Cohere's SDK](https://github.com/cohere-ai/cohere-python?tab=readme-ov-file#usage)\n```py\nimport cohere\n\nco = cohere.Client(\n    api_key=\"YOUR_API_KEY\",\n)\n\nchat = co.chat(\n    message=\"hello world!\",\n    model=\"command\"\n)\n\nprint(chat)\n```\n\nC++\n```cpp\n#include \u003ciostream\u003e\n#include \"cohere.h\" // only header file necessary\n\nusing namespace std;\nusing namespace cohere;\n\nint main() {\n    Cohere co{\"YOUR_API_KEY\"}; // can rewrite to make it more \"Pythonic\"\n    Json chat = co.Chat-\u003echat(\n        \"hello world!\", \n        \"command\"\n    );\n\n    cout \u003c\u003c chat.dump() \u003c\u003c endl;\n}\n```\n\nSimilar to the Python SDK, you can either provide the key or place it as an enviroment variable name `CO_API_KEY`.\n\nFor chat streams, you can perform the following:\n\n```cpp\nint main() {\n    Cohere co(\"YOUR_API_KEY\");\n    Json chat_stream = co.Chat-\u003echat(\n        \"Tell me about Terry Fox\", \n        \"command\",\n        true\n    );\n\n    for (auto \u0026event: chat_stream[\"stream\"]) {\n        if (event[\"event_type\"] == \"text-generation\") {\n            cout \u003c\u003c event[\"text\"] \u003c\u003c endl;\n        }\n    }\n}\n```\n\n## Endpoint Status\n\n- [x] chat_stream\n- [x] chat\n- [ ] dataset†\n- [x] generate_stream\n- [x] generate\n- [x] embed\n- [x] rerank\n- [x] classify\n- [x] summarize\n- [x] tokenize\n- [x] detokenize\n- [x] check_api_key\n\n† missing 1 endpoint\n\nPriority TODO: migrate the API Chat, Embed, Rerank, and Classify to v2. \n\n## Future Plans (unordered)\n - Encapsulate parameters with easy-to-use enumerations and classes, finish other endpoints.\n - Provide support for Cohere's other [supported enviroments](https://docs.cohere.com/docs/cohere-works-everywhere#supported-environments) (Bedrock, Azure, etc.)\n - Improve build routine.\n - Add the library to vcpkg for easier access.\n - The library only covers non-2XX errors. Expand to cover API specifc errors through exception based handling.\n - Provide basic documentation for every available endpoint.\n\n## Acknowledgements\n - [Everything cURL](https://everything.curl.dev/)\n - [Cohere's Python SDK](https://github.com/cohere-ai/cohere-python)\n - [OpenAI's Community Maintained Libraries](https://platform.openai.com/docs/libraries/community-libraries)\n - [nlohmann::json](https://github.com/nlohmann/json), spectacular library\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeldiress%2Fcohere-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabeldiress%2Fcohere-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeldiress%2Fcohere-cpp/lists"}