Gemini 4 Neon Native API Guide: v1beta SDK Setup, Implicit Caching, and Tool Calling
As of 2026-12-04, gemini-4-neon runs natively on the Gemini API at $3.00 per 1M input tokens, $15.00 per 1M output tokens (including thinking tokens), and $0.15 per 1M implicit cached input tokens across a unified 1,048,576-token context window. Released on 18 November 2026 for paid tiers only, Neon replaces legacy token budgets and explicit caches with named thinkingLevel settings and automatic prefix caching. Since 3 December 2026, QCode has served gemini-4-neon on its native https://api.qcode.cc/gemini endpoint at official API list price ×1.0, sharing one cr_ key with Claude (claude-opus-5-5) and GPT (gpt-6.2-sol).
QCode is an independent third-party model API service, not affiliated with or endorsed by Google, Anthropic, or OpenAI. Facts in this guide were verified on 2026-12-04 against the official documentation linked below.
Updated 2026-12-04
Key facts
- Specs (
gemini-4-neon): Released 18 November 2026, paid-tier only, $3.00 input / $15.00 output (incl. thinking) per 1M tokens, 1,048,576 unified context, and 65,536 default sync output (up to 1,048,576 with Long Decode). - QCode
/geminiendpoint (live 2026-12-03): Servesgemini-4-neonat official price ×1.0 ($3.00/$15.00, cached read $0.15/1M);gemini-4-carbon,gemini-4-argon, andgemini-4-hydrogenare not listed on QCode yet. google-genai/@google/genaiv3.0.0+ change: Both SDKs switched defaultapi_versionfromv1betatov1; explicitly setapi_version="v1beta"/apiVersion: 'v1beta'(orGOOGLE_GENAI_API_VERSION=v1beta) withbase_url="https://api.qcode.cc/gemini"and no trailing slash.thinkingLevelrules: SupportsLOW,MEDIUM,HIGH(default), andXHIGH; legacythinking_budgetorthinking_level="MINIMAL"returns HTTP 400, andtemperature/top_p/top_koverrides are ignored.- Implicit caching only: Explicit
cachedContents/caches.createreturns HTTP 400INVALID_ARGUMENT; implicit caching gives 95% off ($0.15/1M, $0 storage fee) on 4,096+ byte-identical prefix tokens, with ~2,050 trailing tokens recomputed. - Tool loops: Multi-turn
generateContentloops must replay prior model turns and thought signatures unchanged; declare native JSON/tool schemas rather than prompting raw JSON text.
Gemini 4 Neon specs and the Gemini 4 lineup
gemini-4-neon is Google's balanced coding and agentic tier, priced below Carbon and Argon with the same 1M unified context and 95% implicit cache discount. Every Gemini 4 model charges one flat input rate across all 1,048,576 tokens (no 200K surcharge) and bills reasoning tokens at the output rate, per Google's AI Studio pricing page and Gemini 4 Neon model page checked on 2026-12-04.
| Model ID | Input / 1M | Output / 1M (incl. thinking) | Cached Input / 1M | Context / Sync Output | Lineup Status (2026-12-04) | QCode /models |
|---|---|---|---|---|---|---|
gemini-4-neon |
$3.00 | $15.00 | $0.15 | 1,048,576 / 65,536 | Balanced coding/agentic; paid only | Live on /gemini (×1.0) |
gemini-4-hydrogen |
$1.50 | $7.50 | $0.075 | 1,048,576 / ~64K | Fast everyday; Free & Paid tiers | Not listed yet |
gemini-4-carbon |
$4.00 | $20.00 | $0.20 | 1,048,576 / ~64K | Deep reasoning; $4/$20 since 2026-12-01 | Not listed yet |
gemini-4-argon |
$4.00 | $20.00 | $0.20 | 1,048,576 / 65,536 | Deprecated; auto-routes to Carbon 2026-12-15 | Not listed yet |
Three constraints matter before writing routing code:
- QCode availability: Only
gemini-4-neonis publicly listed on QCode/modelstoday.gemini-4-carbon,gemini-4-argon, andgemini-4-hydrogenare not listed on QCode yet, so do not target those IDs onapi.qcode.cc/gemini. - Argon retirement: Both Carbon and Argon moved from $2/$10 introductory pricing to $4/$20 on 1 December 2026; on Google's API, deprecated
gemini-4-argonauto-routes togemini-4-carbonstarting 15 December 2026. - Unified window vs. sync cap: Input, thinking, function calls, and output share 1,048,576 tokens. Default synchronous hops cap output at 65,536 tokens; generating longer outputs (up to 1,048,576 minus input) uses Long Decode via Google's Interactions API (
background=true) or SDK segment continuation.
Direct REST curl and the google-genai v3.0.0+ v1beta gotcha
Send REST requests to https://api.qcode.cc/gemini/v1beta/models/gemini-4-neon:generateContent with x-goog-api-key, and in google-genai or @google/genai v3.0.0+ explicitly set v1beta with base_url="https://api.qcode.cc/gemini" and no trailing slash. Google recommends the x-goog-api-key header instead of ?key= so credentials stay out of logs and traces.
Verify model listing, non-streaming JSON, and SSE streaming with curl first:
export GEMINI_API_KEY="cr_your_key"
# 1. List available Gemini models on QCode
curl -s "https://api.qcode.cc/gemini/v1beta/models" \
-H "x-goog-api-key: $GEMINI_API_KEY"
# 2. Non-streaming generateContent call with thinkingLevel
curl -s "https://api.qcode.cc/gemini/v1beta/models/gemini-4-neon:generateContent" \
-X POST \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Write a Go function to deduplicate sorted ints."}]}],
"generationConfig": {
"thinkingConfig": {"thinkingLevel": "MEDIUM"}
}
}'
# 3. Streaming SSE call (--no-buffer flushes chunks immediately)
curl "https://api.qcode.cc/gemini/v1beta/models/gemini-4-neon:streamGenerateContent?alt=sse" \
-X POST \
--no-buffer \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Explain HTTP/2 stream multiplexing in 3 bullets."}]}]
}'
When moving to the official SDKs, watch the v3.0.0+ default API version switch. Both googleapis/python-genai and googleapis/js-genai changed the default Gemini Developer API version from v1beta to v1 in v3.0.0+. Because QCode routes under /gemini/v1beta/models/..., leaving v1 active—or adding a trailing / that creates double-slash // paths—causes HTTP 404.
In Python (google-genai), pass base_url and api_version="v1beta" via types.HttpOptions directly (do not rely on GOOGLE_GEMINI_BASE_URL auto-loading), and unset any conflicting GOOGLE_API_KEY, which overrides GEMINI_API_KEY:
import os
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["GEMINI_API_KEY"],
http_options=types.HttpOptions(
base_url="https://api.qcode.cc/gemini",
api_version="v1beta",
),
)
response = client.models.generate_content(
model="gemini-4-neon",
contents="Summarize the trade-offs between B-trees and LSM-trees.",
config=types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
),
)
print(response.text)
print("Usage:", response.usage_metadata)
In JS/TS (@google/genai), httpOptions.baseUrl takes precedence over setDefaultBaseUrls({ geminiUrl: '...' }) and GOOGLE_GEMINI_BASE_URL. Set apiVersion: 'v1beta' or export GOOGLE_GENAI_API_VERSION=v1beta:
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({
apiKey: process.env.GEMINI_API_KEY,
httpOptions: {
baseUrl: 'https://api.qcode.cc/gemini',
apiVersion: 'v1beta',
},
});
const response = await ai.models.generateContent({
model: 'gemini-4-neon',
contents: 'Summarize the trade-offs between B-trees and LSM-trees.',
config: {
thinkingConfig: { thinkingLevel: 'HIGH' },
},
});
console.log(response.text);
console.log('Usage:', response.usageMetadata);
Client path rules for CLIs and IDEs
Clients differ on whether they append /v1beta automatically (see QCode's Endpoints & API Paths):
- Enter
https://api.qcode.cc/gemini(auto-appends/v1beta):google-genai,@google/genai, Antigravity CLI (agywith"modelProvider": "gemini"in~/.gemini/antigravity-cli/settings.json), Gemini CLI (GOOGLE_GEMINI_BASE_URL,GEMINI_API_KEY,GEMINI_MODEL="gemini-4-neon"), Cherry Studio, and Chatbox (adding/v1betamanually causes/v1beta/v1beta). - Enter
https://api.qcode.cc/gemini/v1beta(no auto-append): OpenCode's nativegoogleprovider (@ai-sdk/googleinopencode.json), which appends/models/...directly and returns 404/405 without/v1beta.
Configuring thinkingLevel and sampling behavior
Control reasoning depth on gemini-4-neon solely with thinkingLevel (LOW, MEDIUM, HIGH, or XHIGH), because legacy token budgets return HTTP 400 and sampling overrides are ignored. Per Google's Gemini 4 get-started guide, omitting thinkingConfig defaults to HIGH.
| Parameter | Behavior on gemini-4-neon |
Cost & Runtime Impact |
|---|---|---|
thinkingLevel: "LOW" |
Valid | Lowest latency and output spend; suits routing, triage, and formatting |
thinkingLevel: "MEDIUM" |
Valid | Balanced depth for routine code generation and extraction |
thinkingLevel: "HIGH" |
Valid (default) | Multi-step planning for cross-file edits and debugging |
thinkingLevel: "XHIGH" |
Valid (Neon & Hydrogen) | Deepest reasoning for hard root-cause bugs and refactors |
thinkingLevel: "MINIMAL" |
Rejected (HTTP 400) | Unsupported on Gemini 4; use "LOW" instead |
thinking_budget / thinkingBudget |
Rejected (HTTP 400) | Deprecated integer budget; remove from request payloads |
temperature, top_p, top_k |
Ignored | Fixed internal sampling; temperature=0 has no effect |
Because thinking tokens bill at $15.00 / 1M output—5× the $3.00 / 1M input rate—dropping routine steps from HIGH to LOW or MEDIUM cuts spend faster than trimming prompt length. Save HIGH and XHIGH for complex reasoning turns.
Note on protocol routing: Google's own /v1beta/openai/ compatibility layer maps reasoning_effort to thinking_level, but on QCode gemini-4-neon runs only on the native /gemini endpoint. Claude models run only on /api, and GPT models run only on /openai/v1 or /openai.
Implicit caching: how the 95% discount actually triggers
Gemini 4 Neon cuts cached input by 95% ($0.15/1M vs. $3.00/1M) through automatic implicit caching at $0 storage cost, whereas explicit cachedContents or caches.create calls return HTTP 400 INVALID_ARGUMENT. Strip out any legacy explicit cache-creation calls before migrating.
Implicit caching is automatic and best-effort, with durable caching enabled by default (docs note up to a 24-hour RAM TTL). Four mechanics decide your actual hit rate:
- 4,096-token byte-identical prefix: Shared prefixes must reach at least 4,096 input tokens and match byte-for-byte from token 0. A changing timestamp, request ID, or reordered tool list near the top invalidates everything below it.
- ~2,050-token trailing recomputation: Roughly the final 2,050 tokens of a prompt recompute at standard input pricing ($3.00/1M), so large static prefixes capture far stronger savings than 5K-token prompts.
- $0 storage fees: You never pay idle per-hour storage charges.
- Verify via
usageMetadata: LogusageMetadata.cachedContentTokenCount(usage_metadata.cached_content_token_countin Python). If Turn 2 reports0, diff the raw serialized JSON prefixes of Turn 1 and Turn 2.
Worked example for a 100,000-token coding-agent turn where 90,000 tokens hit cache and 10,000 tokens (new diff plus trailing window) bill uncached:
- Uncached:
100,000 × $3.00 / 1M = $0.3000. - Implicit cache hit:
(90,000 × $0.15 / 1M) + (10,000 × $3.00 / 1M) = $0.0435—an 85.5% input reduction on that turn.
Order payloads from most static to most volatile: fixed systemInstruction (no timestamps), deterministically sorted tools, static repo/docs context, then append-only conversation turns at the tail.
Function calling, thought signatures, and structured outputs
In client-managed generateContent tool loops, append the model's exact Content turn—including its thought signatures—back into contents unchanged, and never copy one signature across parallel functionCall parts. gemini-4-neon supports native function calling, parallel tool use, Google Search grounding, code execution, computer use, and JSON Schema structured outputs.
Two habits avoid production tool failures:
- Replay thought signatures verbatim: Gemini 4 attaches opaque thought signatures to reasoning and
functionCallturns. Rebuilding a strippedmodelturn or duplicating a signature across parallel calls breaks validation. Always appendresponse.candidates[0].contentintact (on Google's Interactions API,previous_interaction_idhandles state server-side). - Prefer native schemas over prose JSON rules: Declare
FunctionDeclarationparameters and native JSON Schema (or Pydantic in Python / Zod in JS) instead of asking in prose for raw JSON, which Google notes helps preventMALFORMED_FUNCTION_CALLerrors.
This Python loop runs against QCode's /gemini endpoint, preserving thought signatures and logging implicit cache hits:
import os
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["GEMINI_API_KEY"],
http_options=types.HttpOptions(
base_url="https://api.qcode.cc/gemini",
api_version="v1beta",
),
)
get_ci_status = types.FunctionDeclaration(
name="get_ci_status",
description="Return the latest CI pipeline status for a Git commit SHA.",
parameters_json_schema={
"type": "object",
"properties": {"commit_sha": {"type": "string"}},
"required": ["commit_sha"],
},
)
config = types.GenerateContentConfig(
system_instruction="You are a concise release assistant. Call tools before answering.",
tools=[types.Tool(function_declarations=[get_ci_status])],
thinking_config=types.ThinkingConfig(thinking_level="MEDIUM"),
)
contents = [
types.Content(
role="user",
parts=[types.Part.from_text(text="Did commit a1b2c3d pass CI?")],
)
]
# Turn 1: model requests a tool call
resp1 = client.models.generate_content(model="gemini-4-neon", contents=contents, config=config)
model_turn = resp1.candidates[0].content
contents.append(model_turn) # Preserve exact model parts and thought signatures
# Execute requested function calls and send function_response parts
tool_parts = []
for part in model_turn.parts:
if part.function_call:
fc = part.function_call
result = {"commit_sha": fc.args["commit_sha"], "status": "passed", "failed_jobs": 0}
tool_parts.append(types.Part.from_function_response(name=fc.name, response=result))
if tool_parts:
contents.append(types.Content(role="user", parts=tool_parts))
resp2 = client.models.generate_content(model="gemini-4-neon", contents=contents, config=config)
print(resp2.text)
if resp2.usage_metadata:
print("Cached tokens:", resp2.usage_metadata.cached_content_token_count)
Keeping system_instruction and tools immutable while appending model_turn and tool_parts at the end preserves both signature integrity and prefix cacheability once context passes 4,096 tokens.
FAQ
Why does google-genai v3.0.0+ return 404 against /gemini?
Starting in v3.0.0, google-genai (Python) and @google/genai (JS/TS) changed the default Gemini Developer API version from v1beta to v1. Because QCode serves /gemini/v1beta/models/..., set api_version="v1beta" / apiVersion: 'v1beta' in http_options with base_url="https://api.qcode.cc/gemini" and no trailing slash.
Why does cachedContents or caches.create fail with HTTP 400 on Gemini 4 Neon?
Gemini 4 models do not support explicit context caching, so cachedContents and caches.create return HTTP 400 INVALID_ARGUMENT. Remove explicit cache management and rely on automatic implicit caching, which applies a 95% discount ($0.15/1M, $0 storage fee) on 4,096+ byte-identical prefix tokens.
Why do thinking_budget and thinking_level="MINIMAL" return HTTP 400?
Gemini 4 replaced integer token budgets with named levels. gemini-4-neon accepts only LOW, MEDIUM, HIGH (default), and XHIGH; sending thinking_budget or thinking_level="MINIMAL" triggers HTTP 400, and temperature/top_p/top_k overrides are ignored.
Are gemini-4-carbon, gemini-4-argon, or gemini-4-hydrogen available on QCode?
No. As of 2026-12-04, only gemini-4-neon is publicly listed on QCode /models (live since 3 December 2026 on https://api.qcode.cc/gemini). gemini-4-carbon, gemini-4-argon, and gemini-4-hydrogen are not listed on QCode yet.
Can I call gemini-4-neon through QCode's /openai/v1 or /api endpoint?
No. QCode routes strictly by protocol: gemini-4-neon works only on /gemini, Claude only on /api, and GPT only on /openai/v1 or /openai. Use the official Google SDKs, REST /gemini/v1beta/models/..., Antigravity CLI, or OpenCode's google provider (https://api.qcode.cc/gemini/v1beta).
Why must multi-turn tool loops preserve prior model turns and thought signatures?
Gemini 4 attaches opaque thought signatures to reasoning and functionCall turns in stateless generateContent loops. Stripping them or copying one signature across parallel calls breaks continuation; always append response.candidates[0].content verbatim before sending function_response parts.
Running Gemini 4 Neon, Claude, and GPT on one key
One QCode cr_ key runs gemini-4-neon on /gemini ($3/$15 ×1.0, implicit cache read $0.15/1M) alongside claude-opus-5-5 ($4/$20 ×1.0 on /api) and gpt-6.2-sol ($2/$10 ×1.0 on /openai/v1 or /openai) across api.qcode.cc, asia.qcode.cc, and us.qcode.cc. Pay-as-you-go packs start at $4 for $30 of quota (valid 7 days, stackable on renewal), while daily-reset plans start at $9 on /pricing; check /models for the live list and rates.