Gemini PRO
Gemini 1.5 Pro represents a significant leap in large language model technology, offering exceptional understanding and performance across different modalities and contexts.
API Format: Google Gemini
This model uses Google Gemini request/response format.
1import requests
2
3url = "https://api.segmind.com/v1/gemini-1.5-pro"
4
5headers = {
6 "Authorization": "Bearer YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "messages": {
12 "system_instruction": {
13 "parts": {
14 "text": "You are a helpful assistant."
15 }
16 },
17 "contents": [
18 {
19 "role": "user",
20 "parts": [
21 {
22 "text": "What's in this image?"
23 },
24 {
25 "inlineData": {
26 "mimeType": "image/jpeg",
27 "data": "iVBORw0KGgoAAAANSUhEUgA..."
28 }
29 }
30 ]
31 }
32 ]
33 }
34}
35
36response = requests.post(url, json=data, headers=headers)
37print(response.json())
1import requests
2
3url = "https://api.segmind.com/v1/gemini-1.5-pro"
4
5headers = {
6 "Authorization": "Bearer YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "messages": {
12 "system_instruction": {
13 "parts": {
14 "text": "You are a helpful assistant."
15 }
16 },
17 "contents": [
18 {
19 "role": "user",
20 "parts": [
21 {
22 "text": "What's in this image?"
23 },
24 {
25 "inlineData": {
26 "mimeType": "image/jpeg",
27 "data": "iVBORw0KGgoAAAANSUhEUgA..."
28 }
29 }
30 ]
31 }
32 ]
33 }
34}
35
36response = requests.post(url, json=data, headers=headers)
37print(response.json())
API Endpoint
POST https://api.segmind.com/v1/gemini-1.5-pro
Parameters
messages
requiredobject[]
Object containing contents array with role and parts. Parts can contain text or inlineData for images.
role
requiredstring
Role of the message sender
"user"
"model"
content
requiredarray
Array of parts (text or inlineData)
messages.system_instruction
optionalobject
System instruction with parts containing text to guide model behavior.
parts
optionalobject
text
requiredstring
System instruction text
Response Format
{
"candidates": [
{
"content": {
"parts": [
{
"text": "I can see a beautiful sunset over the ocean with vibrant orange and pink hues in the sky."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": []
}
],
"usageMetadata": {
"promptTokenCount": 56,
"candidatesTokenCount": 31,
"totalTokenCount": 87
}
}
Image Input Format
Important: Google Gemini Format
Images should be base64 encoded in the inlineData.data field with mimeType specified
This model supports vision capabilities. You can include images in your requests.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid message format or parameters
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out