Skip to main content
The behavior and output of Gemini models can be customized through various configuration parameters. This guide covers the most important settings.

System Instructions

System instructions set the context and behavior for the model throughout the conversation:
System instructions are like a primer that influences all subsequent responses. They persist throughout the conversation.

Complex System Instructions

You can provide detailed behavioral instructions:

Temperature

Controls randomness in the output. Lower values make the model more deterministic:
More deterministic and focused:
Use for:
  • Factual questions
  • Code generation
  • Structured data extraction
  • Consistent outputs

Max Output Tokens

Limits the length of the generated response:

Token Length Guidelines

Different models have different maximum token limits. Check the model documentation for specific limits.

Combining Configuration Parameters

All parameters work together to shape the output:

Top-p (Nucleus Sampling)

Controls diversity by considering tokens with cumulative probability:
  • top_p=1.0: Consider all tokens (default)
  • top_p=0.9: Consider only top 90% probability tokens
  • top_p=0.5: More focused, less diverse

Top-k Sampling

Limits the number of tokens considered:

Stop Sequences

Define sequences where generation should stop:

Configuration with Chat

System instructions and config apply to entire chat sessions:

Model-Specific Parameters

Check capabilities and defaults for each model:
  • Gemini 2.5 Flash: Fast, efficient, good for most tasks
  • Gemini 2.5 Pro: Advanced reasoning, complex tasks
See the Vertex AI docs and Gemini API docs for model-specific parameters.

Configuration Presets

Common configuration patterns:

Use Cases

Chatbots

System instructions for personality, temperature for variety

Code Generation

Low temperature, specific system instructions

Content Creation

High temperature, flexible max_output_tokens

Data Extraction

Low temperature, stop sequences, structured output

Best Practices

  • Start with default settings and adjust based on output quality
  • Use low temperature (0.0-0.3) for factual, consistent outputs
  • Use high temperature (0.7-1.0) for creative, varied outputs
  • Set max_output_tokens to prevent excessively long responses
  • Use system instructions to establish consistent behavior
  • Combine top_p and top_k for fine-grained control
  • Test different configurations to find optimal settings
  • Use stop sequences to control output format
  • Document your configuration choices for reproducibility