Gemini Native Format
Call Gemini models using Google Native API format
← Semua dokumentasi/v1beta/models/gemini-3.5-flash:generateContent- Synchronous processing mode with real-time response
- Minimal parameters for quick start
{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"status": "BAD_GATEWAY"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"status": "UNAVAILABLE"
}
}Contoh permintaan
curl --request POST \
--url https://api.apisea.ai/v1beta/models/gemini-3.5-flash:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}'Authorizations
AuthorizationstringrequiredAll API endpoints require Bearer Token authentication
Get your API Key:
Visit the API Key Management Page to get your API Key
Add it to the request header:
Authorization: Bearer YOUR_API_KEYPath Parameters
modelstringrequiredModel name
The examples use gemini-3.5-flash, which you can replace with other supported Gemini models:
gemini-3.5-flash- Gemini 3.5 Flashgemini-3.1-pro-preview- Gemini 3.1 Pro Previewgemini-3-pro-preview- Gemini 3 Pro Previewgemini-3.5-flash- Gemini 2.5 Pro
methodenum\Generation method (recommended: generateContent for quick start):
generateContent: Wait for complete response and return at oncestreamGenerateContent: Stream response, return content in chunks
Available options: generateContent, streamGenerateContent
Body
contentsarrayrequiredList of conversation contents
Minimum 1 message required
contents object structure
rolestringrequiredRole type:
user: User messagemodel: Model response (used in conversation history)
partsarrayrequiredMessage content parts
parts object structure
textstringText content
inlineDataobjectInline data (for multimodal input)
inlineData properties
mimeTypestringMIME type, e.g. image/jpeg, image/png
datastringBase64 encoded data
fileDataobjectProvide multimodal content, such as video, through a file URI.
fileData properties
mimeTypestringFile MIME type, such as video/mp4.
fileUristringFile URI, such as an HTTP(S) URL for a video file.
parts example: analyze a video URL
Use fileData to provide the video URL and MIME type, and include an analysis prompt in the same message. This example asks the model to list the main events in chronological order with timestamps.
curl 'https://api.apisea.ai/v1beta/models/gemini-3.1-pro-preview:generateContent' \
-H 'Authorization: Bearer YOUR_APISea_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"fileData": {
"mimeType": "video/mp4",
"fileUri": "https://storage.googleapis.com/cloud-samples-data/generative-ai/video/pixel8.mp4"
}
},
{
"text": "Analyze the video, list the main events in chronological order, and include timestamps."
}
]
}
],
"generationConfig": {
"maxOutputTokens": 2048
}
}'Example:
[
{
"role": "user",
"parts": [{ "text": "Hello, please introduce yourself" }]
}
]generationConfigobjectGeneration configuration (optional)
generationConfig properties
temperaturenumberControls output randomness, range 0.0-2.0
- Lower values make output more deterministic
- Higher values make output more random
Default: 1.0
maxOutputTokensintegerMaximum number of tokens to generate
Different models have different maximum limits
topPnumberNucleus sampling parameter, range 0.0-1.0
Controls the probability mass considered during sampling
topKintegerTop-K sampling parameter
Sample only from the K most probable tokens at each step
stopSequencesarrayList of stop sequences
Stop generation when these sequences are encountered
safetySettingsarraySafety settings (optional)
safetySettings object structure
categorystringSafety category:
HARM_CATEGORY_HATE_SPEECH: Hate speechHARM_CATEGORY_DANGEROUS_CONTENT: Dangerous contentHARM_CATEGORY_HARASSMENT: HarassmentHARM_CATEGORY_SEXUALLY_EXPLICIT: Sexually explicit content
thresholdstringThreshold level:
BLOCK_NONE: Don't blockBLOCK_ONLY_HIGH: Block only high riskBLOCK_MEDIUM_AND_ABOVE: Block medium and above riskBLOCK_LOW_AND_ABOVE: Block low and above risk
Response
candidatesarrayList of candidate responses
candidates object structure
contentobjectGenerated content
content properties
rolestringRole, typically model
partsarrayList of content parts
parts object
textstringGenerated text content
finishReasonstringFinish reason:
STOP: Normal completionMAX_TOKENS: Maximum token limit reachedSAFETY: Stopped for safety reasonsRECITATION: Stopped due to recitationOTHER: Other reasons
indexintegerIndex of the candidate response
safetyRatingsarrayList of safety ratings
safetyRatings object
categorystringSafety category
probabilitystringProbability level: NEGLIGIBLE, LOW, MEDIUM, HIGH
promptFeedbackobjectPrompt feedback information
promptFeedback properties
safetyRatingsarraySafety ratings for the prompt
blockReasonstringBlock reason (if prompt was blocked)
usageMetadataobjectUsage statistics
usageMetadata properties
promptTokenCountintegerNumber of tokens in the prompt
candidatesTokenCountintegerNumber of tokens in candidate responses
totalTokenCountintegerTotal number of tokens consumed
thoughtsTokenCountintegerNumber of tokens used for thinking (if applicable)
promptTokensDetailsarrayPrompt token details
promptTokensDetails object
modalitystringModality type: TEXT, IMAGE, etc.
tokenCountintegerNumber of tokens for this modality
Respons
{
"code": 200,
"data": {
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello! I'm pleased to introduce myself.\n\nI am a large language model, trained and developed by Google..."
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
]
},
"usageMetadata": {
"promptTokenCount": 4,
"candidatesTokenCount": 611,
"totalTokenCount": 2422,
"thoughtsTokenCount": 1807,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 4
}
]
}
}Model yang menggunakan endpoint ini
gemini-3-flash-preview
gemini-3-flash-preview-nothinking
gemini-3-flash-preview-thinking
gemini-3-pro-preview
gemini-3-pro-preview-thinking
gemini-3.1-flash-lite-preview
gemini-3.1-pro-preview
gemini-3.1-pro-preview-thinking
gemini-3.5-flash
gemini-3.5-flash-lite
gemini-3.6-flash
gemini-3.7-flash
Menemukan masalah dalam dokumentasi ini? Email support@apisea.ai.