Firebase AI Logic 및 클라이언트 SDK는 이전에는 "Vertex AI in Firebase"라고 불렸습니다. 확장된 서비스와 기능(예: 이제 Gemini Developer API을(를) 지원함)을 더 잘 반영하기 위해 서비스의 이름을 Firebase AI Logic으로 변경하고 재패키징했습니다.
이제 모바일 또는 웹 앱에서 Google의 생성형 AI 모델에 안전하게 액세스하기 위해 "Gemini API" 제공업체(오랫동안 제공된 Vertex AI Gemini API 또는 이제 Gemini Developer API)를 선택할 수 있습니다. 즉, 이제 합리적인 비율 제한 및 할당량으로 무료 등급을 제공하는 Gemini Developer API을 사용할 수 있습니다.
Firebase AI Logic SDK로 이전하는 단계 개요
1단계: 앱 및 사용 사례에 가장 적합한 "Gemini API" 제공업체를 선택합니다.
2단계: Gemini Developer API를 사용할 수 있도록 Firebase 프로젝트를 설정합니다.
Vertex AI Gemini API 대신 Gemini Developer API를 사용하도록 전환하는 경우에만 적용됩니다.Gemini Developer APIVertex AI Gemini API3단계: 앱에서 사용되는 라이브러리를 업데이트합니다.
4단계: 앱에서 초기화를 업데이트합니다.
5단계: 사용하는 기능에 따라 코드를 업데이트합니다.
1단계: 앱에 가장 적합한 "Gemini API" 제공업체 선택
이전을 통해 "Gemini API" 제공업체를 선택할 수 있습니다.
이전 "Vertex AI in Firebase" SDK는 Vertex AI Gemini API만 사용할 수 있었습니다.
새 Firebase AI Logic SDK를 사용하면 모바일 또는 웹 앱에서 직접 호출할 "Gemini API" 프로바이더(Gemini Developer API 또는 Vertex AI Gemini API)를 선택할 수 있습니다.
지원되는 기능, 가격 책정, 비율 제한 측면에서 두 Gemini API 제공업체 사용 간의 차이점을 검토하세요. 예를 들어 Gemini Developer API는 Cloud Storage URL을 사용하여 파일을 제공하는 것을 지원하지 않지만 무료 등급과 합리적인 할당량을 활용하려는 경우 좋은 선택이 될 수 있습니다.
Vertex AI Gemini API를 계속 사용하려면Vertex AI Gemini API:
다음 단계를 건너뛰고 앱에서 라이브러리를 업데이트한 후, 이 가이드의 나머지 부분을 진행하세요.Gemini Developer API**Gemini Developer API로 전환하려면**
다음 단계로 이동하여 해당 API를 사용하도록 Firebase 프로젝트를 설정한 후 이 가이드의 나머지 부분을 진행하세요.
2단계: Gemini Developer API를 사용할 수 있도록 Firebase 프로젝트 설정
이 단계는 Gemini Developer API와 함께 Firebase AI Logic 클라이언트 SDK를 사용하도록 전환하려는 경우에만 필요합니다. 하지만 을 계속 사용하려면 다음 단계로 건너뛰세요.Vertex AI Gemini API
프로젝트에서 두 'Gemini API' 제공업체를 동시에 사용 설정해도 됩니다.
Firebase 콘솔에서 AI 서비스 > AI 로직으로 이동합니다.
설정 탭으로 이동하여 Gemini Developer API 를 선택합니다.
Gemini Developer API을 사용 설정합니다.
Console은 필요한 API가 사용 설정되어 있는지 확인하고 Firebase 프로젝트에서 Gemini API 키를 생성합니다.
이 Gemini API 키를 앱의 코드베이스에 추가하지 마세요. 자세히 알아보기이 이전 가이드에서 계속 진행하여 앱에서 라이브러리 및 초기화를 업데이트합니다.
3단계: 앱에서 사용되는 라이브러리 업데이트
앱의 코드베이스를 업데이트하여 Firebase AI Logic 라이브러리를 사용합니다.
Swift
앱 프로젝트를 연 상태로 Xcode에서 다음 옵션 중 하나를 사용하여 Firebase 패키지를 v11.13.0 이상으로 업데이트합니다.
옵션 1: 모든 패키지 업데이트: 파일 > 패키지 > 최신 패키지 버전으로 업데이트로 이동합니다.
옵션 2: Firebase 개별 업데이트: 패키지 종속 항목 섹션에서 Firebase 패키지로 이동합니다. Firebase 패키지를 마우스 오른쪽 버튼으로 클릭한 다음 패키지 업데이트 를 선택합니다.
이제 Firebase 패키지에 v11.13.0 이상이 표시되는지 확인합니다. 표시되지 않으면 지정된 패키지 요구사항이 v11.13.0 이상으로 업데이트할 수 있도록 허용하는지 확인합니다.
프로젝트 편집기에서 앱의 타겟을 선택한 다음 프레임워크, 라이브러리, 삽입된 콘텐츠 섹션으로 이동합니다.
새 라이브러리 추가: + 버튼을 선택한 다음 Firebase 패키지에서 FirebaseAI 를 추가합니다.
앱 이전을 완료한 후 (이 가이드의 나머지 섹션 참고) 이전 라이브러리를 삭제해야 합니다. FirebaseVertexAI를 선택한 다음 — 버튼을 누릅니다.
Kotlin
모듈 (앱 수준) Gradle 파일 (일반적으로
<project>/<app-module>/build.gradle.kts또는<project>/<app-module>/build.gradle)에서 이전 종속 항목 (해당하는 경우)을 다음으로 바꿉니다.이전 종속 항목을 삭제하기 전에 앱의 코드베이스를 이전하는 것이 더 쉬울 수 있습니다 (이 가이드의 나머지 섹션 참고).
// BEFORE dependencies { implementation(platform("com.google.firebase:firebase-bom:33.x.y"))
implementation("com.google.firebase:firebase-vertexai")// OR if not using the BoMimplementation("com.google.firebase:firebase-vertexai:16.x.y")} // AFTER dependencies { // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:firebase-bom:34.14.0")) // Add the dependency for the Firebase AI Logic library // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-ai") }Android 프로젝트를 Gradle 파일과 동기화합니다.
Firebase Android BoM을(를) 사용하지 않기로 선택한 경우
firebase-ai 라이브러리의 종속 항목을 추가하고 Android 스튜디오에서 제안하는 최신 버전을 수락하면 됩니다.
Java
모듈 (앱 수준) Gradle 파일 (일반적으로
<project>/<app-module>/build.gradle.kts또는<project>/<app-module>/build.gradle)에서 이전 종속 항목 (해당하는 경우)을 다음으로 바꿉니다.이전 종속 항목을 삭제하기 전에 앱의 코드베이스를 이전하는 것이 더 쉬울 수 있습니다 (이 가이드의 나머지 섹션 참고).
// BEFORE dependencies { implementation(platform("com.google.firebase:firebase-bom:33.x.y"))
implementation("com.google.firebase:firebase-vertexai")// OR if not using the BoMimplementation("com.google.firebase:firebase-vertexai:16.x.y")} // AFTER dependencies { // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:firebase-bom:34.14.0")) // Add the dependency for the Firebase AI Logic library // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-ai") }Android 프로젝트를 Gradle 파일과 동기화합니다.
Firebase Android BoM을(를) 사용하지 않기로 선택한 경우
firebase-ai 라이브러리의 종속 항목을 추가하고 Android 스튜디오에서 제안하는 최신 버전을 수락하면 됩니다.
Web
npm을 사용하여 웹용 Firebase JS SDK의 최신 버전을 가져옵니다.
npm i firebase@latest
또는
yarn add firebase@latest
라이브러리를 가져온 위치에서 가져오기 문을 업데이트하여 대신
firebase/ai를 사용합니다.이전 가져오기를 삭제하기 전에 앱의 코드베이스를 이전하는 것이 더 쉬울 수 있습니다 (이 가이드의 나머지 섹션 참고).
// BEFORE import { initializeApp } from "firebase/app";
import { getVertexAI, getGenerativeModel } from "firebase/vertexai";// AFTER import { initializeApp } from "firebase/app"; import { getAI, getGenerativeModel } from "firebase/ai";
Dart
Flutter 프로젝트 디렉터리에서 다음 명령어를 실행하여
pubspec.yaml파일에서firebase_ai패키지를 사용하도록 업데이트합니다.flutter pub add firebase_ai
Flutter 프로젝트를 다시 빌드합니다.
flutter run
앱 이전을 완료한 후 (이 가이드의 나머지 섹션 참고) 이전 패키지를 삭제해야 합니다.
flutter pub remove firebase_vertexai
Unity
' "Vertex AI in Firebase"'에서는 Unity 지원이 제공되지 않았습니다.
Unity용 SDK를 시작하는 방법을 알아보세요.Firebase AI Logic
4단계: 앱에서 초기화 업데이트
|
Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠 및 코드를 확인합니다. |
선택한 API 제공업체의 서비스를 초기화하고 GenerativeModel 인스턴스를 만드는 방법을 업데이트합니다.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(modelName: "gemini-3.5-flash")
Kotlin
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel("gemini-3.5-flash")
Java
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel("gemini-3.5-flash");
// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, { model: "gemini-3.5-flash" });
Dart
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
FirebaseAI.googleAI().generativeModel(model: 'gemini-3.5-flash');
Unity
'Vertex AI in Firebase'에서는 Unity 지원이 제공되지 않았습니다.
Unity용 SDK를 시작하는 방법을 알아보세요.Firebase AI Logic
**사용 중인 기능에 따라 항상
인스턴스를 만들지 않을 수도 있습니다**.GenerativeModel 입력 및 출력을 스트리밍하려면 Gemini Live API를 사용하여
LiveModel 인스턴스를 만듭니다.
5단계: 사용하는 기능에 따라 코드 업데이트
이 단계에서는 사용하는 기능에 따라 필요할 수 있는 변경사항을 설명합니다.
Cloud Storage URL을 사용하고 이 이전에서 Gemini Developer API을(를) 사용하도록 전환한 경우 멀티모달 요청을 업데이트하여 파일을 인라인 데이터로 포함하거나 동영상에 YouTube URL을 사용해야 합니다.
SDK를 사용하기 위해 코드에서 변경해야 할 사항이 있는지 다음 목록을 검토하세요.Firebase AI Logic
Swift
추가 변경사항이 없습니다.
Kotlin
Live API
- enum 클래스
ResponseModality의UNSPECIFIED값을 삭제했습니다. 대신null을 사용하세요.
- enum 클래스
Java
Live API
- enum 클래스
ResponseModality의UNSPECIFIED값을 삭제했습니다. 대신null을 사용하세요.
- enum 클래스
이제 다양한 Java 빌더 메서드가 void 대신 클래스의 인스턴스를 올바르게 반환하도록 변경되었습니다.
Web
Gemini Developer API 대신 Vertex AI Gemini API를 사용하기 시작하는 경우에만 변경이 필요합니다.
안전 설정
- 지원되지 않는
SafetySetting.method의 사용을 삭제했습니다.
- 지원되지 않는
인라인 데이터
- 지원되지 않는
InlineDataPart.videoMetadata의 사용을 삭제했습니다.
- 지원되지 않는
Dart
추가 변경사항이 없습니다.
Unity
'Vertex AI in Firebase'에서는 Unity 지원이 제공되지 않았습니다.
Unity용 SDK를 시작하는 방법을 알아보세요.Firebase AI Logic
의견 보내기 Firebase AI Logic 사용 경험에 관해