모델에 대한 각 호출에서 모델 구성을 함께 전송하여 모델의 대답 생성 방식을 제어할 수 있습니다. 각 모델은 서로 다른 구성 옵션을 제공합니다.
Google AI Studio를 사용하여 프롬프트와 모델 구성을 실험할 수도 있습니다.Gemini 구성 옵션으로 이동 Imagen 구성 옵션으로 이동
Gemini 모델 구성
| Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. | 
이 섹션에서는 Gemini 모델과 함께 사용할 구성을 설정하는 방법을 보여주고 각 매개변수에 관한 설명을 제공합니다.
모델 구성 (Gemini) 설정
일반적인 사용 사례를 위한 구성
구성은 인스턴스의 수명 동안 유지됩니다. 다른 구성을 사용하려면 해당 구성으로 새 GenerativeModel 인스턴스를 만드세요.
Swift
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
import FirebaseAI
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
let config = GenerationConfig(
  candidateCount: 1,
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
  maxOutputTokens: 200,
  stopSequences: ["red"]
)
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `GenerativeModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
  modelName: "GEMINI_MODEL_NAME",
  generationConfig: config
)
// ...
Kotlin
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
val config = generationConfig {
    candidateCount = 1
    maxOutputTokens = 200
    stopSequences = listOf("red")
    temperature = 0.9f
    topK = 16
    topP = 0.1f
}
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = "GEMINI_MODEL_NAME",
    generationConfig = config
)
// ...
Java
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.candidateCount = 1;
configBuilder.maxOutputTokens = 200;
configBuilder.stopSequences = List.of("red");
configBuilder.temperature = 0.9f;
configBuilder.topK = 16;
configBuilder.topP = 0.1f;
GenerationConfig config = configBuilder.build();
// Specify the config as part of creating the `GenerativeModel` instance
GenerativeModelFutures model = GenerativeModelFutures.from(
        FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .generativeModel(
                    "GEMINI_MODEL_NAME",
                    config
                );
);
// ...
Web
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
const generationConfig = {
  candidate_count: 1,
  maxOutputTokens: 200,
  stopSequences: ["red"],
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
};
// Specify the config as part of creating the `GenerativeModel` instance
const model = getGenerativeModel(ai, { model: "GEMINI_MODEL_NAME",  generationConfig });
// ...
Dart
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
final generationConfig = GenerationConfig(
  candidateCount: 1,
  maxOutputTokens: 200,
  stopSequences: ["red"],
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `GenerativeModel` instance
final model = FirebaseAI.googleAI().generativeModel(
  model: 'GEMINI_MODEL_NAME',
  config: generationConfig,
);
// ...
Unity
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
var generationConfig = new GenerationConfig(
  candidateCount: 1,
  maxOutputTokens: 200,
  stopSequences: new string[] { "red" },
  temperature: 0.9f,
  topK: 16,
  topP: 0.1f
);
// Specify the config as part of creating the `GenerativeModel` instance
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
var model = ai.GetGenerativeModel(
  modelName: "GEMINI_MODEL_NAME",
  generationConfig: generationConfig
);
이 페이지의 다음 섹션에서 각 매개변수에 대한 설명을 확인할 수 있습니다.
Gemini Live API 구성
구성은 인스턴스의 수명 동안 유지됩니다. 다른 구성을 사용하려면 해당 구성으로 새 LiveModel 인스턴스를 만드세요.
Swift
LiveGenerativeModel 인스턴스를 초기화하는 동안 liveGenerationConfig에서 매개변수 값을 설정합니다.
import FirebaseAI
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
let config = LiveGenerationConfig(
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
  maxOutputTokens: 200,
  responseModalities: [.audio],
  speech: SpeechConfig(voiceName: "Fenrir"),
)
// Initialize the Vertex AI Gemini API backend service
// Specify the config as part of creating the `LiveGenerativeModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
  modelName: "GEMINI_MODEL_NAME",
  generationConfig: config
)
// ...
Kotlin
LiveModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
val config = liveGenerationConfig {
    maxOutputTokens = 200
    responseModality = ResponseModality.AUDIO
    speechConfig = SpeechConfig(voice = Voices.FENRIR)
    temperature = 0.9f
    topK = 16
    topP = 0.1f
}
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `LiveModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
    modelName = "GEMINI_MODEL_NAME",
    generationConfig = config
)
// ...
Java
LiveModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
LiveGenerationConfig.Builder configBuilder = new LiveGenerationConfig.Builder();
configBuilder.setMaxOutputTokens(200);
configBuilder.setResponseModalities(ResponseModality.AUDIO);
configBuilder.setSpeechConfig(new SpeechConfig(Voices.FENRIR));
configBuilder.setTemperature(0.9f);
configBuilder.setTopK(16);
configBuilder.setTopP(0.1f);
LiveGenerationConfig config = configBuilder.build();
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `LiveModel` instance
LiveModelFutures model = LiveModelFutures.from(
        FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .generativeModel(
                    "GEMINI_MODEL_NAME",
                    config
                );
);
// ...
Web
LiveGenerativeModel 인스턴스를 초기화하는 동안 LiveGenerationConfig에서 매개변수 값을 설정합니다.
// ...
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
const generationConfig = {
  maxOutputTokens: 200,
  responseModalities: [ResponseModality.AUDIO],
  speechConfig: {
    voiceConfig: {
      prebuiltVoiceConfig: { voiceName: "Fenrir" },
    },
  },
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
};
// Specify the config as part of creating the `LiveGenerativeModel` instance
const model = getLiveGenerativeModel(ai, {
  model: "GEMINI_MODEL_NAME",
  generationConfig,
});
// ...
Dart
LiveModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
final generationConfig = LiveGenerationConfig(
  maxOutputTokens: 200,
  responseModalities: [ResponseModalities.audio],
  speechConfig: SpeechConfig(voiceName: 'Fenrir'),
  temperature: 0.9,
  topP: 0.1,
  topK: 16,
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `LiveModel` instance
final model = FirebaseAI.googleAI().liveGenerativeModel(
  model: 'GEMINI_MODEL_NAME',
  config: generationConfig,
);
// ...
Unity
LiveModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here)
var liveGenerationConfig = new LiveGenerationConfig(
  maxOutputTokens: 200,
  responseModalities: new [] { ResponseModality.Audio },
  speechConfig: SpeechConfig.UsePrebuiltVoice("Fenrir"),
  temperature: 0.9f,
  topK: 16,
  topP: 0.1f
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `LiveModel` instance
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
var model = ai.GetLiveModel(
  modelName: "GEMINI_MODEL_NAME",
  liveGenerationConfig: liveGenerationConfig
);
이 페이지의 다음 섹션에서 각 매개변수에 대한 설명을 확인할 수 있습니다.
매개변수 설명 (Gemini)
다음은 사용 가능한 매개변수의 대략적인 개요입니다(해당하는 경우). Gemini Developer API 문서에서 매개변수와 값의 전체 목록을 확인할 수 있습니다.
| 매개변수 | 설명 | 기본값 | 
|---|---|---|
| 오디오 타임스탬프 audioTimestamp | 오디오 전용 입력 파일의 타임스탬프 이해를 사용 설정하는 불리언입니다. 
 | false | 
| 후보자 수 candidateCount | 반환할 응답 변형의 개수를 지정합니다. 각 요청에 대해 모든 후보의 출력 토큰이 청구되지만 입력 토큰은 한 번만 청구됩니다. 지원되는 값:  
 | 1 | 
| 빈도 페널티 frequencyPenalty | 생성된 대답에 반복적으로 표시되는 토큰을 포함할 확률을 제어합니다. 양수 값은 생성된 콘텐츠에 반복적으로 표시되는 토큰에 페널티를 적용하여 콘텐츠가 반복될 가능성을 줄입니다. | --- | 
| 최대 출력 토큰 maxOutputTokens | 대답에서 생성될 수 있는 최대 토큰 수를 지정합니다. | --- | 
| 상태 페널티 presencePenalty | 생성된 대답에 이미 표시된 토큰을 포함할 확률을 제어합니다. 양수 값은 생성된 콘텐츠에 이미 표시된 토큰에 페널티를 적용하여 다양한 콘텐츠가 생성될 가능성을 높입니다. | --- | 
| 중지 시퀀스 stopSequences | 문자열 중 하나가 응답에서 발견되면 모델에 콘텐츠 생성을 중지하도록 지시하는 문자열 목록을 지정합니다. 
 | --- | 
| 온도 temperature | 대답의 무작위성을 제어합니다. 온도가 낮을수록 더 결정적인 대답이 나오고, 온도가 높을수록 더 다양하거나 창의적인 대답이 나옵니다. | 모델에 따라 다름 | 
| Top-K topK | 생성된 콘텐츠에 사용되는 확률이 가장 높은 단어의 수를 제한합니다. Top-K 값이 1이면 다음으로 선택된 토큰이 모델의 어휘에 포함된 모든 토큰 중에서 가장 확률이 높다는 의미입니다. 반면에 Top-K 값이n이면 다음 토큰이 가장 확률이 높은 n개 토큰 중에서 선택된다는 의미입니다(모두 설정된 온도에 기반함). | 모델에 따라 다름 | 
| Top-P topP | 생성된 콘텐츠의 다양성을 제어합니다. 토큰은 확률의 합이 Top-P 값과 같아질 때까지 확률이 가장 높은 것부터 (위의 Top-K 참조) 가장 낮은 것까지 선택됩니다. | 모델에 따라 다름 | 
| 대답 모달리티 responseModality | Gemini 모델에서 Live API 또는 네이티브 멀티모달 출력을 사용할 때 스트리밍된 출력의 유형(예: 텍스트, 오디오, 이미지)을 지정합니다. Live API 및  | --- | 
| 음성 speechConfig | Live API를 사용할 때 스트리밍된 오디오 출력에 사용되는 음성을 지정합니다. Live API 및  | Puck | 
Imagen 모델 구성
| Imagen API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. | 
이 섹션에서는 Imagen 모델과 함께 사용할 구성을 설정하는 방법을 보여주고 각 매개변수에 관한 설명을 제공합니다.
모델 구성 (Imagen) 설정
구성은 인스턴스의 수명 동안 유지됩니다. 다른 구성을 사용하려면 해당 구성으로 새 ImagenModel 인스턴스를 만드세요.
Swift
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
import FirebaseAI
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
let config = ImagenGenerationConfig(
  negativePrompt: "frogs",
  numberOfImages: 2,
  aspectRatio: .landscape16x9,
  imageFormat: .jpeg(compressionQuality: 100),
  addWatermark: false
)
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `ImagenModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).imagenModel(
  modelName: "IMAGEN_MODEL_NAME",
  generationConfig: config
)
// ...
Kotlin
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
val config = ImagenGenerationConfig {
    negativePrompt = "frogs",
    numberOfImages = 2,
    aspectRatio = ImagenAspectRatio.LANDSCAPE_16x9,
    imageFormat = ImagenImageFormat.jpeg(compressionQuality = 100),
    addWatermark = false
}
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
    modelName = "IMAGEN_MODEL_NAME",
    generationConfig = config
)
// ...
Java
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
ImagenGenerationConfig config = new ImagenGenerationConfig.Builder()
    .setNegativePrompt("frogs")
    .setNumberOfImages(2)
    .setAspectRatio(ImagenAspectRatio.LANDSCAPE_16x9)
    .setImageFormat(ImagenImageFormat.jpeg(100))
    .setAddWatermark(false)
    .build();
// Specify the config as part of creating the `ImagenModel` instance
ImagenModelFutures model = ImagenModelFutures.from(
        FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .imagenModel(
                    "IMAGEN_MODEL_NAME",
                    config
                );
);
// ...
Web
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
const generationConfig = {
  negativePrompt: "frogs",
  numberOfImages: 2,
  aspectRatio: ImagenAspectRatio.LANDSCAPE_16x9,
  imageFormat: ImagenImageFormat.jpeg(100),
  addWatermark: false
};
// Specify the config as part of creating the `ImagenModel` instance
const model = getImagenModel(ai, { model: "IMAGEN_MODEL_NAME", generationConfig });
// ...
Dart
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
final generationConfig = ImagenGenerationConfig(
  negativePrompt: 'frogs',
  numberOfImages: 2,
  aspectRatio: ImagenAspectRatio.landscape16x9,
  imageFormat: ImagenImageFormat.jpeg(compressionQuality: 100)
  addWatermark: false
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `ImagenModel` instance
final model = FirebaseAI.googleAI().imagenModel(
  model: 'IMAGEN_MODEL_NAME',
  config: generationConfig,
);
// ...
Unity
ImagenModel 인스턴스를 만드는 과정에서 ImagenGenerationConfig의 매개변수 값을 설정합니다.
using Firebase.AI;
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
var config = new ImagenGenerationConfig(
  numberOfImages: 2,
  aspectRatio: ImagenAspectRatio.Landscape16x9,
  imageFormat: ImagenImageFormat.Jpeg(100)
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `ImagenModel` instance
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetImagenModel(
  modelName: "imagen-4.0-generate-001",
  generationConfig: config
);
// ...
이 페이지의 다음 섹션에서 각 매개변수에 대한 설명을 확인할 수 있습니다.
매개변수 설명 (Imagen)
다음은 사용 가능한 매개변수의 대략적인 개요입니다(해당하는 경우). Google Cloud 문서에서 매개변수와 값의 전체 목록을 확인할 수 있습니다.
| 매개변수 | 설명 | 기본값 | 
|---|---|---|
| 부정 프롬프트 negativePrompt | 생성된 이미지에서 생략할 항목에 대한 설명 이 매개변수는 아직  | --- | 
| 결과 수 numberOfImages | 요청별로 반환되는 생성된 이미지 수 | 기본값은 이미지 1개입니다. | 
| 가로세로 비율 aspectRatio | 생성된 이미지의 너비 대 높이 비율 | 기본값은 정사각형 (1:1)입니다. | 
| 이미지 형식 imageFormat | 생성된 이미지의 이미지 형식 (MIME 유형) 및 압축 수준과 같은 출력 옵션 | 기본 MIME 유형은 PNG입니다. 기본 압축은 75입니다 (MIME 유형이 JPEG로 설정된 경우). | 
| 워터마크 addWatermark | 생성된 이미지에 표시되지 않는 디지털 워터마크 (SynthID라고 함)를 추가할지 여부 | 기본값은 true입니다. | 
| 인물 생성 personGeneration | 모델에서 사람을 생성할 수 있는지 여부 | 기본값은 모델에 따라 다름 | 
| 안전 속성 포함 includeSafetyAttributes | 필터링되지 않은 입력 및 출력에 대한 응답에서 안전 속성 목록에 대해 반올림된 책임감 있는 AI 점수를 사용 설정할지 여부입니다. 안전 속성 카테고리:
           | 기본값은 false입니다. | 
seed 매개변수) 지정
    storageUri 매개변수)
    enhancePrompt 매개변수)을 사용 중지
    콘텐츠 생성을 제어하는 기타 옵션
- 프롬프트 디자인에 대해 자세히 알아보세요. 모델이 내 요구사항에 맞는 출력을 생성하도록 영향을 줄 수 있습니다.
- 안전 설정을 사용하여 증오심 표현, 성적인 콘텐츠 등 유해하다고 간주될 수 있는 대답을 받을 가능성을 조정합니다.
- 시스템 요청 사항을 설정하여 모델의 동작을 조정합니다. 이 기능은 모델이 최종 사용자의 추가 안내에 노출되기 전에 추가하는 서문과 같습니다.
- 프롬프트와 함께 응답 스키마를 전달하여 특정 출력 스키마를 지정합니다. 이 기능은 JSON 출력을 생성할 때 가장 일반적으로 사용되지만 분류 작업(예: 모델이 특정 라벨이나 태그를 사용하도록 하려는 경우)에도 사용할 수 있습니다.