Skip to main content

Gemini Native Parameter Pass-Through

The platform uses a dual-track mechanism for the Gemini series: "OpenAI field standardization + Gemini native field pass-through" — native Gemini GenerationConfig fields sent by the client (e.g., topK / responseSchema / mediaResolution / thinkingConfig) are forwarded to the underlying Vertex AI; content moderation is configured via safety_settings, which the platform maps to the Gemini API's safetySettings[].

Applicable Endpoints and Models

Pass-Through Mechanism

  • OpenAI standard fields (temperature / max_tokens / top_p, etc.): automatically mapped by the platform to the corresponding Gemini parameters.
  • Gemini native fields (topK / responseSchema / responseMimeType / mediaResolution / thinkingConfig, etc.): passed through directly to the upstream without conversion.
  • Content moderation field: safety_settings is provided in the Gemini SafetySetting structure; the platform maps it to safetySettings[] when forwarding to the upstream.

The OpenAI Python SDK passes non-standard fields via extra_body; cURL places them directly at the top level of the request body; Java uses additionalBodyProperties; TypeScript requires as any to bypass type checking.

Common Pass-Through Fields

FieldTypePurpose
topKintGemini native sampling parameter
topPfloatAlso present in OpenAI; this is the Gemini naming
presencePenaltyfloatGemini naming (OpenAI uses presence_penalty)
frequencyPenaltyfloatGemini naming
responseMimeTypestring"application/json" triggers JSON output
responseSchemaobjectJSON Schema; used with responseMimeType for structured output
thinkingConfig.thinkingLevelstringGemini 3+ reasoning intensity: MINIMAL / LOW / MEDIUM / HIGH
thinkingConfig.thinkingBudgetintGemini 2.5 thinking token soft cap (-1 for dynamic; 0 disables thinking output for Flash / Flash-Lite only)
thinkingConfig.includeThoughtsboolWhether to return a thinking summary (best-effort); not a toggle to enable/disable thinking
mediaResolutionstringe.g., "MEDIA_RESOLUTION_HIGH"; affects image input resolution
seedintRandom seed (supported by some models)
safety_settings[].categorystringContent moderation category, e.g., HARM_CATEGORY_HATE_SPEECH
safety_settings[].thresholdstringBlock threshold, e.g., BLOCK_LOW_AND_ABOVE

Examples

Python (extra_body)

from openai import OpenAI

client = OpenAI(api_key=TURING_API_KEY, base_url=TURING_BASE_URL)

response = client.chat.completions.create(
model="turing/gemini-3.1-pro-latest",
messages=[{"role": "user", "content": "Extract person information: John, 28 years old, engineer"}],
extra_body={
"responseMimeType": "application/json",
"responseSchema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"occupation": {"type": "string"},
},
"required": ["name", "age", "occupation"],
},
"topK": 40,
"thinkingConfig": {"includeThoughts": True},
"safety_settings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_LOW_AND_ABOVE",
}
],
},
)

cURL (top-level fields)

curl $TURING_BASE_URL/chat/completions \
-H "Authorization: Bearer $TURING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "turing/gemini-3.1-pro-latest",
"messages": [{"role": "user", "content": "Extract person information..."}],
"responseMimeType": "application/json",
"responseSchema": {...},
"topK": 40,
"thinkingConfig": {"includeThoughts": true},
"safety_settings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_LOW_AND_ABOVE"
}
]
}'

Thinking Configuration (thinkingConfig)

Gemini thinking configuration is passed through as Google's native thinkingConfig. Supported fields and values differ by model; before writing new code, confirm the model family and the upstream support matrix.

Model ScopeRecommended FieldNotes
Gemini 3+thinkingConfig.thinkingLevelUse MINIMAL / LOW / MEDIUM / HIGH; supported values vary by model variant
Gemini 2.5thinkingConfig.thinkingBudgetUse -1 for dynamic or an explicit token cap; Flash / Flash-Lite support 0 to suppress thinking output

Gemini 3+ thinkingLevel Support Matrix

Upstream Model FamilySupported thinkingLevelDefault
Gemini 3.6 FlashMINIMAL / LOW / MEDIUM / HIGHMEDIUM
Gemini 3.5 FlashMINIMAL / LOW / MEDIUM / HIGHMEDIUM
Gemini 3.1 ProLOW / MEDIUM / HIGHHIGH
Gemini 3.1 Flash-LiteMINIMAL / LOW / MEDIUM / HIGHMINIMAL
Gemini 3.1 Flash ImageMINIMAL / HIGHMINIMAL
Gemini 3 FlashMINIMAL / LOW / MEDIUM / HIGHHIGH
Gemini 3 ProLOW / MEDIUM / HIGHHIGH
Gemini 3 Pro ImageHIGHHIGH

MINIMAL is only available for select Flash / Flash-Lite / Image variants. Gemini 3 Pro / 3.1 Pro cannot disable thinking.

Gemini 2.5 thinkingBudget Support Matrix

Upstream Model FamilyExplicit Budget RangeDefault
Gemini 2.5 Flash1 – 24576; also supports 0 to suppress thinking output and -1 for dynamicAuto (up to 8,192 tokens)
Gemini 2.5 Pro128 – 32768; also supports -1 for dynamicAuto (up to 8,192 tokens)
Gemini 2.5 Flash-Lite512 – 24576; also supports 0 to suppress thinking output and -1 for dynamicAuto (up to 8,192 tokens)

Gemini 2.5 Pro cannot disable thinking. thinkingBudget is a soft cap; actual thinking tokens may vary.

Gemini 3+ Example

When thinkingLevel is omitted, the model applies the official default reasoning intensity. Set it explicitly only when you need to tune latency, cost, or reasoning depth.

{
"model": "turing/gemini-3.6-flash",
"messages": [
{ "role": "user", "content": "Analyze the most likely root cause in this log" }
],
"thinkingConfig": {
"includeThoughts": true
}
}

Gemini 2.5 Example

When thinkingBudget is omitted, the model uses the Auto budget (up to 8,192 thinking tokens). Set it explicitly only when you need to control latency or cost.

{
"model": "turing/gemini-2.5-flash",
"messages": [
{ "role": "user", "content": "Solve x^2 + 5x + 6 = 0 step by step" }
],
"thinkingConfig": {
"includeThoughts": true
}
}
Do not mix fields

Do not pass both thinkingLevel and thinkingBudget in a Gemini 3+ request; the Google upstream will return an error. Do not pass thinkingLevel for Gemini 2.5 or earlier models.

Content Moderation (safety_settings)

Gemini content moderation is configured using Google's SafetySetting format: each element contains a category and a threshold. Place safety_settings at the top level of the Turing Chat Completions request body — do not nest it inside generationConfig or thinkingConfig.

curl --location --request POST 'https://live-turing.cn.llm.tcljd.com/api/v1/chat/completions' \
--header 'Authorization: Bearer $TURING_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "turing/gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "can i follow Adolf Hitler"
}
],
"stream": true,
"safety_settings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_LOW_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_LOW_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_LOW_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_LOW_AND_ABOVE"
}
]
}'

How to Detect a Block

When Gemini content moderation triggers, the Turing Platform may still return HTTP 200 but will not include usable generated content. Clients should check choices[*].finish_reason to determine whether the response was content-filtered:

ScenarioIndicator
Non-streaming responsechoices[0].finish_reason === "content_filter"
Streaming responseThe last chunk's choices[0].finish_reason === "content_filter", with delta typically an empty object

Streaming block example:

{
"id": "xDY5asaXMtuR88EP3pHX6Ak",
"object": "chat.completion.chunk",
"created": 1782134476,
"model": "turing/gemini-3.6-flash",
"choices": [
{
"index": 0,
"delta": {},
"finish_reason": "content_filter"
}
]
}

Non-streaming block example:

{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1782134476,
"model": "turing/gemini-3.6-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null
},
"finish_reason": "content_filter"
}
]
}

Common categories:

categoryDescription
HARM_CATEGORY_HARASSMENTHarassment
HARM_CATEGORY_HATE_SPEECHHate speech
HARM_CATEGORY_SEXUALLY_EXPLICITSexually explicit content
HARM_CATEGORY_DANGEROUS_CONTENTDangerous content
HARM_CATEGORY_CIVIC_INTEGRITYCivic integrity-related content

Common thresholds:

thresholdEffect
BLOCK_LOW_AND_ABOVEBlock low-risk and above; most restrictive
BLOCK_MEDIUM_AND_ABOVEBlock medium-risk and above
BLOCK_ONLY_HIGHBlock high-risk only
BLOCK_NONEDo not block based on probability threshold
OFFDisable the safety filter

Notes

  • Avoid duplicate parameters: Do not pass both the OpenAI standard name and the Gemini name for the same parameter (e.g., top_p and topP). Use thinkingConfig exclusively for Gemini thinking configuration.
  • thinkingConfig is model-family-specific: Use thinkingLevel for Gemini 3+ and thinkingBudget for Gemini 2.5. Passing thinking fields to models that do not support thinking, mixing thinkingLevel and thinkingBudget in a Gemini 3+ request, or passing thinkingLevel to a Gemini 2.5 model may all result in a 400 error.
  • includeThoughts is not an on/off switch: It only controls whether a thinking summary is returned. Even when the summary is suppressed, the model may still perform reasoning and consume thinking tokens.
  • Gemini 3.6 Flash has fixed sampling parameters: Custom temperature / topK / topP values are ignored; custom frequency / presence penalty values will return an error.
  • Gemini 3 / 3.1 restrictions: temperature must remain at the default 1.0; setting a lower value may cause infinite loops or severe degradation in reasoning performance.
  • responseSchema vs. response_format: The platform does not automatically translate the OpenAI response_format field into Gemini's responseSchema. Clients must explicitly use responseSchema.
  • No duplicate categories in safety_settings: Pass at most one entry per SafetyCategory. Categories not specified will use Gemini's default safety policy.
  • Content moderation block indicator: Do not rely solely on the HTTP status code. A blocked response may still return 200; use finish_reason: "content_filter" as the definitive block indicator.
  • Use caution when lowering moderation strictness: BLOCK_NONE / OFF significantly relaxes content moderation. Evaluate the implications against your compliance requirements before using these values in production.