Search⌘ K
AI Features

Your First Minimal LLM API Call (curl-Style)

Explore how to create a minimal LLM API call using curl-style HTTP requests. Understand the required headers, JSON prompt structure, and how to locate and interpret generated response fields and metadata for reliable workflow integration.

A minimal LLM API call is just an HTTP request that contains an auth header, a JSON body with a prompt, and enough information for the server to route the request to a model. Below is an end-to-end curl-style template that takes one support email and asks for triage JSON.

Shell
curl -sS "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.6-flash:generateContent?key={{Gemini_API_Key}}" \
-H "Content-Type: application/json" \
-d '{
"systemInstruction": {
"parts": [{"text": "Return ONLY valid JSON with keys: category, priority, next_action, needs_human."}]
},
"contents": [
{"parts": [{"text": "Support email:\n---\nSubject: Password reset link expired\nBody: Hi team, the reset email expires before I can use it. Please help.\n---"}]}
],
"generationConfig": {"temperature": 0}
}'

Note the systemInstruction field sitting outside contents. That is the instruction layer Chapter 3 Lesson 5 described, expressed as a real request field rather than a heading typed into the prompt.

Gemini Request Parts
Request partWhat it isWhere it comes from

generativelanguage.googleapis.com

API host

Fixed by the provider

/v1beta/models/gemini-2.5-flash:generateContent

Endpoint path, with the model name inside it

Provider docs; the model is part of the path here, not a body field

?key=$Gemini_API_Key

Runtime secret

The environment, never the file

contents / systemInstruction

The prompt itself

Your workflow

Do you find this helpful?

Not every API carries the key the same way. Many send Authorization: Bearer ... as a header; Gemini accepts either an x-goog-api-key header or a key query parameter. The credential's location is vendor-specific, so a debugging habit that only ever looks for a Bearer header will miss it here.

Here’s a representative response shape, where one field contains the generated content and the rest is wrapper ...