RelayVano

← All postcards

Testing Gemini from the Berlin Backend Queue

Model atlas EN

A Berlin queue, one direct Gemini request

The backend team in Berlin has a small job to finish before its afternoon deploy: send a prompt to Gemini and inspect the response without adding an SDK or changing the application. A single curl request is enough to see the moving parts.

Gemini’s native API accepts HTTP requests. You provide a model-specific endpoint, a JSON request body, and an API key in the x-goog-api-key header. The header is the credential: it tells the service which key to use for authentication and billing. The prompt belongs in the request body, not in the header.

Build the curl request

For a text-generation request, the endpoint uses the model’s generateContent method. Replace GEMINI_API_KEY with a key you obtained through the provider’s supported setup, and choose a model available to your account.

curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-pro:generateContent" -H "Content-Type: application/json" -H "x-goog-api-key: GEMINI_API_KEY" -d '{"contents":[{"parts":[{"text":"Summarize the purpose of an HTTP health check in two sentences."}]}]}'

The method is POST because the request sends data for the model to process. Content-Type says that data is JSON. The x-goog-api-key header supplies authentication, and the JSON body places the prompt inside contents, then parts, then text. The model name is part of the URL, so changing models means changing that path.

Read the response before changing the prompt

A successful response is JSON. Generated text is commonly returned under candidates, with content and parts nested inside. If curl prints a large response on one line, piping it through a JSON formatter can make it easier to inspect. Avoid assuming the response is plain text only: metadata and safety information may appear alongside the generated content.

If the request fails, check the HTTP status and response body first. An authentication error usually points to a missing, invalid, or unauthorized key. A model or endpoint error can mean the model name is unavailable to your account or the endpoint path is incorrect. A malformed-request response is a cue to validate the JSON and required fields.

Keep the API key out of shell history

Putting a real key directly in a command is convenient for a quick test, but it may remain in shell history or be visible in process listings. For repeatable local work, load it from an environment variable and reference that variable in the header. Do not commit keys to a repository, paste them into issue trackers, or include them in client-side code. Rotate a key if it has been exposed.

For example, a shell can read the key from an environment variable named GEMINI_API_KEY, and curl can send its value as the header. Keep the variable scoped to your local environment, and use your team’s secrets manager for deployed workloads. The exact secret-storage setup depends on where the request runs.

Use a relay when one endpoint is not the whole workflow

A direct Gemini request is useful for learning the native API and checking a model in isolation. An application that switches among providers may instead need one billing balance and a consistent endpoint. RelayVano is a pay-as-you-go relay for models including Gemini 3.1 Pro and Claude Sonnet 5.5, and its API base is https://api.relayvano.com. It also works with Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs, which can reduce provider-specific setup across a development workflow.

If that fits your project, sign up for RelayVano and check the current API documentation before wiring it into an application. Keep credentials in environment variables or a secrets manager whichever endpoint you call, and make a small test request before putting model calls on a production path.

More postcards from this route