System Instructions

Quick Question is there system instructions in gemini api and how can i use it

On Gemini’s Playground there is a section labeled System Instructions above the chat function:


You can find documentation here: Usar instruções do sistema para orientar o comportamento de um modelo  |  Google AI for Developers  |  Google for Developers
And some examples in the Cookbook:

1 Like

Hi,I checked out that the system instruction part is explicitly mentioned in the python code but not in the javascript code. Can you please confirm if adding system instructions to javascript code is identical to that of python or there is a difference?
Thanks

Thanks, didn’t even know about cookbook what i needed is rest api

{
“error”: {
“code”: 400,
“message”: “Developer instruction is not enabled for models/gemini-pro”,
“status”: “INVALID_ARGUMENT”
}
}

@MoonLord System instructions is not supported for Gemini 1.0 Pro.
You can replace gemini-pro with gemini-1.5-pro-latest to use the 1.5 Pro model.

@Aayman_Khalid take a look here for system instructions with JS: generative-ai-js/docs/reference/main/generative-ai.generativemodel.md at main · google-gemini/generative-ai-js · GitHub

1 Like

@Aayman_Khalid I’ve got sample code here that may help: JSON Results with Google Gemini Generative AI API Calls

i was using something like that
model: “models/gemini-1.5-pro-latest”
systemInstruction: {
parts: {
text: “instructions”
}
}
and also i tried every possible model

Problem solved actually it was because in my request uri was “https://generativelanguage.googleapis.com/v1beta/models/gemini-pro”
i changed it to gemini-1.5-pro-latest
And it worked

1 Like