Client for Google Gemini API.
More...
#include <GeminiClient.hpp>
|
| | GeminiClient (const std::string &apiKey, const std::string &model="gemini-2.5-flash", const std::string &baseUrl="https://generativelanguage.googleapis.com") |
| |
| | ~GeminiClient () override |
| |
| std::string | SendPrompt (const std::string &prompt, std::function< void(const std::string &)> callback=nullptr) override |
| | Send a prompt to the AI and get a response.
|
| |
| bool | IsAvailable () const override |
| | Check if the AI service is available.
|
| |
| std::string | GetModelName () const override |
| | Get the name of the model being used.
|
| |
| void | SetModelName (const std::string &model) override |
| |
| virtual std::string | GetProviderName () const override |
| | Get the name of the AI provider.
|
| |
| std::string | GetServiceId () const override |
| | Unique identifier for this service instance.
|
| |
| std::string | GetServiceType () const override |
| | Type of service ("ai", "analyzer", "exporter", etc.)
|
| |
|
| std::string | SendHttpPost (const std::string &endpoint, const std::string &jsonBody) const |
| |
Client for Google Gemini API.
Supported models (latest):
- gemini-2.5-flash (recommended for free tier - fast, efficient, 1M context)
- gemini-2.5-flash-lite (fastest, most economical for high-frequency tasks)
- gemini-2.5-pro (advanced reasoning, excellent for coding)
- gemini-3-pro (most intelligent, best multimodal understanding)
Legacy models:
- gemini-1.5-flash, gemini-1.5-pro (still supported)
Free tier limits:
- 15 requests per minute
- 1500 requests per day
API: https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent Authentication: x-goog-api-key header Get API key: https://aistudio.google.com/app/apikey
◆ GeminiClient()
| ai::GeminiClient::GeminiClient |
( |
const std::string & |
apiKey, |
|
|
const std::string & |
model = "gemini-2.5-flash", |
|
|
const std::string & |
baseUrl = "https://generativelanguage.googleapis.com" |
|
) |
| |
|
explicit |
◆ ~GeminiClient()
| ai::GeminiClient::~GeminiClient |
( |
| ) |
|
|
inlineoverride |
◆ GetModelName()
| std::string ai::GeminiClient::GetModelName |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ GetProviderName()
| virtual std::string ai::GeminiClient::GetProviderName |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ GetServiceId()
| std::string ai::GeminiClient::GetServiceId |
( |
| ) |
const |
|
overridevirtual |
◆ GetServiceType()
| std::string ai::IAIService::GetServiceType |
( |
| ) |
const |
|
inlineoverridevirtualinherited |
◆ IsAvailable()
| bool ai::GeminiClient::IsAvailable |
( |
| ) |
const |
|
overridevirtual |
Check if the AI service is available.
- Returns
- true if service can be reached
Implements ai::IAIService.
◆ SendHttpPost()
| std::string ai::GeminiClient::SendHttpPost |
( |
const std::string & |
endpoint, |
|
|
const std::string & |
jsonBody |
|
) |
| const |
|
private |
◆ SendPrompt()
| std::string ai::GeminiClient::SendPrompt |
( |
const std::string & |
prompt, |
|
|
std::function< void(const std::string &)> |
callback = nullptr |
|
) |
| |
|
overridevirtual |
Send a prompt to the AI and get a response.
- Parameters
-
| prompt | The text prompt to send |
| callback | Function called with response chunks as they arrive |
- Returns
- Complete response text
Implements ai::IAIService.
◆ SetModelName()
| void ai::GeminiClient::SetModelName |
( |
const std::string & |
model | ) |
|
|
overridevirtual |
◆ m_apiKey
| std::string ai::GeminiClient::m_apiKey |
|
private |
◆ m_baseUrl
| std::string ai::GeminiClient::m_baseUrl |
|
private |
◆ m_model
| std::string ai::GeminiClient::m_model |
|
private |
The documentation for this class was generated from the following files: