Skip to content

Conversation

Copy link

Copilot AI commented Nov 20, 2025

Adds support for Google Gemini models via the official Gemini API (https://ai.google.dev/api).

Changes

Core Implementation

  • Added ApiType.gemini and Provider.gemini enum cases
  • Created geminiChat.swift with Gemini-specific message types:
    • GeminiMessage, GeminiUserMessage, GeminiModelMessage
    • GeminiPart supporting text, inline data, function calls/responses
    • GeminiTool for function declarations
  • Created GeminiClient actor with streaming support using endpoint format: /v1beta/models/{model}:streamGenerateContent?key={apiKey}
  • Updated Message enum to support both OpenAI and Gemini messages

Tests

  • GeminiClientTests: Streaming, cancellation, function calling
  • ParseGeminiMessageTests: Message parsing/serialization
  • geminiChatController: Vapor-based mock server

Usage Example

let client = GeminiClient(
    baseURL: URL(string: "https://generativelanguage.googleapis.com")!,
    apiKey: apiKey
)

let stream = await client.generateStreamResponse(
    systemText: "You are a helpful assistant.",
    message: GeminiUserMessage(text: "Hello"),
    model: OpenAICompatibleModel(id: "gemini-pro"),
    tools: [/* GeminiTool objects */]
)

for try await message in stream.stream {
    // Handle streaming responses
}

Pattern follows existing OpenAI implementation for consistency.

Original prompt

add gemini model support: https://ai.google.dev/api


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

Copilot AI and others added 4 commits November 20, 2025 03:40
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Co-authored-by: sirily11 <32106111+sirily11@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Gemini model support for AI integration Add Google Gemini API support Nov 20, 2025
Copilot AI requested a review from sirily11 November 20, 2025 03:47
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