Skip to content

Replace OpenAI integration with Google Gemini API#1

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/replace-openai-with-gemini-api
Draft

Replace OpenAI integration with Google Gemini API#1
Copilot wants to merge 2 commits into
mainfrom
copilot/replace-openai-with-gemini-api

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 14, 2025

Migrates from OpenAI to Google Gemini API for SQL generation, enabling free tier usage while maintaining interface compatibility.

Changes

  • New GuzzleGeminiClient - Implements OpenAIClientInterface with Gemini API endpoint (https://generativelanguage.googleapis.com/v1beta/). Converts OpenAI message format to Gemini's contents/parts structure and uses responseMimeType: application/json for structured responses.

  • Config updates - PromptSQLConfig properties: openAiApiKeygeminiApiKey, openAiModelgeminiModel. Default model changed to gemini-1.5-flash.

  • Documentation - Updated README with Gemini references, environment variables, and code examples.

Migration

// Before
$config = new PromptSQLConfig(
    openAiApiKey: getenv('OPENAI_API_KEY'),
    openAiModel: 'gpt-4o-mini',
    // ...
);
$client = new GuzzleOpenAIClient($config->openAiApiKey);

// After
$config = new PromptSQLConfig(
    geminiApiKey: getenv('GEMINI_API_KEY'),
    geminiModel: 'gemini-1.5-flash',
    // ...
);
$client = new GuzzleGeminiClient($config->geminiApiKey);

The existing OpenAIBasedSqlGenerator works unchanged via the interface. GuzzleOpenAIClient remains available for backward compatibility.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Ite0WM /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Replace OpenAI integration with Google Gemini API to use the free tier. Create a new GuzzleGeminiClient that implements OpenAIClientInterface, allowing the same generator to work with Gemini's API. Also update the configuration to use Gemini API key instead of OpenAI key, and update documentation to reflect the change.

This pull request was created as a result of the following prompt from Copilot chat.

Replace OpenAI integration with Google Gemini API to use the free tier. Create a new GuzzleGeminiClient that implements OpenAIClientInterface, allowing the same generator to work with Gemini's API. Also update the configuration to use Gemini API key instead of OpenAI key, and update documentation to reflect the change.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jona-odoh <78029472+jona-odoh@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace OpenAI integration with Google Gemini API Replace OpenAI integration with Google Gemini API Nov 14, 2025
Copilot AI requested a review from jona-odoh November 14, 2025 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants