Gemini 3.1 Pro
Request ID gemini-3.1-pro-preview
Protocols
POST /v1beta/models/gemini-3.1-pro-preview:generateContent· Gemini generateContent examplePOST /v1beta/models/gemini-3.1-pro-preview:streamGenerateContent· Gemini streamGenerateContent example
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-3.1-pro-preview:generateContent
| Field | Type | Required | Description |
|---|---|---|---|
model (path) | string | Required | Use gemini-3.1-pro-preview as the model ID in the URL path. |
contents | object[] | Required | Conversation contents in order. Each item holds its input parts in parts. |
contents[].role | string | Optional | Message role. Use user for user input and model for model messages in history. |
contents[].parts | object[] | Required | Array of parts within a content item. Text parts use text. |
systemInstruction | object | Optional | System instruction object. Put instruction text in parts[].text. |
generationConfig.maxOutputTokens | integer | Optional | Caps output tokens. The accepted limit depends on the model and endpoint. |
generationConfig.temperature | number | Conditional | Controls sampling randomness. Accepted values and whether the field takes effect depend on the model and endpoint. |
generationConfig.topP | number | Conditional | Limits sampling candidates by cumulative probability. Use when the model and endpoint support it. |
generationConfig.responseMimeType | string | Optional | Output MIME type. Use application/json for JSON output. |
generationConfig.responseJsonSchema | object | Conditional | Output JSON Schema. Use with responseMimeType: application/json on an endpoint that supports schemas. |
POST /v1beta/models/gemini-3.1-pro-preview:streamGenerateContent
| Field | Type | Required | Description |
|---|---|---|---|
model (path) | string | Required | Use gemini-3.1-pro-preview as the model ID in the URL path. |
contents | object[] | Required | Conversation contents in order. Each item holds its input parts in parts. |
contents[].role | string | Optional | Message role. Use user for user input and model for model messages in history. |
contents[].parts | object[] | Required | Array of parts within a content item. Text parts use text. |
systemInstruction | object | Optional | System instruction object. Put instruction text in parts[].text. |
generationConfig.maxOutputTokens | integer | Optional | Caps output tokens. The accepted limit depends on the model and endpoint. |
generationConfig.temperature | number | Conditional | Controls sampling randomness. Accepted values and whether the field takes effect depend on the model and endpoint. |
generationConfig.topP | number | Conditional | Limits sampling candidates by cumulative probability. Use when the model and endpoint support it. |
generationConfig.responseMimeType | string | Optional | Output MIME type. Use application/json for JSON output. |
generationConfig.responseJsonSchema | object | Conditional | Output JSON Schema. Use with responseMimeType: application/json on an endpoint that supports schemas. |
?alt | string | Optional | Query 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
curl -sS 'https://api.icodeeasy.cc/v1beta/models/gemini-3.1-pro-preview: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
curl -N -sS 'https://api.icodeeasy.cc/v1beta/models/gemini-3.1-pro-preview: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
Capabilities and limits
streaming· Supported
Compatibility aliases and retired redirects
gemini-3.1-pro→gemini-3.1-pro-preview(Alias)gemini-3-pro-preview→gemini-3.1-pro-preview(Retired redirect)
Model Capability Catalog · View pricing
Related guides
Gemini CLI Setup
Install Gemini CLI, configure authentication and the custom service domain, then use strict non-streaming JSON, SSE responses, and the video analysis demo correctly.
Gemini generateContent
Send native Gemini requests and read JSON responses or SSE streams. Put the model ID in the URL path and text in contents[].parts[].
Model Capability Catalog
Compare public text, image, and video models by normalized request ID, compatible protocols, supported clients, tool use, media capabilities, limits, and review date.