모델을 호출할 때마다 모델 구성과 함께 전송하여 모델의 대답 생성 방식을 제어할 수 있습니다. 각 모델은 maxOutputTokens 설정 또는 사고, 응답 형식, 이미지, 음성, 음성 활동 감지 (VAD)를 위한 특수 구성과 같은 다양한 구성 옵션을 지원합니다.
Gemini 모델에 액세스할 때 대부분의 사용 사례에서 GenerationConfig를 사용하여 모델을 구성합니다. 하지만 Gemini Live API 모델을 구성하는 경우 LiveGenerationConfig를 사용합니다.
이 페이지에서는 Gemini 모델의 구성을 설정하는 방법을 보여주고 사용 가능한 매개변수 표를 제공합니다.
Gemini 구성으로 이동 Gemini Live API 구성으로 이동
Gemini 모델의 GenerationConfig
|
Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. |
범용 모델, 이미지 생성 (Nano Banana) 모델, 텍스트 음성 변환 (TTS) 모델을 포함한 대부분의 Gemini 생성 모델에 GenerationConfig를 설정합니다.
구성은 GenerativeModel 인스턴스의 전체 기간 동안 유지됩니다. 다른 구성을 사용하려면 다른 구성으로 새 인스턴스를 만들고 사용합니다.
다음 예시에서는 매우 기본적인 모델 구성을 보여줍니다. 추가 옵션 (특히 특수 모델의 경우)은 이 페이지 뒷부분에 있는 사용 가능한 파라미터 표를 참조하세요.
Swift
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
import FirebaseAILogic
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
let config = GenerationConfig(
maxOutputTokens: 200,
stopSequences: ["red"]
)
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
// Specify the config as part of creating the `GenerativeModel` instance.
let model = FirebaseAI.firebaseAI(backend: .agentPlatform()).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.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
val config = generationConfig {
maxOutputTokens = 200
stopSequences = listOf("red")
}
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
// Specify the config as part of creating the `GenerativeModel` instance.
val model = Firebase.ai(backend = GenerativeBackend.agentPlatform()).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.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.maxOutputTokens = 200;
configBuilder.stopSequences = List.of("red");
GenerationConfig config = configBuilder.build();
// Specify the config as part of creating the `GenerativeModel` instance.
GenerativeModelFutures model = GenerativeModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.agentPlatform())
.generativeModel(
"GEMINI_MODEL_NAME",
config
);
);
// ...
Web
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 파라미터 값을 설정합니다.
// ...
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
const ai = getAI(firebaseApp, { backend: new AgentPlatformBackend() });
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
const generationConfig = {
maxOutputTokens: 200,
stopSequences: ["red"],
};
// 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.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
final generationConfig = GenerationConfig(
maxOutputTokens: 200,
stopSequences: ["red"],
);
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
// Specify the config as part of creating the `GenerativeModel` instance.
final model = FirebaseAI.agentPlatform().generativeModel(
model: 'GEMINI_MODEL_NAME',
generationConfig: generationConfig,
);
// ...
Unity
GenerativeModel 인스턴스를 만드는 과정에서 GenerationConfig의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
var generationConfig = new GenerationConfig(
maxOutputTokens: 200,
stopSequences: new string[] { "red" }
);
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
// Specify the config as part of creating the `GenerativeModel` instance.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.AgentPlatform());
var model = ai.GetGenerativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
);
Gemini Live API 모델의 LiveGenerationConfig
|
Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. |
Gemini Live API 모델을 사용하는 경우에만 LiveGenerationConfig를 설정합니다.
구성은 LiveModel 인스턴스의 전체 기간 동안 유지됩니다. 다른 구성을 사용하려면 다른 구성으로 새 인스턴스를 만들고 사용합니다.
다음 예시에서는 매우 기본적인 모델 구성을 보여줍니다. 음성 활동 감지(VAD) 구성과 같은 추가 옵션은 이 페이지 뒷부분에 있는 사용 가능한 파라미터 표를 참조하세요.
Swift
LiveModel 인스턴스를 초기화하는 동안 liveGenerationConfig에서 파라미터 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
let config = LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: [.audio],
speech: SpeechConfig(voiceName: "Fenrir"),
)
// Specify the config as part of creating the `liveModel` instance.
let liveModel = FirebaseAI.firebaseAI(backend: .agentPlatform(location: "us-central1")).liveModel(
modelName: "GEMINI_LIVE_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 = Voice("FENRIR"))
}
// Specify the config as part of creating the `LiveModel` instance.
val liveModel = Firebase.ai(backend = GenerativeBackend.agentPlatform(location = "us-central1")).liveModel(
modelName = "GEMINI_LIVE_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.setResponseModality(ResponseModality.AUDIO);
configBuilder.setSpeechConfig(new SpeechConfig(new Voice("FENRIR")));
LiveGenerationConfig config = configBuilder.build();
// Specify the config as part of creating the `LiveModel` instance.
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.agentPlatform("us-central1")).liveModel(
"GEMINI_LIVE_MODEL_NAME",
config
);
// ...
Web
LiveGenerativeModel 인스턴스를 초기화하는 동안 LiveGenerationConfig에서 파라미터 값을 설정합니다.
// ...
// Initialize the Agent Platform Gemini API backend service (formerly Vertex AI).
const ai = getAI(firebaseApp, { backend: new AgentPlatformBackend("us-central1") });
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
const liveGenerationConfig = {
maxOutputTokens: 200,
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: {
prebuiltVoiceConfig: { voiceName: "Fenrir" },
},
},
};
// Specify the config as part of creating the `LiveGenerativeModel` instance.
const liveModel = getLiveGenerativeModel(ai, {
model: "GEMINI_LIVE_MODEL_NAME",
liveGenerationConfig,
});
// ...
Dart
LiveGenerativeModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 파라미터 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
final config = LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'Fenrir'),
);
// Specify the config as part of creating the `liveGenerativeModel` instance.
final liveModel = FirebaseAI.agentPlatform(location: 'us-central1').liveGenerativeModel(
model: 'GEMINI_LIVE_MODEL_NAME',
liveGenerationConfig: config,
);
// ...
Unity
LiveModel 인스턴스를 만드는 과정에서 LiveGenerationConfig의 파라미터 값을 설정합니다.
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
var config = new LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: new[] { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("Fenrir")
);
// Specify the config as part of creating the `LiveModel` instance.
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.AgentPlatform(location: "us-central1")).GetLiveModel(
modelName: "GEMINI_LIVE_MODEL_NAME",
liveGenerationConfig: config
);
// ...
사용 가능한 모델 파라미터
다음 표는 모델 구성에 사용할 수 있는 매개변수를 간략하게 보여줍니다. 일부 파라미터는 특정 모델에만 적용됩니다.
| 매개변수 | 설명 | 제한사항 | 기본값 |
|---|---|---|---|
오디오 타임스탬프audioTimestamp
|
오디오 전용 입력 파일의 타임스탬프 이해를 사용 설정합니다. |
불리언
|
false
|
최대 출력 토큰maxOutputTokens
|
응답에서 생성될 수 있는 토큰의 최대 개수를 지정합니다.
|
--- | --- |
중지 시퀀스stopSequences
|
문자열 중 하나가 응답에서 발견되면 모델에 콘텐츠 생성을 중지하도록 지시하는 문자열 목록을 지정합니다. |
Nano Banana 또는 TTS 모델에는 적용되지 않습니다. |
--- |
| 특수 구성 | |||
생각 중thinkingConfig
|
모델이 대답을 생성할 때 '사고 과정'을 제어합니다.
|
지원되는 값: 사고 문서를 참고하세요. TTS 모델에는 적용되지 않습니다.
Firebase AI Logic는 Live API 모델에 대해 |
모델에 따라 다름 |
응답 형식responseModalities
|
출력 유형 (예: 텍스트, 오디오, 이미지)을 지정합니다. | Nano Banana, TTS, Live API 모델을 사용하는 경우에만 적용되며 필수입니다. | --- |
이미지 특성imageConfig
|
생성된 이미지의 가로세로 비율과 해상도를 지정합니다. |
지원되는 값: 이미지 생성 구성 참조 Nano Banana 모델을 사용하는 경우에만 적용됩니다. |
가로세로 비율 1:1 (정사각형) 해상도 1024x1024 |
음성speechConfig
|
오디오 출력에 사용되는 음성을 지정합니다. |
TTS 모델 및 Live API 모델을 사용하는 경우에만 적용됩니다. TTS 모델에 필요합니다. |
Puck
|
음성 활동 감지 (VAD)realtimeInputConfig
|
음성 활동 감지 (VAD), 중단 처리, 차례 컨텍스트 범위를 구성하거나 자동 VAD를 사용 중지합니다. |
지원되는 값: VAD 구성 참조 Live API 모델을 사용하는 경우에만 적용됩니다. |
VAD 사용 설정됨 개별 설정의 기본값을 참조하세요. |
콘텐츠 생성을 제어하는 다른 옵션
- 프롬프트 설계에 대해 자세히 알아보고 모델이 필요에 맞는 출력을 생성하도록 영향을 줄 수 있습니다.
- 안전 설정을 사용하여 증오심 표현, 음란물 등 유해한 것으로 간주될 수 있는 대답을 받을 가능성을 조정합니다.
- 시스템 요청 사항을 설정하여 모델의 동작을 조정합니다. 이 기능은 모델이 최종 사용자의 추가 안내에 노출되기 전에 추가하는 서문과 같습니다.
- 프롬프트와 함께 응답 스키마를 전달하여 특정 출력 스키마를 지정합니다. 이 기능은 JSON 출력을 생성할 때 흔히 사용되지만, 모델이 특정 라벨이나 태그를 사용하도록 하려는 경우와 같은 분류 작업에도 사용할 수 있습니다.