Trying to Sell Gemini API to client failing... Different results between AI Studio and API

We are assisting a client who analyses lots of 2 hour recordings of staff and then evaluates them. When the client does it with AI Studio, het gets great results. Exactly what he wants. When we use the API to programmatically do the same, with the same prompts etc, we get different results. Client is ready to cancel the whole project.

We are sending the same parameters and instructions to Gemini. Same model etc.

    $generateData = [
      'contents' => [
        [
          'parts' => [
            ['text' => $analysisPrompt],
            ['file_data' => ['mime_type' => $files_mime_type, 'file_uri' => $files_uri]]
          ]
        ]
      ],
      'generationConfig' => [
        'temperature'      => $temperature,
        'maxOutputTokens'  => $max_tokens
      ]
    ];

Is there anything we are missing? Must we add topP and topK?

Hi @andrebruton,

While using AI Studio, please check which model and version is being used and what are the parameters shown towards the right side of screen (Temperature, grounding, Top K, etc). Make sure all the parameters and model version is configured appropriately while trying the programmatic approach.

This should help resolve the issue.

Happy coding :slight_smile:

They are exactly the same. We even added the Media Resolution key, but turns out it gives an error when analysing audio.

Does AI Studio use topP AND topK together? It seems like the consensus is to use one or the other??