feat(ai): add GLM Interactions API prototype - #16637
Conversation
Add support for the Gemini Interactions API alongside the existing Generate Content API in GeminiLanguageModel. * Extract shared data models (`JSONValue` and `GoogleCloudAPIError`) into `GeminiSharedDataModels`. * Add `InteractionsDataModels` containing Swift types generated from the Gemini Interactions OpenAPI specification. * Implement Interactions URL routing and SSE streaming in `GeminiAPIClient`. * Introduce `GeminiLanguageModel.APIVariant` to toggle between Generate Content and Interactions API backends. * Implement transcript and request translators for the Interactions API and branch executor execution accordingly. * Parameterize all integration tests across supported backends and API variants, gracefully cancelling Interactions tests for Firebase AI Logic until proxy support is available.
Synchronize the root Package.swift with the target configuration from GeminiLanguageModel/Package.swift to support the new Interactions API. * Add `GeminiSharedDataModels` and `InteractionsDataModels` targets. * Update `GeminiLanguageModel`, `GeminiAPIClient`, and `GeminiAPIDataModels` target dependencies to include the shared and interactions data model targets. * Add missing dependency on `GeminiAPIClient` and exclude `README.md` in `GeminiTestUtilities`. * Exclude `README.md` and `IntegrationTests/README.md` in `GeminiLanguageModelTests`.
Add the `gfm` CLI sample tool along with package trait support for direct Gemini Developer API authentication via environment variables. * Add `gfm` CLI tool in `GeminiLanguageModel/Samples/gfm` supporting content generation, streaming, multi-turn chat, model availability evaluations, and JSON schema inspection. * Add `GeminiDeveloperAPIEnvironmentAuth` package trait to conditionally expose standalone `GeminiLanguageModel` initialization. * Implement environment API key resolution in `GeminiLanguageModel`, preferring `GOOGLE_API_KEY` over `GEMINI_API_KEY`. * Add `GeminiLanguageModel.Error.missingAPIKey` when required credentials are not found in the environment. * Expose standard `EndpointConfiguration.geminiDeveloperAPI` static endpoint property. * Add unit test coverage for trait-gated initializers and key resolution precedence without mutating process environment state.
Add support for selecting the Gemini Interactions API variant from the CLI in the `gfm` utility, and enable building and testing for iOS 27 Simulator environments. * Add `--api-variant` and `--api` options to `respond`, `chat`, and `available` commands in `gfm`. * Define `APIVariantChoice` in `GFMCore` conforming to `ExpressibleByArgument` to cleanly parse API variants without retroactive conformance warnings. * Forward configured API variants through `ModelResolver` to `GeminiLanguageModel`. * Expose public `apiVariant` property on `GeminiLanguageModel`. * Add `.iOS(.v18)` to `gfm/Package.swift` and update `main.swift` and `SessionManager` to build cleanly for iOS Simulator. * Add unit tests for argument parsing, command defaults, and model variant configuration. * Update `gfm` documentation with Xcode iOS Simulator execution steps.
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Added prototype Interactions API support to
GeminiLanguageModeland added agfmCLI sample tool for manual testing and experimentation.GeminiSharedDataModelsand addedInteractionsDataModelsgenerated from the Gemini Interactions OpenAPI spec./interactions) and SSE streaming toGeminiAPIClient.GeminiLanguageModel.APIVariant(.generateContentand.interactions) and implemented bidirectional translation between Foundation Models transcripts and Interactions requests.gfmCLI Sample ToolGeminiLanguageModel/Samples/gfmsupporting single prompts (respond), interactive multi-turn chat (chat), model availability checks (available), and schema inspection (schema object).--api-variant(alias--api) to select betweengenerate-contentandinteractions.~/.fm/sessions/.gfmCLI Overview & Usage GuideOverview
gfmis a command-line utility modeled after Apple'sfm(Foundation Models) CLI. It provides an interface to test prompt generation, multi-turn streaming chat, model availability, and structured JSON schemas using Google Gemini (GeminiLanguageModel) and Apple System models (SystemLanguageModel).Requirements & Setup
SystemLanguageModel), or iOS 27.0+ SimulatorQuickstart
Commands
gfm available: Evaluates model availability on the system (-m gemini,-m system).gfm respond: Single prompt response with real-time streaming:gfm chat: Interactive multi-turn chat session with session persistence:/help,/clear,/sessions,/exit.gfm schema object: Previews and validates structured JSON schema definitions.Running on iOS 27 Simulator via Xcode
For testing on machines running macOS 26:
GeminiLanguageModel/Samples/gfm/Package.swiftin Xcode.gfmexecutable scheme and choose an iOS 27 Simulator destination (e.g.iPhone 17 Pro).⌘<):respond "Hello"orchat).GOOGLE_API_KEYwith your API key value.⌘Rto run and view streaming output in Xcode's console.#no-changelog