Stream generate content (Gemini format)
/genai/v1beta/models/{model}:streamGenerateContentStreams content generation using Google Gemini API format. The model is specified in the URL path.
Path Parameters
Model name with action (e.g., gemini-pro:streamGenerateContent)
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
text/event-stream
application/json
application/json
curl -X POST "http://localhost:8080/genai/v1beta/models/string:streamGenerateContent" \ -H "Content-Type: application/json" \ -d '{}'{
"candidates": [
{
"content": {
"role": "user",
"parts": [
{
"text": "string",
"thought": true,
"thoughtSignature": "string",
"inlineData": {
"mimeType": "string",
"data": "string",
"displayName": "string"
},
"fileData": {
"mimeType": "string",
"fileUri": "string",
"displayName": "string"
},
"functionCall": {
"id": "string",
"name": "string",
"args": {}
},
"functionResponse": {
"id": "string",
"name": "string",
"response": {},
"willContinue": true,
"scheduling": "string"
},
"executableCode": {
"language": "string",
"code": "string"
},
"codeExecutionResult": {
"outcome": "OUTCOME_UNSPECIFIED",
"output": "string"
},
"videoMetadata": {
"fps": 0,
"startOffset": "string",
"endOffset": "string"
}
}
]
},
"finishReason": "FINISH_REASON_UNSPECIFIED",
"finishMessage": "string",
"tokenCount": 0,
"safetyRatings": [
{
"category": "string",
"probability": "string",
"probabilityScore": 0,
"severity": "string",
"severityScore": 0,
"blocked": true,
"overwrittenThreshold": "string"
}
],
"citationMetadata": {},
"index": 0,
"groundingMetadata": {},
"urlContextMetadata": {
"urlMetadata": [
{
"retrievedUrl": "string",
"urlRetrievalStatus": "string"
}
]
},
"avgLogprobs": 0,
"logprobsResult": {
"chosenCandidates": [
{
"token": "string",
"tokenId": 0,
"logProbability": 0
}
],
"topCandidates": [
{
"candidates": [
{
"token": "string",
"tokenId": 0,
"logProbability": 0
}
]
}
]
}
}
],
"promptFeedback": {
"blockReason": "string",
"blockReasonMessage": "string",
"safetyRatings": [
{
"category": "string",
"probability": "string",
"probabilityScore": 0,
"severity": "string",
"severityScore": 0,
"blocked": true,
"overwrittenThreshold": "string"
}
]
},
"usageMetadata": {
"promptTokenCount": 0,
"candidatesTokenCount": 0,
"totalTokenCount": 0,
"cachedContentTokenCount": 0,
"thoughtsTokenCount": 0,
"toolUsePromptTokenCount": 0,
"trafficType": "string",
"cacheTokensDetails": [
{
"modality": "string",
"tokenCount": 0
}
],
"candidatesTokensDetails": [
{
"modality": "string",
"tokenCount": 0
}
],
"promptTokensDetails": [
{
"modality": "string",
"tokenCount": 0
}
],
"toolUsePromptTokensDetails": [
{
"modality": "string",
"tokenCount": 0
}
]
},
"modelVersion": "string",
"responseId": "string",
"createTime": "2019-08-24T14:15:22Z"
}{
"error": {
"code": 0,
"message": "string",
"status": "string",
"details": [
{
"@type": "string",
"fieldViolations": [
{
"description": "string"
}
]
}
]
}
}{
"error": {
"code": 0,
"message": "string",
"status": "string",
"details": [
{
"@type": "string",
"fieldViolations": [
{
"description": "string"
}
]
}
]
}
}Retrieve file (Gemini format) GET
Retrieves file metadata in Google Gemini API format. Note: This endpoint returns file metadata only. Direct file content download is not supported by Gemini Files API. Use the file.uri field from the response to access the file content.
Upload file (Gemini format) POST
Uploads a file using Google Gemini API format. This is a multipart upload with two parts: - "metadata": JSON object containing file metadata - "file": Binary file content Note: Direct file content download is not supported by Gemini Files API. Use the file.uri field from the response to access uploaded files.