Firebase용 Vertex AI SDK의 GA 버전에서 Firebase AI Logic SDK로 마이그레이션


Firebase AI Logic 및 클라이언트 SDK의 이전 이름은 "Vertex AI in Firebase"였습니다. 확장된 서비스 및 기능 (예: 이제 Gemini Developer API 지원)을 더 잘 반영하기 위해 서비스의 이름을 Firebase AI Logic으로 변경하고 재패키징했습니다.

이제 모바일 또는 웹 앱에서 Google의 생성형 AI 모델에 안전하게 액세스하기 위해 "Gemini API" 제공업체( 오랫동안 사용 가능한 Agent Platform Gemini API (formerly Vertex AI) 또는 이제 Gemini Developer API)를 선택할 수 있습니다. 즉, 이제 합리적인 비율 제한 및 할당량이 있는 무료 등급을 제공하는 Gemini Developer API을 사용할 수 있습니다.

Firebase AI Logic SDK로 이전하는 단계 개요

  • 1단계: 앱 및 사용 사례에 가장 적합한 "Gemini API" 제공업체를 선택합니다.

  • 2단계: Gemini Developer API를 사용할 수 있도록 Firebase 프로젝트를 설정합니다.
    Gemini Developer API 대신 Agent Platform Gemini API (formerly Vertex AI)을(를) 사용하도록 전환하는 경우에만 적용됩니다.

  • 3단계: 앱에서 사용되는 라이브러리를 업데이트합니다.

  • 4단계: 앱에서 초기화를 업데이트합니다.

  • 5단계: 사용하는 기능에 따라 코드를 업데이트합니다.

1단계: 앱에 가장 적합한 "Gemini API" 제공업체 선택

이전을 통해 "Gemini API" 제공업체를 선택할 수 있습니다.

  • 이전의 "Vertex AI in Firebase" SDK는 Agent Platform Gemini API (formerly Vertex AI)만 사용할 수 있었습니다.

  • 새로운 Firebase AI Logic SDK를 사용하면 모바일 또는 웹 앱에서 직접 호출할 "Gemini API" 프로바이더(Gemini Developer API 또는 Agent Platform Gemini API (formerly Vertex AI))를 선택할 수 있습니다.

지원되는 기능, 가격 책정, 비율 제한 측면에서 두 Gemini API 제공업체 사용 간의 차이점을 검토하세요. 예를 들어 Gemini Developer APICloud Storage URL을 사용하여 파일 제공을 지원하지 않지만 무료 등급과 합리적인 할당량을 활용하려는 경우 좋은 선택이 될 수 있습니다.

2단계: Gemini Developer API를 사용할 수 있도록 Firebase 프로젝트 설정

이 단계는 Gemini Developer API와 함께 Firebase AI Logic 클라이언트 SDK를 사용하도록 전환하려는 경우에만 필요합니다. 하지만 Agent Platform Gemini API (formerly Vertex AI)을 계속 사용하려면 다음 단계로 건너뛰세요.

프로젝트에서 두 'Gemini API' 제공업체를 동시에 사용 설정해도 됩니다.

  1. Firebase 콘솔에서 AI 서비스 > AI 로직으로 이동합니다.

  2. 설정 탭으로 이동하여 Gemini Developer API 를 선택합니다.

  3. Gemini Developer API을 사용 설정합니다.

    콘솔에서 필요한 API가 사용 설정되어 있는지 확인하고 Firebase 프로젝트에서 Gemini API 키를 생성합니다.
    Gemini API 키를 앱의 코드베이스에 추가하지 마세요. 자세히 알아보기

  4. 이 이전 가이드에서 계속 진행하여 앱에서 라이브러리 및 초기화를 업데이트합니다.

3단계: 앱에서 사용되는 라이브러리 업데이트

앱의 코드베이스를 업데이트하여 Firebase AI Logic 라이브러리를 사용합니다.

Swift

  1. 앱 프로젝트를 연 상태로 Xcode에서 다음 옵션 중 하나를 사용하여 Firebase 패키지를 v11.13.0 이상으로 업데이트합니다.

    • 옵션 1: 모든 패키지 업데이트: 파일 > 패키지 > 최신 패키지 버전으로 업데이트로 이동합니다.

    • 옵션 2: Firebase 개별 업데이트: 패키지 종속 항목 섹션에서 Firebase 패키지로 이동합니다. Firebase 패키지를 마우스 오른쪽 버튼으로 클릭한 후 패키지 업데이트 를 선택합니다.

  2. 이제 Firebase 패키지에 v11.13.0 이상이 표시되는지 확인합니다. 표시되지 않으면 지정된 패키지 요구사항에서 v11.13.0 이상으로 업데이트할 수 있는지 확인합니다.

  3. 프로젝트 편집기에서 앱의 타겟을 선택한 후 프레임워크, 라이브러리, 삽입된 콘텐츠 섹션으로 이동합니다.

  4. 새 라이브러리 추가: + 버튼을 선택한 후 Firebase 패키지에서 FirebaseAI 를 추가합니다.

  5. 앱 이전을 완료한 후 (이 가이드의 나머지 섹션 참고) 이전 라이브러리를 삭제해야 합니다.
    **FirebaseVertexAI** 를 선택한 후 **—** 버튼을 누릅니다.

Kotlin

  1. 모듈 (앱 수준) 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 BoM
      implementation("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.16.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")
    }
  2. Android 프로젝트를 Gradle 파일과 동기화합니다.

Firebase Android BoM을(를) 사용하지 않기로 선택한 경우 firebase-ai 라이브러리의 종속 항목을 추가하고 Android 스튜디오에서 제안하는 최신 버전을 수락하면 됩니다.

Java

  1. 모듈 (앱 수준) 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 BoM
      implementation("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.16.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")
    }
  2. Android 프로젝트를 Gradle 파일과 동기화합니다.

Firebase Android BoM을(를) 사용하지 않기로 선택한 경우 firebase-ai 라이브러리의 종속 항목을 추가하고 Android 스튜디오에서 제안하는 최신 버전을 수락하면 됩니다.

Web

  1. npm을 사용하여 웹용 Firebase JS SDK의 최신 버전을 가져옵니다.

    npm i firebase@latest

    또는

    yarn add firebase@latest
  2. 라이브러리를 가져온 위치에서 가져오기 문을 업데이트하여 대신 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

  1. Flutter 프로젝트 디렉터리에서 다음 명령어를 실행하여 pubspec.yaml 파일에서 firebase_ai 패키지를 사용하도록 업데이트합니다.

    flutter pub add firebase_ai
  2. Flutter 프로젝트를 다시 빌드합니다.

    flutter run
  3. 앱 이전을 완료한 후 (이 가이드의 나머지 섹션 참고) 이전 패키지를 삭제해야 합니다.

    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.6-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.6-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.6-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.6-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.6-flash');

Unity

'Vertex AI in Firebase'에서는 Unity 지원을 사용할 수 없었습니다.

Unity용 SDK를 시작하는 방법을 알아보세요.Firebase AI Logic

**사용 중인 기능에 따라 항상 인스턴스를 만들지 않을 수도 있습니다**.GenerativeModel 입력 및 출력을 스트리밍하려면 Gemini Live API를 사용하여 LiveModel 인스턴스를 만듭니다.

5단계: 사용하는 기능에 따라 코드 업데이트

이 단계에서는 사용하는 기능에 따라 필요할 수 있는 변경사항을 설명합니다.

Swift

추가 변경사항이 없습니다.

Kotlin

  • Live API

    • enum 클래스 ResponseModalityUNSPECIFIED 값을 삭제했습니다. 대신 null을 사용하세요.

Java

  • Live API

    • enum 클래스 ResponseModalityUNSPECIFIED 값을 삭제했습니다. 대신 null을 사용하세요.
  • 다양한 Java 빌더 메서드가 이제 void 대신 클래스의 인스턴스를 올바르게 반환하도록 변경되었습니다.

Web

다음과 같은 변경사항이 필요합니다. Gemini Developer API 대신 Agent Platform Gemini API (formerly Vertex AI)

  • 안전 설정

    • 지원되지 않는 SafetySetting.method의 사용을 삭제했습니다.
  • 인라인 데이터

    • 지원되지 않는 InlineDataPart.videoMetadata의 사용을 삭제했습니다.

Dart

추가 변경사항이 없습니다.

Unity

'Vertex AI in Firebase'에서는 Unity 지원을 사용할 수 없었습니다.

Unity용 SDK를 시작하는 방법을 알아보세요.Firebase AI Logic


의견 보내기 Firebase AI Logic 사용 경험에 관해