Gemini 1.5 pro latest REST API and system instructions

Hello I use the Gemini REST API 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, “system instruction” is not supported. Would you know how to use it?

Welcome to the forum. There is a handy cookbook that shows how to form the system instruction from REST: cookbook/quickstarts/rest/System_instructions_REST.ipynb at main · google-gemini/cookbook · GitHub

Hope that helps!

1 Like

Welcome to the forum!

The example on the page you linked to shows how a System Instruction can be used.

If you’re having problems, showing us exactly the code you’re using and exactly the error you’re getting that makes you think it isn’t supported can help us help you.

I tried again this morning and it worked.
I dont understand why it did not work a few days sooner.
May be prosressive deployment…
Anyway, it is solved and this works:

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=${GEMINI_API_KEY} \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{"system_instruction":{"parts":{"text":"Act as a BASH script developer."}},"contents":[{"parts":[{"text":"Write a script that will print the current date"}]}]}'

Thank you for you patience.