How can i turn off safty for my Gemini Api

how can i turn off safty for my Gemini Api
in the ai studio i can turn it off but when i connect i cannot

Welcome to the forum!

You don’t specify what language you’re using, but check out the documentation about safety settings to get information and code samples for your library.

@MTGameMaker , To disable safety features for the Gemini API, you can set the ‘threshold’ parameter to ‘BLOCK_NONE’. Here’s an example of how to do:

from google.generativeai.types import HarmCategory, HarmBlockThreshold

model = genai.GenerativeModel(model_name=‘gemini-1.5-flash’)
response = model.generate_content(
[‘Do these look store-bought or homemade?’, img],
safety_settings={
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
}
)

1 Like