Files
firebase-ios-sdk/FirebaseAI/Sources/Extensions/Public/FirebaseAI+GeminiLanguageModel.swift
T
Andrew Heard 27eaab3918 feat(ai): document and expose GeminiLanguageModel (#16631)
Remove the GEMINI_LANGUAGE_MODEL environment variable check in
Package.swift to unconditionally include GeminiLanguageModel targets
and dependencies on supported Swift 6.4+ toolchains.

Add DocC documentation comments for the GeminiLanguageModel integration
with Apple's Foundation Models framework.

Provide usage guidance, public preview warnings, and links to Apple's
LanguageModel protocol, LanguageModelSession, and DynamicProfile. In
addition, document FirebaseAI.geminiLanguageModel(name:) and include
a code example showing how to instantiate and use the model.
2026-09-09 15:57:01 -04:00

40 lines
1.8 KiB
Swift

// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if compiler(>=6.4) && canImport(FoundationModels) && canImport(GeminiLanguageModel)
import GeminiLanguageModel
public extension FirebaseAI {
/// **[Public Preview]** Creates a ``GeminiLanguageModel`` instance.
///
/// > Warning: This API is a public preview and may be subject to change.
///
/// The returned model conforms to Apple's
/// [`LanguageModel`](https://developer.apple.com/documentation/foundationmodels/languagemodel)
/// protocol and can be used with `LanguageModelSession` in Apple's Foundation Models
/// framework.
///
/// - Parameter name: The identifier of the Gemini model to use; see
/// [available model
/// names](https://firebase.google.com/docs/ai-logic/models#available-model-names)
/// for a list of supported model names.
/// - Returns: A ``GeminiLanguageModel`` configured for this `FirebaseAI` instance.
@available(iOS 27.0, macOS 27.0, watchOS 27.0, visionOS 27.0, *)
@available(tvOS, unavailable)
func geminiLanguageModel(name: String) -> GeminiLanguageModel {
GeminiLanguageModel(name: name, firebaseAI: self)
}
}
#endif // compiler(>=6.4) && canImport(FoundationModels) && canImport(GeminiLanguageModel)