https://www.boundaryml.com logo
How to set system instructions in Gemini?
# help
c
I can see there's a way to pass
systemInstruction
to the
/generateContent
endpoint but it seems to be an object. Tried something but not sure if this is the way. Can anyone help? https://cdn.discordapp.com/attachments/1403144284642742413/1403144284957446164/Screenshot_2025-08-08_at_4.02.59_AM.png?ex=68967b72&is=689529f2&hm=2858923c13a11751bdd4549bd664f9396aae99b4c3efee71d67ed73134609fc1&
v
heya!
you can acutally just do it via the prompt!
Copy code
function Foo() -> returntype {
  client "GeminiPro"
  prompt #"
     {{ _.role('system')
     <system stuff>
     {{ _.role('user') }}
     ...
  "#
}
the thing you are doing will also work!
c
Ahh yes, that's what I was wondering. It should work, but I couldn't see any changes in the preview, so wasn't sure.
v
the reason you need this is because in gemini, you can't send only a
system
message, but in openai you can. So the default role for a message in gemini is
user
. so:
Copy code
function Foo() -> returntype {
  client "GeminiPro"
  prompt #"
     ...
  "#
}
is really the same as:
Copy code
function Foo() -> returntype {
  client "GeminiPro"
  prompt #"
     {{ _.role('user') }}
     ...
  "#
}
when using gemini
when using openai, the default role is
system
you can also modify the default role:
Copy code
client<llm> MyClient {
  options {
     default_role "system"
  }
}
which may help
c
Right, understood. This makes sense.
Thank you so much!
v