How to Call Gemini 2.0 Flash with Google Search via HTTPS in Apple Shortcuts?

I’m trying to use Gemini 2.0 Flash with Google Search in Apple Shortcuts by making HTTPS requests (CURL or similar). The idea is to integrate Gemini’s search capabilities directly into Shortcuts so I can trigger a query on the go.

However, after checking the API documentation, I couldn’t find a clear example of how to make this work with a simple HTTPS request. Specifically, I’m looking for guidance on:

• How to properly call Gemini 2.0 Flash with Google Search using CURL or any HTTPS method in Apple Shortcuts?

• Are there any required headers, query parameters, or authentication steps needed to enable Google Search?

• Any official documentation or example requests that can help with this setup?

If anyone has experience or insights on this, I’d really appreciate your help! Thanks in advance. :blush:

Hi @milkmilk

The documentation is here Grounding with Google Search  |  Gemini API  |  Google AI for Developers
Unfortunately, the REST example seems to have an issue.

To enable Google Search you add it as a tool to the API call.

Nonetheless, here’s the JSON payload (-d value) I generate with the Gemini SDK for .NET

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key={{apiKey}}
Content-Type: application/json

{
  "model" : "models/gemini-2.0-flash-exp",
  "contents" : [ {
    "role" : "user",
    "parts" : [ {
      "text" : "When is the next total solar eclipse in Mauritius?"
    } ]
  } ],
  "tools" : [ {
    "googleSearch" : { }
  } ]
}

You can add the API key either as query string parameter (as above) or in the HTTP header (recommended): x-goog-api-key: {{apiKey}}

The response gives you GroundingMetadata to use.

Hope this helps you with the cURL statement.

Cheers

PS: I reported the missing REST call via Feedback in the documentation page.

1 Like

Your HTTP call statement is perfect, thank you for your great help!! Thanks again!!

1 Like