How to hit the Google Gemini API

The Gemini API lives at https://generativelanguage.googleapis.com/v1beta. Google's quickstart now leads with the Interactions API; the older generateContent method is what most existing code uses. Both are below.

Authentication

Create a key in Google AI Studio and send it as the x-goog-api-key header. In the examples it's written {{GEMINI_API_KEY}}.

Full reference: https://ai.google.dev/gemini-api/docs

Generate text (Interactions API)

The quickstart's current form: a model and an input string.

curl https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: {{GEMINI_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-3.8-flash", "input": "Explain how HTTP caching works in a few words."}'
Run in PostTaco

Generate text (generateContent)

The model goes in the URL; the reply is in candidates[0].content.parts[0].text.

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent \
  -H "x-goog-api-key: {{GEMINI_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"parts": [{"text": "Write a haiku about REST APIs."}]}]}'
Run in PostTaco

Add a system instruction

system_instruction sits beside contents, not inside it.

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent \
  -H "x-goog-api-key: {{GEMINI_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "system_instruction": {"parts": [{"text": "Answer in one sentence."}]},
    "contents": [{"parts": [{"text": "What is a webhook?"}]}]
  }'
Run in PostTaco

List models

Every model your key can use, with token limits and supported methods.

curl https://generativelanguage.googleapis.com/v1beta/models \
  -H "x-goog-api-key: {{GEMINI_API_KEY}}"
Run in PostTaco