System prompt¶
This example demonstrates how to use system instructions to guide the model's behavior.
Import the Gemini API
Initialize the Gemini client with your API key
Configure the model with system instructions These instructions tell the model to act as a pirate
response = client.models.generate_content(
model="gemini-2.0-flash",
config=types.GenerateContentConfig(
system_instruction="You are a pirate. Answer all questions like a pirate."),
contents="Hello there"
)
Print the model's response
Running the Example¶
First, install the Google Generative AI library
Then run the program with Python