DEV Community

Cover image for Gemini 4 Carbon API Migration: 400 Errors, Timeouts and Output Limits
AIHubMix
AIHubMix

Posted on Edited on

Gemini 4 Carbon API Migration: 400 Errors, Timeouts and Output Limits

Carbon keeps Argon's request schema, but several values now fail validation and long thinking changes the timeout and billing profile. The native Interactions/background rules below come from Google's Carbon guide; AIHubMix currently documents only Chat Completions for Carbon.

Safe defaults

  • Use gemini-4-carbon and keep max_tokens at or below 65,536 on AIHubMix; the gateway does not publish a larger output path.
  • For Google's native long-decode path, set HTTP read timeouts to 15–20 minutes per stream.
  • Remove temperature, top_p and top_k (ignored). Remove penalties; candidate_count above 1 returns 400 in Google's Carbon guide.
  • For Google-native background interactions, send store=true and an explicit max_output_tokens; these fields are not documented for Carbon on AIHubMix.

Documented 400s

Trigger Result Fix
Native max_output_tokens above 1,048,576 400 Stay within the native cap; keep AIHubMix at ≤65,536
frequency_penalty or presence_penalty 400 Remove the fields
candidate_count above 1 400 Omit or set to 1
Native background without store=true 400 Add store=true
History ends on a model turn Rejected End on a user turn
Native thinking_budget or MINIMAL 400 on native Carbon Use low/medium/high

temperature, top_p and top_k are ignored. In Google's native Carbon fields, thinking_budget and thinking_level=MINIMAL are validation errors. In Google's OpenAI compatibility layer, reasoning_effort=minimal maps to low; AIHubMix has not published whether that mapping applies to Carbon. Do not combine reasoning_effort and thinking_level.

Quiet failures

The standard output ceiling is 65,536. Google's native long-decode path can reach up to 1,048,576 tokens minus the input, with 131,072 and 262,144 as examples, but the OpenAI compatibility layer cannot retrieve continuation tokens; keep the AIHubMix request at 65,536 or below. A low cap such as 8,192 can stop the model while it is thinking and return incomplete with empty text; completed work is still billed.

Carbon defaults to medium thinking. Explicit caching is unsupported; implicit caching begins at 4,096 tokens. Google's guide recommends sequential tool turns, while AIHubMix documents tool_choice="auto"; Carbon-specific tool support on the gateway remains unconfirmed.

Timeouts and billing

Does a 60-second cutoff allow the first answer token to arrive? Artificial Analysis measured Carbon High at 67.1 seconds, Carbon Medium at 23.2, Carbon Low at 12.9 and Argon High at 40.1.

Seconds to first answer token: Carbon High 67.1, Medium 23.2, Low 12.9; Argon High 40.1. Only Carbon High exceeds the 60-second reference.

First answer token only, not total request duration. Source: Artificial Analysis, 11 November 2026.

Carbon High crosses the 60-second reference in this measurement. That does not establish a safe timeout for the whole request: Google's separate recommendation of 15–20-minute HTTP read timeouts applies to its native long-decode streams. These are one snapshot's results, not latency guarantees or an AIHubMix test.

Thinking tokens count as output. Every native long-decode hop is billed, including hops containing only thinking, and cancelled work is billed for completed segments. Google Search grounding has 5,000 free requests per month, then $14 per 1,000 (daily cap 1,500).

Google's Vertex rule for completions over 32K that fail after a timeout is vendor-only; AIHubMix has not published whether it applies. Carbon and Argon rates double on December 1 ($2/$10/$0.10 to $4/$20/$0.20); AIHubMix's post-December price is unknown.

Minimal Chat Completions request

import os
from openai import OpenAI
client = OpenAI(base_url="https://aihubmix.com/v1", api_key=os.environ["AIHUBMIX_API_KEY"])
response = client.chat.completions.create(
    model="gemini-4-carbon",
    messages=[{"role": "user", "content": "Reply with OK."}],
    max_tokens=32768,
)
print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

AIHubMix documents Chat Completions for Carbon. Claude Code (Messages) and Codex (Responses) are not confirmed for this model, so check the model page before wiring either.

Checklist

  • gemini-4-carbon selected.
  • No sampling parameters or penalties.
  • candidate_count omitted or 1.
  • max_tokens ≤65,536; native long-decode timeout ≥15 minutes.
  • Only one reasoning control field; native MINIMAL and thinking_budget are invalid.
  • Prefer sequential tool turns on Google native; AIHubMix documents tool_choice="auto", but Carbon support is unconfirmed.
  • No explicit cache calls.

Keep reading: the Gemini 4 Carbon series

Sources

Top comments (0)