LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ai::GeminiClient Class Reference

Client for Google Gemini API. More...

#include <GeminiClient.hpp>

Inheritance diagram for ai::GeminiClient:
Inheritance graph
Collaboration diagram for ai::GeminiClient:
Collaboration graph

Public Member Functions

 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.)
 

Private Member Functions

std::string SendHttpPost (const std::string &endpoint, const std::string &jsonBody) const
 

Private Attributes

std::string m_apiKey
 
std::string m_model
 
std::string m_baseUrl
 

Detailed Description

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

Constructor & Destructor Documentation

◆ 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

Member Function Documentation

◆ GetModelName()

std::string ai::GeminiClient::GetModelName ( ) const
inlineoverridevirtual

Get the name of the model being used.

Implements ai::IAIService.

◆ GetProviderName()

virtual std::string ai::GeminiClient::GetProviderName ( ) const
inlineoverridevirtual

Get the name of the AI provider.

Implements ai::IAIService.

◆ GetServiceId()

std::string ai::GeminiClient::GetServiceId ( ) const
overridevirtual

Unique identifier for this service instance.

Implements services::IService.

◆ GetServiceType()

std::string ai::IAIService::GetServiceType ( ) const
inlineoverridevirtualinherited

Type of service ("ai", "analyzer", "exporter", etc.)

Implements services::IService.

◆ 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
promptThe text prompt to send
callbackFunction called with response chunks as they arrive
Returns
Complete response text

Implements ai::IAIService.

Here is the call graph for this function:

◆ SetModelName()

void ai::GeminiClient::SetModelName ( const std::string &  model)
overridevirtual

Implements ai::IAIService.

Member Data Documentation

◆ 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: