Text modelsAdvanced usersUpdated
POST/v1beta/models/gemini-4-carbon:generateContent

API console

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

Requests use the API key you enter and follow standard API billing.

Gemini 4 Carbon

Request ID gemini-4-carbon

Protocols

Authentication

Requests require an API key from API key management. For JSON requests, set Content-Type: application/json.

  • Gemini · x-goog-api-key: YOUR_API_KEY

Request parameters

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

FieldTypeRequiredDescription
model (path)stringRequiredUse gemini-4-carbon as the model ID in the URL path.
contentsobject[]RequiredConversation contents in order. Each item holds its input parts in parts.
contents[].rolestringOptionalMessage role. Use user for user input and model for model messages in history.
contents[].partsobject[]RequiredArray of parts within a content item. Text parts use text.
contents[].parts[].inlineDataobjectConditionalInline media object. Provide mimeType and Base64-encoded data. Accepted media types depend on the model and endpoint.
systemInstructionobjectOptionalSystem instruction object. Put instruction text in parts[].text.
generationConfig.maxOutputTokensintegerOptionalCaps output tokens. The accepted limit depends on the model and endpoint.
generationConfig.responseMimeTypestringOptionalOutput MIME type. Use application/json for JSON output.
generationConfig.responseJsonSchemaobjectConditionalOutput JSON Schema. Use with responseMimeType: application/json on an endpoint that supports schemas.
toolsobject[]ConditionalTool definitions available to the model. Tool types and parameter formats depend on the protocol and endpoint.

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

FieldTypeRequiredDescription
model (path)stringRequiredUse gemini-4-carbon as the model ID in the URL path.
contentsobject[]RequiredConversation contents in order. Each item holds its input parts in parts.
contents[].rolestringOptionalMessage role. Use user for user input and model for model messages in history.
contents[].partsobject[]RequiredArray of parts within a content item. Text parts use text.
contents[].parts[].inlineDataobjectConditionalInline media object. Provide mimeType and Base64-encoded data. Accepted media types depend on the model and endpoint.
systemInstructionobjectOptionalSystem instruction object. Put instruction text in parts[].text.
generationConfig.maxOutputTokensintegerOptionalCaps output tokens. The accepted limit depends on the model and endpoint.
generationConfig.responseMimeTypestringOptionalOutput MIME type. Use application/json for JSON output.
generationConfig.responseJsonSchemaobjectConditionalOutput JSON Schema. Use with responseMimeType: application/json on an endpoint that supports schemas.
toolsobject[]ConditionalTool definitions available to the model. Tool types and parameter formats depend on the protocol and endpoint.
?altstringOptionalQuery parameter. Set to sse to receive the streamGenerateContent result as SSE.

Request examples

Set your API key in the local ICODEEASY_API_KEY environment variable and choose an endpoint that accepts direct HTTP calls. For endpoints that require a specific client, follow that client’s setup guide.

Gemini generateContent

bash
curl -sS 'https://api.icodeeasy.cc/v1beta/models/gemini-4-carbon:generateContent' \
  -H "x-goog-api-key: $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Explain how a rainbow forms in one sentence."
        }
      ]
    }
  ]
}'

Gemini streamGenerateContent

bash
curl -N -sS 'https://api.icodeeasy.cc/v1beta/models/gemini-4-carbon:streamGenerateContent?alt=sse' \
  -H "x-goog-api-key: $ICODEEASY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Explain how a rainbow forms in one sentence."
        }
      ]
    }
  ]
}'

Read the response

  • Gemini generateContent · Read text parts in candidates[].content.parts[]. JSON
  • Gemini streamGenerateContent · Parse each SSE record and append the text in candidates[].content.parts[]. SSE

Full integration guide

Capabilities and limits

  • streaming · Supported
  • tool_calling · Conditional — Depends on the compatible protocol and request format
  • image_input · Conditional — Depends on the compatible endpoint and request format
  • video_input · Conditional — Depends on the compatible endpoint and request format

Model Capability Catalog · View pricing