GroqAPI-cpp (Groq API Wrapper) is a minimalistic C++ library for easy interaction with the Groq API. It simplifies sending requests, processing responses, and supports multithreading. Ideal for integrating Groq's language processing into C++ applications efficiently. Works seamlessly with C++14 and later versions.
- Send chat requests to the Groq API with ease.
- Print chat responses directly to the console.
- Thread-safe singleton pattern ensures safe concurrent access.
- Utilizes Windows HTTP Services for network communication.
- Supports C++14 and later versions.
#include "GroqAPI.hpp"
int main() {
try {
std::string apiKey = "groq-api-key";
std::string model = "llama3-8b-8192";
std::string userMessage = "Hello there!";
std::string response = Groq::GroqApi::GetInstance().SendChatRequest(apiKey, model, userMessage);
Groq::GroqApi::GetInstance().PrintChatResponse(response);
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}
- Windows SDK (for WinHttp)
- nlohmann/json (included as a header-only library)
- C++14 compiler or later
Simply include the GroqApi.hpp header file in your project and link against the Windows HTTP Services library (winhttp.lib).