Gemini Requests Work Best With Clearly Separated Fields
A Gemini request separates conversation from operating instructions
A Gemini generateContent request is easier to understand as several containers with different jobs. One holds the conversation. Others supply standing instructions, generation preferences, safety settings, or available tools. Keeping these responsibilities separate makes requests easier to read and problems easier to diagnose.
The model is selected through the API method’s model parameter, represented in the request address for direct REST calls. It is not another conversational message. Field availability can vary by model and API version, so a familiar field name does not guarantee that every model supports it.
The contents field carries the actual conversation
contents is the central request field. It contains an ordered list of conversation entries. For a first request, one entry containing the user’s question is usually enough. For a continuing conversation, include the relevant earlier turns because an ordinary generateContent call does not automatically recover your application’s chat history.
Each entry has a role and parts. The usual conversation roles are user and model. The model role identifies earlier assistant output; it does not select the model. Preserving the conversation’s order helps Gemini distinguish the current question from previous answers.
Parts carry text and supported media together
parts is a list because one turn can contain several pieces of content. A user might supply a written question alongside an image. The text field holds ordinary language, while inlineData carries supported binary content encoded for transport, together with its media type.
fileData references supported externally stored content rather than embedding its bytes. Accepted locations and media formats depend on the API and model. A local filename alone does not upload a file. For newcomers, the useful distinction is simple: contents groups conversation turns, while parts groups the material inside each turn.
System instructions guide behavior without replacing user messages
systemInstruction supplies higher-level guidance, such as the assistant’s purpose, preferred tone, or response boundaries. It uses a content-shaped object, but the supported instruction content is text. Keep the immediate task in contents rather than hiding every instruction in a single crowded prompt.
Clear instructions improve consistency, but they are not a security boundary. Your application must still validate sensitive actions, protect credentials, and treat user-provided material as untrusted input.
Generation settings shape output rather than supply facts
generationConfig groups response controls. temperature adjusts sampling randomness, while topP and, where supported, topK provide other sampling controls. Start with defaults instead of changing every setting together.
maxOutputTokens limits generated output rather than input size. Token accounting can include thinking tokens on models that use them. stopSequences can end generation when specified text appears. Structured-output settings, including responseMimeType and supported schema fields, request a particular output format. They do not remove the need to validate the result.
Tools describe capabilities that applications must handle
tools makes supported capabilities available, including function declarations and certain built-in tools. A function declaration describes an operation and its expected arguments. It does not execute your application’s function.
toolConfig controls supported tool behavior, including function-calling choices. When Gemini returns a function call, your application typically validates the arguments, performs the authorized operation, and supplies a function response in a subsequent request. Built-in tools can follow different execution paths.
Safety controls and caching serve separate purposes
safetySettings configures supported harm-category thresholds. These settings affect filtering; they do not grant permission to bypass provider policies. Inspect the response for blocking information rather than assuming every successful HTTP request contains an answer.
cachedContent references previously created cached context. It is not a switch that automatically stores the current conversation. Check cache compatibility, lifetime, and pricing before designing around it.
Relay routing does not change these underlying distinctions
BestRelay publishes this guide as a quality-first API relay that forwards requests to the official model named, without substitution. Its coverage spans Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK, although client compatibility does not make provider request formats interchangeable.
Billing is pay-as-you-go using provider-reported token counts, with cache reads and writes priced separately. Members earn referral commission when invited users top up. Create a BestRelay account to try your first request.
Want to try the models discussed here? Sign up