{"id":27120874,"url":"https://github.com/janhkrueger/openai-api-cpp","last_synced_at":"2026-05-19T10:03:17.854Z","repository":{"id":191570155,"uuid":"684813430","full_name":"janhkrueger/openai-api-cpp","owner":"janhkrueger","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-11T10:11:10.000Z","size":158,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T10:45:06.226Z","etag":null,"topics":["cpp","demo","openai","openai-api"],"latest_commit_sha":null,"homepage":"https://gitlab.com/janhkrueger/openai-api-cpp","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janhkrueger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-08-29T22:58:04.000Z","updated_at":"2023-08-29T23:28:41.000Z","dependencies_parsed_at":"2025-04-07T10:40:18.619Z","dependency_job_id":"41719cc7-27fb-41b4-9da6-77716417c68e","html_url":"https://github.com/janhkrueger/openai-api-cpp","commit_stats":null,"previous_names":["janhkrueger/openai-api-cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/janhkrueger/openai-api-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janhkrueger%2Fopenai-api-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janhkrueger%2Fopenai-api-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janhkrueger%2Fopenai-api-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janhkrueger%2Fopenai-api-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janhkrueger","download_url":"https://codeload.github.com/janhkrueger/openai-api-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janhkrueger%2Fopenai-api-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273287701,"owners_count":25078581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"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":["cpp","demo","openai","openai-api"],"created_at":"2025-04-07T10:40:04.168Z","updated_at":"2026-05-19T10:03:17.792Z","avatar_url":"https://github.com/janhkrueger.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openai-api-cpp\n\n\n\n## Introduction\n\nA short demo how to use the OpenAI api via a C++ program based on [olrea/openai-cpp](https://github.com/olrea/openai-cpp)\n\nAlso included [nlohmann/json](https://github.com/nlohmann/json) as dependency for openai-cpp.\n\nFor reading the config value, [jbeder/yaml-cpp](https://github.com/jbeder/yaml-cpp) is used.\n\nThe entire project can be build and run inside Visual Studio Code and the shipped dev container.\n\n## Create the dev container\n\nWhen using Visual Studio Code with the Dev Container Plugin, upon opening the repository the IDE will recognize the devcontainer config under .devcontainer and ask if the repository should restarted and opened in the container. Do this and everything needed to build and run the application will be at hand.\n\n## Adjust the config file\n\nThe shipped config file consists of:\n\n```yaml\nopenai:\n  model: davinci-002\n  prompt: Say this is a test.\n  max_tokens: 9\n  temperature: 0\nloglevel:\n  level: info\n```\n\nFeel free to adjust the model and the prompt regarding the desired question send to openai.\n\nIt is only intended to act as a sample, not as a production ready application.\n\n## Compile the application\n\n```bash\nmake -f build/makefile\n```\n\n## Set the environment variable with the openai token\n\n```bash\nexport OPENAI_API_KEY='sk-abcdefghijklmnopqrstuvwxyz1234567890'\n```\n\n## Run the application\nThen you can run the application with\n\n```bash\nbin/main\n```\n\n## Sample Prompt and Response\n\nIn the folder **samples** there are the sample json send to openai and the response.\n\n## Project status\n\nFinished. It is only there to demonstrate the usage.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanhkrueger%2Fopenai-api-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanhkrueger%2Fopenai-api-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanhkrueger%2Fopenai-api-cpp/lists"}