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:- Low Temperature (0.0-0.3)
- Medium Temperature (0.4-0.7)
- High Temperature (0.8-2.0)
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
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 tokenstop_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
Configuration Presets
Common configuration patterns:- Factual Q&A
- Creative Writing
- Code Generation
- Summarization
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_tokensto prevent excessively long responses - Use system instructions to establish consistent behavior
- Combine
top_pandtop_kfor fine-grained control - Test different configurations to find optimal settings
- Use stop sequences to control output format
- Document your configuration choices for reproducibility