Your First Minimal LLM API Call (curl-Style)
Explore how to perform your first minimal LLM API call using a curl-style HTTP request. Understand key elements like authorization headers, JSON body formatting, and extracting model output from response metadata. Gain skills in debugging and validating API calls to build reliable AI workflows that handle responses and errors predictably.
We'll cover the following...
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.
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.
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 ...