{"id":15047627,"url":"https://github.com/fugashy/chatgpt_client_cpp","last_synced_at":"2026-02-17T11:01:28.377Z","repository":{"id":245645850,"uuid":"806833773","full_name":"fugashy/chatgpt_client_cpp","owner":"fugashy","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-23T02:45:52.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-10-07T08:43:51.645Z","etag":null,"topics":["chatgpt","chatgpt-api","cpp","cpp17","cpprestsdk","docker","docker-image","dockerfile","openai","rest-api"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fugashy.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-05-28T02:05:49.000Z","updated_at":"2024-06-23T02:49:16.000Z","dependencies_parsed_at":"2024-06-23T06:06:23.912Z","dependency_job_id":"67181bc1-01a4-433f-81f8-b3df6dc4d309","html_url":"https://github.com/fugashy/chatgpt_client_cpp","commit_stats":null,"previous_names":["fugashy/chatgpt_client_cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fugashy/chatgpt_client_cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fugashy%2Fchatgpt_client_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fugashy%2Fchatgpt_client_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fugashy%2Fchatgpt_client_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fugashy%2Fchatgpt_client_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fugashy","download_url":"https://codeload.github.com/fugashy/chatgpt_client_cpp/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fugashy%2Fchatgpt_client_cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29541119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T08:11:05.436Z","status":"ssl_error","status_checked_at":"2026-02-17T08:09:38.860Z","response_time":100,"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":["chatgpt","chatgpt-api","cpp","cpp17","cpprestsdk","docker","docker-image","dockerfile","openai","rest-api"],"created_at":"2024-09-24T21:01:39.940Z","updated_at":"2026-02-17T11:01:28.355Z","avatar_url":"https://github.com/fugashy.png","language":"C++","readme":"# chargpt_client_cpp\n\nA CHATGPT client library implemented in C++\n\n# Dependencies\n\n- restcppsdk\n\n# Supported API\n\nSome optional fields are not implemented yet...\n\n- [ ] Audio\n\n- [ ] Chat\n\n  - [x] Chat Completion\n\n  - [ ] Chat Completion Object\n\n  - [ ] Chat Completion Chunk Object\n\n- [ ] Embeddings\n\n- [ ] Fine-Tuning\n\n- [ ] Batch\n\n- [ ] Files\n\n- [ ] Images\n\n- [ ] Models\n\n- [ ] Moderations\n\n- [x] Assistancts\n\n  - [x] Create assistant\n\n  - [x] List assistants\n\n  - [x] Retrieve assistant\n\n  - [x] Modify assistant\n\n  - [x] Delete assistant\n\n- [ ] Threads\n\n  - [x] Create\n\n  - [x] Retrive\n\n  - [ ] Modify\n\n  - [x] Delete\n\n- [ ] Messages\n\n  - [x] Create message\n\n  - [x] List messages\n\n  - [x] Retrieve message\n\n  - [ ] Modify message\n\n  - [x] Delete message\n\n- [ ] Runs\n\n  - [x] Create runs\n\n  - [x] List runs\n\n  - [x] Retrieve runs\n\n  - [ ] Modify runs\n\n  - [ ] Submit tool outputs\n\n  - [x] Cancel runs\n\n- [ ] Run Steps\n\n- [ ] Vector Stores\n\n- [ ] Vector Store Files\n\n- [ ] Vector Store File Batches\n\n- [ ] Streaming\n\n# Operating environment for verification\n\n- macOS Sonoma 14.5\n\n# Required\n\n- C++ 17\n\n- cpprestsdk\n\n  https://github.com/microsoft/cpprestsdk\n\n# How to build\n\n```bash\nmkdir build\ncd build\ncmake ..\nmake install\n```\n\n# Sample code\n\n```cpp\n#include \"chatgpt_client_cpp/chatgpt_client_cpp.hpp\"\n\n\nusing chatgpt_client_cpp::client::Client;\nusing ReqBuilder = chatgpt_client_cpp::v1::chat::Builder;\nusing ReqBodyBuilder = chatgpt_client_cpp::v1::chat::body::Builder;;\nusing chatgpt_client_cpp::v1::chat::body::MessageElementBuilder;;\nusing chatgpt_client_cpp::v1::chat::body::ContentTextPartBuilder;\nusing chatgpt_client_cpp::v1::chat::body::ContentImageUrlPartBuilder;\nusing chatgpt_client_cpp::v1::chat::body::ImageUrlBuilder;\n\n\nint main(int argc, char** argv)\n{\n  std::string text = \"なにが写っていますか\";\n  std::string image_url = \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\";\n  if (argc \u003e 1)\n  {\n    text = argv[1];\n  }\n  if (argc \u003e 2)\n  {\n    image_url = argv[2];\n  }\n  std::cout \u003c\u003c \"argument num: \" \u003c\u003c argc \u003c\u003c std::endl;\n  std::cout \u003c\u003c \"text        : \" \u003c\u003c text \u003c\u003c std::endl;\n  std::cout \u003c\u003c \"image url   : \" \u003c\u003c image_url \u003c\u003c std::endl;\n\n  // Here's an example using a synchronous interface to obtain responses.\n  // Asynchronous interface is also provided by client class\n\n  // Build a request\n  const auto req = ReqBuilder()\n    .body(ReqBodyBuilder()\n        .model(\"gpt-4o\")\n        .message(MessageElementBuilder()\n          .role(\"user\")\n          .content(ContentTextPartBuilder()\n              .type(\"text\")\n              .text(text)\n              .build())\n          .content(ContentImageUrlPartBuilder()\n              .type(\"image_url\")\n              .image_url(ImageUrlBuilder()\n                .url(image_url)\n                .build())\n              .build())\n          .build())\n        .max_tokens(300)\n        .build())\n    .build();\n\n  // Send a request then get a response\n  const auto res = Client::GetInstance().Request\u003cClient::OptionalJson\u003e(req);\n\n  std::cout \u003c\u003c \"res :\" \u003c\u003c res.value().serialize() \u003c\u003c std::endl;\n\n  return EXIT_SUCCESS;\n}\n```\n\n# Sample executables\n\n- chatgpt_client_cpp_sample_chat\n\n```bash\nchatgpt_client_cpp_sample_chat \\\n  こんにちは．日本の名所を教えて下さい．\n\n\u003e res :{\"choices\":[{\"finish_reason\":\"length\",\"index\":0,\"logprobs\":null,\"message\":{\"content\":\"こんにちは！ 日本にはたくさんの名所がありますが、代表的なものをいくつか紹介しますね。\\n\\n1. 京都：日本の歴史や文化が 色濃く残る京都は、多くの寺院や神社が点在する観光地として有名です。清水寺や金閣寺、伏見稲荷大社などが人気の観光スポットです。\\n\\n2. 東京：日本の首都であり、繁華な都市東京にも多くの名所があります。東京タワーや 浅草寺、新宿御苑などが代表的な観光地です。\\n\\n3. 富士山：日本を代表する観光スポットといえば、やはり富士 山です。日本最高峰の富士山は、美しい形状と四季折々の景色で多くの観光客を魅了しています。\\n\\nこれ以外にも、日本には多くの素晴らしい\",\"role\":\"assistant\"}}],\"created\":1717027020,\"id\":\"chatcmpl-9UNS8Jslac0l9vwujR6Imh0YMYgzv\",\"model\":\"gpt-3.5-turbo-0125\",\"object\":\"chat.completion\",\"system_fingerprint\":null,\"usage\":{\"completion_tokens\":300,\"prompt_tokens\":22,\"total_tokens\":322}}\n```\n\n- chatgpt_client_cpp_sample_chat_with_image_uri\n\n```bash\nchatgpt_client_cpp_sample_chat_with_image_uri \\\n  こんにちは．何が写っていますか\n  https://upload.wikimedia.org/wikipedia/commons/4/46/Leadenhall_Market_In_London_-_Feb_2006_rotated.jpg\n\u003e argument num: 3\n\u003e text        : こんにちは．何が写っていますか\n\u003e image url   : https://upload.wikimedia.org/wikipedia/commons/4/46/Leadenhall_Market_In_London_-_Feb_2006_rotated.jpg\n\u003e res :{\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"logprobs\":null,\"message\":{\"content\":\"こんにちは。こ の写真には美しいアーケード商店街が映っています。写真の建物は歴史的で装飾が施されたアーケードで、天井はガラスと鉄の構造になっています。道の両脇に様々な店が並んでいます。また、いくつかの人々が道を歩いている様子も見えます。商業施設や観光地である可能性が高いです。\",\"role\":\"assistant\"}}],\"created\":1717026752,\"id\":\"chatcmpl-9UNNo4U1Kr5wwbtlilVKwz30G7ZWK\",\"model\":\"gpt-4o-2024-05-13\",\"object\":\"chat.completion\",\"system_fingerprint\":\"fp_aa87380ac5\",\"usage\":{\"completion_tokens\":105,\"prompt_tokens\":1119,\"total_tokens\":1224}}\n```\n\n- chatgpt_client_cpp_sample_use_thread\n\n```bash\nchatgpt_client_cpp_sample_use_thread\n\n\u003e messages before asking to AI\n\u003e from: user -\u003e\n\u003e          Hello\n\u003e messages after asking to AI\n\u003e from: assistant -\u003e\n\u003e          こんにちは！君の面白さのバッテリーはフル充電かい？それとも笑いの充電器が必要なら、任せておいて ！今日はどんなお笑いネタを探してる？\n\u003e from: user -\u003e\n\u003e          Hello\n```\n\nUsing a docker container\n\n```bash\ndocker run \\\n  -it \\\n  --rm \\\n  -e OPENAI_API_KEY=$OPENAI_API_KEY \\\n  cgccpp:24.04 chatgpt_client_cpp_sample_use_thread\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffugashy%2Fchatgpt_client_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffugashy%2Fchatgpt_client_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffugashy%2Fchatgpt_client_cpp/lists"}