Gemini 4 Carbon API

A reasoning model for complex coding, scientific reasoning, and multimodal understanding.

POST /v1/chat/completions

Chat Completions

Basic text request

Required parameters: model, messages

Available parameters: model, messages, max_tokens, stream, stream_options

Request parameters

ParameterTypeRequiredDescription
modelstringYesUse `gemini-4-carbon`. Options: gemini-4-carbon
messagesarrayYesOrdered conversation turns. Each turn contains `role` and `content`.
max_tokensintegerNoOutput budget for reasoning and visible text. The example sets a per-call budget.
streambooleanNoDefaults to `false` for JSON. Set `true` for SSE.
stream_optionsobjectNoStreaming options.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. ### Streaming request example ```bash curl -N -X POST 'https://api.router.ai/v1/chat/completions' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ --data-raw '{"model":"gemini-4-carbon","max_tokens":256,"stream":true,"messages":[{"role":"user","content":"Suggest a name for a fictional paper sailboat."}],"stream_options":{"include_usage":true}}' ``` Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -X POST 'https://api.router.ai/v1/chat/completions' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"model":"gemini-4-carbon","max_tokens":256,"stream":false,"messages":[{"role":"user","content":"Suggest a name for a fictional paper sailboat."}]}'

Endpoint reference: Create a chat completion (OpenAI-compatible)

POST /v1/responses

Responses

Basic text request

Required parameters: model, input

Available parameters: model, input, max_output_tokens, stream

Request parameters

ParameterTypeRequiredDescription
modelstringYesUse `gemini-4-carbon`. Options: gemini-4-carbon
inputstringYesInput text. This example uses a plain string.
max_output_tokensintegerNoOutput budget for reasoning and visible text. The example sets a per-call budget.
streambooleanNoDefaults to `false` for JSON. Set `true` for SSE.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. ### Streaming request example ```bash curl -N -X POST 'https://api.router.ai/v1/responses' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ --data-raw '{"model":"gemini-4-carbon","max_output_tokens":256,"stream":true,"input":"Suggest a name for a fictional paper sailboat."}' ``` Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -X POST 'https://api.router.ai/v1/responses' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"model":"gemini-4-carbon","max_output_tokens":256,"stream":false,"input":"Suggest a name for a fictional paper sailboat."}'

POST /v1/messages

Messages

Basic text request

Required parameters: model, messages, max_tokens

Available parameters: model, messages, max_tokens, stream, system

Request parameters

ParameterTypeRequiredDescription
modelstringYesUse `gemini-4-carbon`. Options: gemini-4-carbon
messagesarrayYesOrdered conversation turns. Each turn contains `role` and `content`.
max_tokensintegerYesOutput budget for reasoning and visible text. The example sets a per-call budget.
streambooleanNoDefaults to `false` for JSON. Set `true` for SSE.
systemstringNoOptional top-level system instruction.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. ### Streaming request example ```bash curl -N -X POST 'https://api.router.ai/v1/messages' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \ --data-raw '{"model":"gemini-4-carbon","max_tokens":256,"stream":true,"messages":[{"role":"user","content":"Suggest a name for a fictional paper sailboat."}]}' ``` Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -X POST 'https://api.router.ai/v1/messages' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'anthropic-version: 2023-06-01' \
  --data-raw '{"model":"gemini-4-carbon","max_tokens":256,"stream":false,"messages":[{"role":"user","content":"Suggest a name for a fictional paper sailboat."}]}'

Endpoint reference: Create a message (Claude native)

POST /v1beta/models/gemini-4-carbon:generateContent

Gemini native generation · v1beta

Basic text request

Required parameters: contents

Available parameters: contents, generationConfig, systemInstruction

Request parameters

ParameterTypeRequiredDescription
contentsarrayYesOrdered turns. Text requests use `contents[].parts[].text`.
generationConfigobjectNoGeneration settings. `maxOutputTokens` controls the combined text and reasoning budget.
systemInstructionobjectNoOptional system instruction using `parts[].text`.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. When a native function call includes `thoughtSignature`, return the original model parts and the matching `functionResponse` in order, with the signature intact. Cross-account signature portability is unverified. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -X POST 'https://api.router.ai/v1beta/models/gemini-4-carbon:generateContent' \
  -H "x-goog-api-key: $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"contents":[{"role":"user","parts":[{"text":"Suggest a name for a fictional paper sailboat."}]}],"generationConfig":{"maxOutputTokens":192,"thinkingConfig":{"thinkingLevel":"LOW"}}}'

POST /v1beta/models/gemini-4-carbon:streamGenerateContent

Gemini native streaming · v1beta

Basic text request

Required parameters: contents

Available parameters: contents, generationConfig, systemInstruction

Request parameters

ParameterTypeRequiredDescription
contentsarrayYesOrdered turns. Text requests use `contents[].parts[].text`.
generationConfigobjectNoGeneration settings. `maxOutputTokens` controls the combined text and reasoning budget.
systemInstructionobjectNoOptional system instruction using `parts[].text`.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. When a native function call includes `thoughtSignature`, return the original model parts and the matching `functionResponse` in order, with the signature intact. Cross-account signature portability is unverified. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. ### SSE event format ```text data: {"candidates":[{"index":0,"content":{"role":"model","parts":[{"text":"Paper Finch"}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":24,"candidatesTokenCount":7,"thoughtsTokenCount":9,"totalTokenCount":40},"modelVersion":"gemini-4-carbon","responseId":"example_gemini_response_001"} ``` Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -N -X POST 'https://api.router.ai/v1beta/models/gemini-4-carbon:streamGenerateContent?alt=sse' \
  -H "x-goog-api-key: $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"contents":[{"role":"user","parts":[{"text":"Suggest a name for a fictional paper sailboat."}]}],"generationConfig":{"maxOutputTokens":192,"thinkingConfig":{"thinkingLevel":"LOW"}}}'

POST /v1/models/gemini-4-carbon:generateContent

Gemini native generation · v1

Basic text request

Required parameters: contents

Available parameters: contents, generationConfig, systemInstruction

Request parameters

ParameterTypeRequiredDescription
contentsarrayYesOrdered turns. Text requests use `contents[].parts[].text`.
generationConfigobjectNoGeneration settings. `maxOutputTokens` controls the combined text and reasoning budget.
systemInstructionobjectNoOptional system instruction using `parts[].text`.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. When a native function call includes `thoughtSignature`, return the original model parts and the matching `functionResponse` in order, with the signature intact. Cross-account signature portability is unverified. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -X POST 'https://api.router.ai/v1/models/gemini-4-carbon:generateContent' \
  -H "x-goog-api-key: $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"contents":[{"role":"user","parts":[{"text":"Suggest a name for a fictional paper sailboat."}]}],"generationConfig":{"maxOutputTokens":192,"thinkingConfig":{"thinkingLevel":"LOW"}}}'

POST /v1/models/gemini-4-carbon:streamGenerateContent

Gemini native streaming · v1

Basic text request

Required parameters: contents

Available parameters: contents, generationConfig, systemInstruction

Request parameters

ParameterTypeRequiredDescription
contentsarrayYesOrdered turns. Text requests use `contents[].parts[].text`.
generationConfigobjectNoGeneration settings. `maxOutputTokens` controls the combined text and reasoning budget.
systemInstructionobjectNoOptional system instruction using `parts[].text`.
`MAX_TOKENS` can return only reasoning usage or partial text. After a client timeout, check the original request before sending another one. When a native function call includes `thoughtSignature`, return the original model parts and the matching `functionResponse` in order, with the signature intact. Cross-account signature portability is unverified. Check JSON and fields for HTTP 400, the API key for 401, the account balance for 402, and request frequency for 429. A 5xx status indicates a service error. Streams can also contain error events, so check both the HTTP status and the final event. Reasoning and visible text share the output budget. Omitted counters are unreported. An explicit zero means the counter is zero. ### SSE event format ```text data: {"candidates":[{"index":0,"content":{"role":"model","parts":[{"text":"Paper Finch"}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":24,"candidatesTokenCount":7,"thoughtsTokenCount":9,"totalTokenCount":40},"modelVersion":"gemini-4-carbon","responseId":"example_gemini_response_001"} ``` Verified 2026-11-26. [Google model reference](https://aistudio.google.com/docs/models/gemini-4-carbon)

Request example

curl -N -X POST 'https://api.router.ai/v1/models/gemini-4-carbon:streamGenerateContent?alt=sse' \
  -H "x-goog-api-key: $API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{"contents":[{"role":"user","parts":[{"text":"Suggest a name for a fictional paper sailboat."}]}],"generationConfig":{"maxOutputTokens":192,"thinkingConfig":{"thinkingLevel":"LOW"}}}'