gemini-4-carbon
Use Gemini 4 Carbon with native Google GenerateContent requests, streaming, thinking controls, JSON schemas, tool calls, and explicit continuation on reAPI.
Use gemini-4-carbon with reAPI's native Google GenerateContent endpoints; see the model page for current availability and pricing.
Quick example
These examples make one non-streaming request without automatic retries or continuation. Your reAPI key belongs in x-goog-api-key; a Google account key is not required. Python uses the standard library. The JavaScript example uses @google/genai 2.29.1 with explicit retry and continuation controls.
curl https://reapi.ai/api/v1beta/models/gemini-4-carbon:generateContent \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[{"text":"Review this design and suggest a minimal verification plan."}]}],
"generationConfig": {
"maxOutputTokens": 4096,
"thinkingConfig": {"thinkingLevel":"medium"}
}
}'import json
from urllib.request import Request, urlopen
body = {
"contents": [{"role": "user", "parts": [{"text": "Review this design and suggest a minimal verification plan."}]}],
"generationConfig": {
"maxOutputTokens": 4096,
"thinkingConfig": {"thinkingLevel": "medium"},
},
}
request = Request(
"https://reapi.ai/api/v1beta/models/gemini-4-carbon:generateContent",
data=json.dumps(body).encode("utf-8"),
headers={"x-goog-api-key": "YOUR_API_KEY", "Content-Type": "application/json"},
method="POST",
)
with urlopen(request, timeout=120) as response:
result = json.load(response)
print(json.dumps(result, indent=2))import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: "YOUR_API_KEY",
httpOptions: {
baseUrl: "https://reapi.ai/api",
apiVersion: "v1beta",
retryOptions: { attempts: 1 },
},
});
const response = await ai.models.generateContent({
model: "gemini-4-carbon",
contents: "Review this design and suggest a minimal verification plan.",
config: {
maxOutputTokens: 4096,
thinkingConfig: { thinkingLevel: "medium" },
automaticContinuation: false,
},
});
console.log(response.text);package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
body := []byte(`{
"contents":[{"role":"user","parts":[{"text":"Review this design and suggest a minimal verification plan."}]}],
"generationConfig":{"maxOutputTokens":4096,"thinkingConfig":{"thinkingLevel":"medium"}}
}`)
req, err := http.NewRequest("POST",
"https://reapi.ai/api/v1beta/models/gemini-4-carbon:generateContent",
bytes.NewReader(body))
if err != nil { panic(err) }
req.Header.Set("x-goog-api-key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil { panic(err) }
fmt.Println(resp.Status, string(out))
}Endpoints and authentication
| Method | URL | Response |
|---|---|---|
POST | https://reapi.ai/api/v1beta/models/gemini-4-carbon:generateContent | Native JSON |
POST | https://reapi.ai/api/v1beta/models/gemini-4-carbon:streamGenerateContent?alt=sse | Native SSE |
Send Content-Type: application/json and x-goog-api-key: YOUR_API_KEY. Authorization: Bearer YOUR_API_KEY and the Google-compatible ?key=YOUR_API_KEY parameter are also accepted. Prefer the header examples. An explicitly supplied Google key takes precedence over bearer or browser-session credentials. Create your key in API Keys.
The JavaScript Google SDK base URL is https://reapi.ai/api, with apiVersion: "v1beta". The SDK adds /v1beta/models/gemini-4-carbon:generateContent, or its streaming equivalent. Do not put /v1beta in both the base URL and API version. Direct HTTP clients use the complete endpoint shown above.
Choose streaming by endpoint, not a stream body field. generateContent returns JSON; streamGenerateContent?alt=sse returns text/event-stream. There is no asynchronous task ID or task polling. This integration exposes these generation methods, not Google's Files, cache-management, Interactions, or token-counting APIs.
Request parameters
The native JSON body is forwarded unchanged, including unknown fields and nested schemas. This inventory describes Google's request format; it is not a field allowlist. The model service determines parameter acceptance and behavior. Authentication, billing admission, request size, and the platform media policy remain separate checks.
The model is selected in the URL. Do not replace contents with OpenAI messages or put reasoning_effort in a native request.
| Field | Type | Required / default | Meaning |
|---|---|---|---|
contents | Content array | Required | Conversation history plus the current input; each content has role (user or model) and parts |
tools | Tool array | Optional; omitted | Native function declarations and supported built-in tools |
toolConfig | object | Optional; omitted | Native function-calling and other tool configuration |
safetySettings | array | Optional; model defaults | Per-category thresholds; Google permits at most one setting per category |
continuationToken | string | Optional; omitted | Opaque checkpoint token returned by a candidate; reuse the original contents when continuing |
labels | string-valued object | Optional; omitted | Request metadata; Google specifies lowercase letters, digits, underscores and dashes, at most 63 characters per key/value, with keys beginning with a letter |
systemInstruction | Content object | Optional; omitted | Top-level text instructions, such as {"parts":[{"text":"Be concise."}]} |
generationConfig | object | Optional; model defaults | Output budget, thinking, stop sequences, schemas and other generation settings |
serviceTier | string enum | Optional; standard | unspecified, standard, flex, priority; availability depends on the model service |
store | boolean | Optional; omitted | Google request-logging control; reAPI does not add a default |
For media, use native fileData parts with a public HTTP(S) fileUri and the correct mimeType. inlineData, base64 media and data: media URIs are not accepted. Opaque thought signatures and continuation tokens are protocol state, not media inputs; preserve them exactly. Google documents image, audio, video and PDF inputs for Carbon and text output. A format's presence in the generic API does not establish model-specific availability.
generationConfig
All fields below are optional. Unless stated, omission leaves the model default in effect; reAPI does not fill in a sampling setting or rewrite a schema.
| Field | Type | Documented behavior |
|---|---|---|
maxOutputTokens | integer | Thinking plus output budget; REST defaults/per-request caps are 32,768 for JSON and 65,536 for SSE. Larger budgets can require continuation. Input, thinking and output share 1,048,576 tokens |
thinkingConfig | object | thinkingLevel: low, medium (Carbon default), high; includeThoughts requests available thought summaries. thinkingBudget is deprecated; Google rejects combining budget and level |
stopSequences | string array | Up to five sequences; the matched sequence is excluded from output |
responseMimeType | string | text/plain by default; application/json and text/x.enum are documented alternatives |
responseJsonSchema | JSON value | JSON Schema output constraint; forward the complete schema, with support determined by Google |
responseSchema | object | Legacy output schema, deprecated in the current reference; do not combine with responseJsonSchema |
responseFormat | object | Current Google reference's per-modality format configuration; model support varies |
responseModalities | string array | Omitted/empty requests text; Carbon is a text-output model |
seed | integer | Optional decoding seed; omission leaves selection to the service |
presencePenalty, frequencyPenalty | number | Native repetition settings; model behavior varies |
responseLogprobs | boolean | Requests candidate log probabilities where supported |
logprobs | integer | 0–20 alternatives in the generic reference; requires responseLogprobs |
mediaResolution | string enum | MEDIA_RESOLUTION_UNSPECIFIED, MEDIA_RESOLUTION_LOW, MEDIA_RESOLUTION_MEDIUM, MEDIA_RESOLUTION_HIGH; support depends on media and model |
enableEnhancedCivicAnswers, enableAffectiveDialog | boolean | Generic Google options; model availability varies |
translationConfig, audioTranscriptionConfig | object | Generic task configurations; model availability varies |
The controls follow the recorded Carbon request inventory. Google documents temperature, topP and topK as ignored, and explicit caching as unsupported. Additional fields still pass through to the model service; omitting them from the controls does not introduce an API rejection rule. The Google GenerateContent reference defines nested content, tool, safety and configuration objects.
Structured output
This native configuration requests an object matching a JSON Schema:
{
"generationConfig": {
"responseMimeType": "application/json",
"responseJsonSchema": {
"type": "object",
"properties": {"answer": {"type": "string"}},
"required": ["answer"],
"additionalProperties": false
}
}
}OpenAI-compatible requests
Existing OpenAI clients can use POST https://reapi.ai/api/v1/chat/completions, an OpenAI SDK base URL of https://reapi.ai/api/v1, and bearer authentication. That body uses model, messages, stream and the OpenAI parameter names. Keep it separate from the native body above.
Google documents the compatibility mapping reasoning_effort: minimal → low, low → low, medium → medium, and high → high. Prefer the native generationConfig.thinkingConfig format when working directly with Gemini-specific settings and signed parts. A parameter being accepted does not prove its effect. Google OpenAI compatibility.
OpenAI compatibility maps reasoning_effort to the native thinking level. Use the native endpoints when you need Gemini-specific objects and exact signed content parts.
Groups
See the model page’s live group prices. Copy the complete model ID shown for the group you want and use it in the model segment of the native Gemini URL, or the model field for OpenAI-compatible calls. The same reAPI key works across available groups; no separate group key is needed.
Keep the bare gemini-4-carbon model ID to use its configured default. Existing requests keep working unchanged. For programmatic discovery and compatibility details, see LLM groups.
Pricing dimensions
Current rates are read from the configured price group and displayed on the model page. Input, output (including thinking) and cached input can have separate rates. The final charge follows the selected group's settled request amount, including any applicable tool fees. Explicit caching is not supported on Carbon; a repeated prompt is a cache hit only when usage reports it.
Each continuation is a separate HTTP request with its own usage and charge. reAPI performs one generation attempt per request, with no automatic retries or continuation loop. Your application's SDK can otherwise issue additional requests, which is why the examples disable both behaviors.
Bill formula
For ordinary token usage, the estimate is (input_tokens − cached_tokens) × input_rate + cached_tokens × cache_read_rate + output_tokens × output_rate. Thinking counts as output. Any configured context tier and tool charges also apply; the final settled request amount is authoritative. reAPI does not multiply an already group-adjusted amount by the group ratio again.
The final USD amount is retained in micro-units: micro_units = ceil(billed_usd × 1,000,000), then credits = micro_units / 1,000. One credit equals $0.001. Streamed usage is cumulative and settles once after complete delivery. Failed delivery, cancellation, incomplete streams or missing trusted billing evidence follow the no-charge path.
Responses, tools and continuation
| Field | Meaning |
|---|---|
candidates[] | Native response candidates; inspect each candidate's content, finishReason and optional continuationToken |
content.parts[] | Text, thought summaries, signed parts, function calls and other native output parts |
usageMetadata | Prompt, candidate, thinking, cached-content and applicable tool-use token counters |
promptFeedback | Prompt blocking/safety feedback when returned |
groundingMetadata, citationMetadata | Candidate-level grounding or citation data when returned |
modelVersion, responseId | Model and response identifiers when supplied |
Text comes from candidate parts with text; parts marked thought: true are thought summaries. Preserve the complete model content for later turns, including thoughtSignature, part ordering and functionCall objects. Do not reconstruct a signed turn from the displayed text alone.
Your application executes client functions and sends functionResponse parts in a subsequent user content. reAPI does not execute those functions. When supplying Python callables to the Google SDK, set automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True) if your application must control each tool round trip explicitly.
For streaming, change the curl URL to :streamGenerateContent?alt=sse and add --no-buffer. Each SSE data: frame contains a native JSON response fragment. The stream ends at EOF, with no OpenAI [DONE] sentinel. Read in-stream error frames and finishReason; do not interpret any received text as proof that the stream completed.
CONTINUATION means the per-request cap was reached before generation finished. The candidate supplies an opaque continuationToken; it can have no visible text if the hop was spent thinking. To continue, make another request with the original contents unchanged and that token. If resuming after MAX_TOKENS, raise maxOutputTokens. Keep the token intact; do not generate or decode it yourself. Google's long-output guidance.
Errors
Native errors use Google's shape, with an HTTP status code and status name:
{
"error": {
"code": 400,
"message": "Request body must be a JSON object.",
"status": "INVALID_ARGUMENT"
}
}The response includes a request-id header for support. Native model error details are preserved where returned. OpenAI-compatible errors retain that endpoint's separate format.
| HTTP status | Native status | Meaning |
|---|---|---|
| 400 | INVALID_ARGUMENT | Invalid JSON/request or a model-rejected parameter combination |
| 401 | UNAUTHENTICATED | Missing or invalid reAPI key |
| 402 | FAILED_PRECONDITION | Insufficient balance for admission |
| 403 | PERMISSION_DENIED | Access denied |
| 404 | NOT_FOUND | Unknown model or method |
| 413 | INVALID_ARGUMENT | Request body exceeds 32 MB |
| 429 | RESOURCE_EXHAUSTED | Rate or concurrency limit |
| 502 | INTERNAL | Invalid response or incomplete delivery |
| 503 | UNAVAILABLE | Service or pricing unavailable |
| 504 | DEADLINE_EXCEEDED | Request deadline exceeded |
An error can arrive inside an already-open SSE stream. Handle it before treating the result as complete. See the platform error catalog for the other reAPI surfaces.
Tips
- Start with medium thinking and an explicit output budget appropriate to the task. Thinking consumes that budget even when summaries are not requested.
- Keep original signed parts for tool turns and keep the original request separately for continuation.
- Use native JSON for Gemini-specific tools and generation settings. Do not paste OpenAI field names into a native request.
- Use public media URLs and their actual MIME types; this API does not upload files to Google for you.
- Inspect usage and finish reasons. HTTP 200 alone does not verify grounding, caching, schema adherence, or a particular parameter's effect.
Related
Official model evidence reviewed 2026-11-11; reAPI integration checked 2026-11-14: GenerateContent, Carbon model, thinking, JavaScript HTTP options, JavaScript retry options, JavaScript continuation, Python SDK types.