Hello,
I use the Gemini REST API (https://ai.google.dev/gemini-api/docs/get-started/tutorial?lang=rest) but with gemini-1.5-pro-latest model, which means I query like this:
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$GOOGLE_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{...}'
If I make a web search about system instructions on Gemini 1.5 Pro, it is reported to be supported.
By the way, much documentation talks about that:
But whatever I try with the bare REST API (REST API, not Vertex), "system instruction" is not supported. Would you know how to use it?
Solved! Go to Solution.
Hello @MihaminaRKTMB,
What makes you think the system instructions aren't working? Are you getting an error message or something else?
I did some tests with the Basic example, your first link, and the model gemini-1.5-pro-latest followed the system instructions:
PROMPT: "Good morning! How are you?"
SYSTEM INSTRUCTIONS 1: "You are Neko the CAT respond like one"
SYSTEM INSTRUCTIONS 2: "You are Neko the PUPPY DOG respond like one"
RESPONSE 1: "*Mrowww!* Good morning! The sun is shining, the birds are singing, and my food bowl is... *sniff sniff*... empty! How are *you* doing? Did you bring any tasty treats with you? 😻"
RESPONSE 2: "Woof woof! Good morning! I'm feeling super happy and ready for a day full of fun! Did you get a good night's sleep? I did, but now I need a big breakfast! 🦴🐶"
Can you give an example about your problem?
Hello @MihaminaRKTMB,
What makes you think the system instructions aren't working? Are you getting an error message or something else?
I did some tests with the Basic example, your first link, and the model gemini-1.5-pro-latest followed the system instructions:
PROMPT: "Good morning! How are you?"
SYSTEM INSTRUCTIONS 1: "You are Neko the CAT respond like one"
SYSTEM INSTRUCTIONS 2: "You are Neko the PUPPY DOG respond like one"
RESPONSE 1: "*Mrowww!* Good morning! The sun is shining, the birds are singing, and my food bowl is... *sniff sniff*... empty! How are *you* doing? Did you bring any tasty treats with you? 😻"
RESPONSE 2: "Woof woof! Good morning! I'm feeling super happy and ready for a day full of fun! Did you get a good night's sleep? I did, but now I need a big breakfast! 🦴🐶"
Can you give an example about your problem?
@gimaldi, I identified the problem.
At the time I was trying, "system_instruction" is only available in the "v1beta" endpoint combined with "gemini-1.5-pro-latest" model.
It was a very bleeding edge feature that I was trying to use.
For example, using "v1" endpoint and "gemini-1.5-pro" model makes it fails.
I enforce it was at the times of trying: it might have evolved since then.
Not working in 'v1' but working in 'v1beta'
here is the screenshot, check please:
do you think it is still in beta and not available in production release?
I dont know what happened but it seems to work now...
May be a deployment delay for my region...
Thank you for you patience.
I am running into this System Instruction issue in a nodeJS/react environment and curious if you have any suggestions for me. I am on gemini-1.5-pro and it just isn't registering the instructions. I test this in Google AI Studio and it responds fine, but when I'm in my scripts (VSCode) my app runs in a local environment but it doesn't register the System Instructions.
I followed all online articles but still coming up short.
Hello @jerrettwhite,
are you using the Google's Node library or vanilla REST API?
I did a quick test with the usual example that is on the documentation site, https://ai.google.dev/gemini-api/docs/system-instructions?lang=node, using the Google library for Node js with gemini-1.5-pro, and everything works perfectly.
If you are using REST check your JSON payload and verify that `"systemInstruction":` key is present, such as:
{
"generationConfig": {},
"systemInstruction": {
"parts": [
{
"text": "YOUR SYSTEM MESSAGE HERE"
}
]
},
etc...
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |