HyprLab Docs
  • GETTING STARTED
    • Introduction
    • Authentication
    • Making requests
  • BROWSE MODELS
    • Model List
      • OpenAI
        • AUDIO
        • CHAT
        • EMBEDDINGS
        • IMAGE
        • TEXT
        • MODERATION
      • Anthropic
      • Google
        • AUDIO
        • CHAT
          • OpenAI-Format
          • Google-Format
        • IMAGE
        • VIDEO
      • DeepSeek
      • x.AI
        • CHAT
        • IMAGE
      • Cohere
      • Meta AI
      • Qwen
      • Microsoft
      • Mistral AI
      • Perplexity AI
      • Cognitive Computations
      • Nvidia
      • Nous Research
      • MiniMax
      • Amazon
      • AI21-Labs
      • Reka AI
      • Black Forest Labs
      • Stability AI
        • Stable Diffusion 3.5
        • Stable Diffusion 3 - Ultra
        • Stable Diffusion 3 - Core
        • Stable Diffusion 3
        • Stable Diffusion XL 1.0
      • Recraft AI
      • Ideogram AI
      • Kling AI
      • Luma AI
      • Free-GPT
  • Playground
    • HyprLab Studio
    • HyprLab Chat
    • HyprLab - SillyTavern
  • INTEGRATION
    • Basic Setup
      • SillyTavern
      • Janitor AI
      • Risu AI
      • Agnai Chat
      • TypingMind
      • ChatWaifu - Steam
Powered by GitBook
On this page
  • Sample API Request
  • ✨ Gemini
  1. BROWSE MODELS
  2. Model List
  3. Google
  4. CHAT

Google-Format

Base-Path:

https://api.hyprlab.io

Non-Stream Path:

https://api.hyprlab.io/v1beta/models/[MODEL]:generateContent?key=[API-KEY]

Stream Path:

https://api.hyprlab.io/v1beta/models/[MODEL]:streamGenerateContent?alt=sse&key=[API-KEY]

Sample API Request

Basic Request:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": [
    {
      "role": "user",
      "parts": [{
        "text": "Hello"
      }]
    },
    {
      "role": "model",
      "parts": [{
        "text": "Great to meet you. What would you like to know?"
      }]
    },
    {
      "role": "user",
      "parts": [{
        "text": "I have two dogs in my house. How many paws are in my house?"
      }]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.95,
    "topK": 0,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Node.js:

= = =

const axios = require('axios');

const API_KEY = 'API_HERE'; // Replace with your API key
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContent() {
  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: [
      {
        role: "user",
        parts: [{
          text: "Hello"
        }]
      },
      {
        role: "model",
        parts: [{
          text: "Great to meet you. What would you like to know?"
        }]
      },
      {
        role: "user",
        parts: [{
          text: "I have two dogs in my house. How many paws are in my house?"
        }]
      }
    ],
    generationConfig: {
      temperature: 0.7,
      topP: 0.95,
      topK: 0,
      max_output_tokens: 8192,
      response_mime_type: "text/plain"
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    // Handle the response
    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Call the function
generateContent()
  .then(result => {
    // Additional processing if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import requests

API_KEY = "API_HERE"  # Replace with your API key
API_BASE = "api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content(conversation):
    """
    Generate content using Gemini Model
    
    Args:
        conversation: List of message objects with role and text
    """
    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": conversation,
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain"
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
conversation = [
    {
        "role": "user",
        "parts": [{
            "text": "Hello"
        }]
    },
    {
        "role": "model",
        "parts": [{
            "text": "Great to meet you. What would you like to know?"
        }]
    },
    {
        "role": "user",
        "parts": [{
            "text": "I have two dogs in my house. How many paws are in my house?"
        }]
    }
]

response = generate_content(conversation)
if "candidates" in response:
    print(response["candidates"][0]["content"]["parts"][0]["text"])

Image Input:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": {
    "parts": [
      {
        "inline_data": {
          "mime_type": "image/jpeg",
          "data": "'$(base64 /path/to/image.jpg)'"
        }
      },
      {
        "text": "What do you see in this image?"
      }
    ]
  },
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.9,
    "topK": 40,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Node.js:

= = =

const axios = require('axios');
const fs = require('fs');

const API_KEY = 'API_HERE'; // Replace with your API key
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContentWithImage(imagePath) {
  // Read and convert image to base64
  const imageData = fs.readFileSync(imagePath);
  const base64Image = imageData.toString('base64');

  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: {
      parts: [
        {
          inline_data: {
            mime_type: "image/jpeg", // Adjust mime type based on your image
            data: base64Image
          }
        },
        {
          text: "What do you see in this image?"
        }
      ]
    },
    generationConfig: {
      temperature: 0.7,
      topP: 0.95,
      topK: 0,
      max_output_tokens: 8192,
      response_mime_type: "text/plain"
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    // Handle the response
    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContentWithImage('/path/to/image.jpg')
  .then(result => {
    // Handle result if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import base64
import requests

API_KEY = "API_HERE"  # Replace with your API key
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content_with_image(image_path):
    """
    Generate content using Gemini Model with image input
    
    Args:
        image_path: Path to the image file
    """
    # Read and encode image to base64
    with open(image_path, "rb") as image_file:
        base64_image = base64.b64encode(image_file.read()).decode('utf-8')

    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": {
            "parts": [
                {
                    "inline_data": {
                        "mime_type": "image/jpeg",  # Adjust mime type based on your image
                        "data": base64_image
                    }
                },
                {
                    "text": "What do you see in this image?"
                }
            ]
        },
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain"
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content_with_image("/path/to/image.jpg")
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Audio Input:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": {
    "parts": [
      {
        "inline_data": {
          "mime_type": "audio/mpeg",
          "data": "'$(base64 /path/to/audio.mp3)'"
        }
      },
      {
        "text": "What is being said in this audio?"
      }
    ]
  },
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.95,
    "topK": 0,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Node.js:

= = =

const axios = require('axios');
const fs = require('fs');

const API_KEY = 'API_HERE'; // Replace with your API key
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContentWithAudio(audioPath) {
  // Read and convert audio to base64
  const audioData = fs.readFileSync(audioPath);
  const base64Audio = audioData.toString('base64');

  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: {
      parts: [
        {
          inline_data: {
            mime_type: "audio/mpeg", // Adjust mime type based on your audio format
            data: base64Audio
          }
        },
        {
          text: "What is being said in this audio?"
        }
      ]
    },
    generationConfig: {
      temperature: 0.7,
      topP: 0.95,
      topK: 0,
      max_output_tokens: 8192,
      response_mime_type: "text/plain"
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    // Handle the response
    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContentWithAudio('/path/to/audio.mp3')
  .then(result => {
    // Handle result if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import base64
import requests

API_KEY = "API_HERE"  # Replace with your API key
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content_with_audio(audio_path):
    """
    Generate content using Gemini Model with audio input
    
    Args:
        audio_path: Path to the audio file
    """
    # Read and encode audio to base64
    with open(audio_path, "rb") as audio_file:
        base64_audio = base64.b64encode(audio_file.read()).decode('utf-8')

    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": {
            "parts": [
                {
                    "inline_data": {
                        "mime_type": "audio/mpeg",  # Adjust mime type based on your audio format
                        "data": base64_audio
                    }
                },
                {
                    "text": "What is being said in this audio?"
                }
            ]
        },
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain"
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content_with_audio("/path/to/audio.mp3")
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Video Input:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": {
    "parts": [
      {
        "inline_data": {
          "mime_type": "video/mp4",
          "data": "'$(base64 /path/to/video.mp4)'"
        }
      },
      {
        "text": "What is happening in this video?"
      }
    ]
  },
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.95,
    "topK": 0,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Node.js:

= = =

const axios = require('axios');
const fs = require('fs');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContentWithVideo(videoPath) {
  // Read and convert video to base64
  const videoData = fs.readFileSync(videoPath);
  const base64Video = videoData.toString('base64');

  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: {
      parts: [
        {
          inline_data: {
            mime_type: "video/mp4",
            data: base64Video
          }
        },
        {
          text: "What is happening in this video?"
        }
      ]
    },
    generationConfig: {
      temperature: 0.7,
      topP: 0.9,
      topK: 40,
      max_output_tokens: 8192,
      response_mime_type: "text/plain"
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContentWithVideo('/path/to/video.mp4')
  .then(result => {
    // Handle result if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

# PYTHON
import base64
import requests

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content_with_video(video_path):
    """
    Generate content using Gemini Model with video input
    
    Args:
        video_path: Path to the video file
    """
    # Read and encode video to base64
    with open(video_path, "rb") as video_file:
        base64_video = base64.b64encode(video_file.read()).decode('utf-8')

    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": {
            "parts": [
                {
                    "inline_data": {
                        "mime_type": "video/mp4",
                        "data": base64_video
                    }
                },
                {
                    "text": "What is happening in this video?"
                }
            ]
        },
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain"
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content_with_video("/path/to/video.mp4")
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
File input:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": {
    "parts": [
      {
        "inline_data": {
          "mime_type": "application/pdf",
          "data": "'$(base64 /path/to/document.pdf)'"
        }
      },
      {
        "text": "What is this document about?"
      }
    ]
  },
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.95,
    "topK": 0,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Nodejs:

= = =

const axios = require('axios');
const fs = require('fs');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContentWithPDF(pdfPath) {
  // Read and convert PDF to base64
  const pdfData = fs.readFileSync(pdfPath);
  const base64PDF = pdfData.toString('base64');

  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: {
      parts: [
        {
          inline_data: {
            mime_type: "application/pdf",
            data: base64PDF
          }
        },
        {
          text: "What is this document about?"
        }
      ]
    },
    generationConfig: {
      temperature: 0.7,
      topP: 0.95,
      topK: 0,
      max_output_tokens: 8192,
      response_mime_type: "text/plain"
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContentWithPDF('/path/to/document.pdf')
  .then(result => {
    // Handle result if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import base64
import requests

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content_with_pdf(pdf_path):
    """
    Generate content using Gemini Model with PDF input
    
    Args:
        pdf_path: Path to the PDF file
    """
    # Read and encode PDF to base64
    with open(pdf_path, "rb") as pdf_file:
        base64_pdf = base64.b64encode(pdf_file.read()).decode('utf-8')

    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": {
            "parts": [
                {
                    "inline_data": {
                        "mime_type": "application/pdf",
                        "data": base64_pdf
                    }
                },
                {
                    "text": "What is this document about?"
                }
            ]
        },
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain"
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content_with_pdf("/path/to/document.pdf")
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Structured Output:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": [{
    "parts": [{
      "text": "List 5 popular cookie recipes"
    }]
  }],
  "generationConfig": {
    "response_mime_type": "application/json",
    "response_schema": {
      "type": "ARRAY",
      "items": {
        "type": "OBJECT",
        "properties": {
          "recipe_name": {"type": "STRING"}
        }
      }
    }
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

= = =

Nodejs:

= = =

const axios = require('axios');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContent() {
  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant."
      }
    },
    contents: [{
      parts: [{
        text: "List 5 popular cookie recipes"
      }]
    }],
    generationConfig: {
      response_mime_type: "application/json",
      response_schema: {
        type: "ARRAY",
        items: {
          type: "OBJECT",
          properties: {
            recipe_name: {"type": "STRING"}
          }
        }
      }
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE"
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE"
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log('Model Response:', response.data.candidates[0].content.parts[0].text);
    } else {
      console.log('No response generated');
    }

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContent()
  .then(result => {
    // Handle result if needed
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import requests

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content():
    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": [{
            "parts": [{
                "text": "List 5 popular cookie recipes"
            }]
        }],
        "generationConfig": {
            "response_mime_type": "application/json",
            "response_schema": {
                "type": "ARRAY",
                "items": {
                    "type": "OBJECT",
                    "properties": {
                        "recipe_name": {"type": "STRING"}
                    }
                }
            }
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content()
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Function Calling:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful lighting system bot. You can turn lights on and off, and you can set the color. Do not perform any other tasks."
    }
  },
  "tools": [
    {
      "function_declarations": [
        {
          "name": "enable_lights",
          "description": "Turn on the lighting system.",
          "parameters": { "type": "object" }
        },
        {
          "name": "set_light_color",
          "description": "Set the light color. Lights must be enabled for this to work.",
          "parameters": {
            "type": "object",
            "properties": {
              "rgb_hex": {
                "type": "string",
                "description": "The light color as a 6-digit hex string, e.g. ff0000 for red."
              }
            },
            "required": ["rgb_hex"]
          }
        },
        {
          "name": "stop_lights",
          "description": "Turn off the lighting system.",
          "parameters": { "type": "object" }
        }
      ]
    }
  ],
  "tool_config": {
    "function_calling_config": {"mode": "none"}
  },
  "contents": {
    "role": "user",
    "parts": {
      "text": "What can you do?"
    }
  }
}'

= = =

Node.js

= = =

const axios = require('axios');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContent() {
  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful lighting system bot. You can turn lights on and off, and you can set the color. Do not perform any other tasks."
      }
    },
    tools: [
      {
        function_declarations: [
          {
            name: "enable_lights",
            description: "Turn on the lighting system.",
            parameters: { type: "object" }
          },
          {
            name: "set_light_color",
            description: "Set the light color. Lights must be enabled for this to work.",
            parameters: {
              type: "object",
              properties: {
                rgb_hex: {
                  type: "string",
                  description: "The light color as a 6-digit hex string, e.g. ff0000 for red."
                }
              },
              required: ["rgb_hex"]
            }
          },
          {
            name: "stop_lights",
            description: "Turn off the lighting system.",
            parameters: { type: "object" }
          }
        ]
      }
    ],
    tool_config: {
      function_calling_config: {mode: "none"}
    },
    contents: {
      role: "user",
      parts: {
        text: "What can you do?"
      }
    }
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContent()
  .then(result => {
    if (result.candidates) {
      console.log(result.candidates[0].content.parts[0].text);
    }
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import requests

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content():
    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful lighting system bot. You can turn lights on and off, and you can set the color. Do not perform any other tasks."
            }
        },
        "tools": [
            {
                "function_declarations": [
                    {
                        "name": "enable_lights",
                        "description": "Turn on the lighting system.",
                        "parameters": { "type": "object" }
                    },
                    {
                        "name": "set_light_color",
                        "description": "Set the light color. Lights must be enabled for this to work.",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "rgb_hex": {
                                    "type": "string",
                                    "description": "The light color as a 6-digit hex string, e.g. ff0000 for red."
                                }
                            },
                            "required": ["rgb_hex"]
                        }
                    },
                    {
                        "name": "stop_lights",
                        "description": "Turn off the lighting system.",
                        "parameters": { "type": "object" }
                    }
                ]
            }
        ],
        "tool_config": {
            "function_calling_config": {"mode": "none"}
        },
        "contents": {
            "role": "user",
            "parts": {
                "text": "What can you do?"
            }
        }
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content()
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Code Execution:

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "tools": [{"code_execution": {}}],
  "contents": [
    {
      "role": "user",
      "parts": [{
        "text": "Can you print \"Hello world!\"?"
      }]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": ""
        },
        {
          "executable_code": {
            "language": "PYTHON",
            "code": "\nprint(\"hello world!\")\n"
          }
        },
        {
          "code_execution_result": {
            "outcome": "OUTCOME_OK",
            "output": "hello world!\n"
          }
        },
        {
          "text": "I have printed \"hello world!\" using the provided python code block. \n"
        }
      ]
    },
    {
      "role": "user",
      "parts": [{
        "text": "What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50."
      }]
    }
  ]
}'

= = =

Node.js:

= = =

const axios = require('axios');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContent() {
  const payload = {
    tools: [{code_execution: {}}],
    contents: [
      {
        role: "user",
        parts: [{
          text: "Can you print \"Hello world!\"?"
        }]
      },
      {
        role: "model",
        parts: [
          {
            text: ""
          },
          {
            executable_code: {
              language: "PYTHON",
              code: "\nprint(\"hello world!\")\n"
            }
          },
          {
            code_execution_result: {
              outcome: "OUTCOME_OK",
              output: "hello world!\n"
            }
          },
          {
            text: "I have printed \"hello world!\" using the provided python code block. \n"
          }
        ]
      },
      {
        role: "user",
        parts: [{
          text: "What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50."
        }]
      }
    ]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContent()
  .then(result => {
    if (result.candidates) {
      console.log(result.candidates[0].content.parts[0].text);
    }
  })
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import requests

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content():
    payload = {
        "tools": [{"code_execution": {}}],
        "contents": [
            {
                "role": "user",
                "parts": [{
                    "text": "Can you print \"Hello world!\"?"
                }]
            },
            {
                "role": "model",
                "parts": [
                    {
                        "text": ""
                    },
                    {
                        "executable_code": {
                            "language": "PYTHON",
                            "code": "\nprint(\"hello world!\")\n"
                        }
                    },
                    {
                        "code_execution_result": {
                            "outcome": "OUTCOME_OK",
                            "output": "hello world!\n"
                        }
                    },
                    {
                        "text": "I have printed \"hello world!\" using the provided python code block. \n"
                    }
                ]
            },
            {
                "role": "user",
                "parts": [{
                    "text": "What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50."
                }]
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content()
    if "candidates" in response:
        print(response["candidates"][0]["content"]["parts"][0]["text"])
except Exception as e:
    print(f"An error occurred: {e}")
Grounding (Google Search Retrieval)

= = =

Curl:

= = =

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-1.5-flash-002:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "contents": [{
    "parts": [{
      "text": "What is the current Google stock price?"
    }]
  }],
  "tools": [{
    "google_search_retrieval": {
      "dynamic_retrieval_config": {
        "mode": "MODE_DYNAMIC",
        "dynamic_threshold": 0.6
      }
    }
  }]
}'

= = =

Node.js:

= = =

const axios = require('axios');

const API_KEY = 'API_HERE';
const API_BASE = 'https://api.hyprlab.io';
const MODEL = 'gemini-1.5-flash-002';

async function generateContent() {
  const payload = {
    contents: [{
      parts: [{
        text: "What is the current Google stock price?"
      }]
    }],
    tools: [{
      google_search_retrieval: {
        dynamic_retrieval_config: {
          mode: "MODE_DYNAMIC",
          dynamic_threshold: 0.6
        }
      }
    }]
  };

  try {
    const response = await axios({
      method: 'post',
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        'Content-Type': 'application/json'
      },
      data: payload
    });

    console.log('Full Response:', JSON.stringify(response.data, null, 2));
    return response.data;
  } catch (error) {
    console.error('Error:', error.response ? error.response.data : error.message);
    throw error;
  }
}

// Example usage
generateContent()
  .catch(error => {
    console.error('Failed to generate content:', error);
  });

= = =

Python:

= = =

import requests
import json

API_KEY = "API_HERE"
API_BASE = "https://api.hyprlab.io"
MODEL = "gemini-1.5-flash-002"

def generate_content():
    payload = {
        "contents": [{
            "parts": [{
                "text": "What is the current Google stock price?"
            }]
        }],
        "tools": [{
            "google_search_retrieval": {
                "dynamic_retrieval_config": {
                    "mode": "MODE_DYNAMIC",
                    "dynamic_threshold": 0.6
                }
            }
        }]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
try:
    response = generate_content()
    print('Full Response:', json.dumps(response, indent=2))
except Exception as e:
    print(f"An error occurred: {e}")
Thinking Mode

===

Curl:

===

curl -X POST "https://api.hyprlab.io/v1beta/models/gemini-2.5-flash-preview:generateContent?key=API_HERE" \
-H "Content-Type: application/json" \
-d '{
  "system_instruction": {
    "parts": {
      "text": "You are a helpful assistant."
    }
  },
  "contents": [
    {
      "role": "user",
      "parts": [{
        "text": "Hello"
      }]
    },
    {
      "role": "model",
      "parts": [{
        "text": "Great to meet you. What would you like to know?"
      }]
    },
    {
      "role": "user",
      "parts": [{
        "text": "9.11 and 9.8, which is greater?"
      }]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "topP": 0.95,
    "topK": 0,
    "max_output_tokens": 8192,
    "response_mime_type": "text/plain",
    "thinkingConfig": {
      "thinkingBudget": 24576,
      "includeThoughts": true
    }
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_NONE"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ]
}'

===

Nodejs

===

const axios = require("axios");

const API_KEY = "API_HERE"; // Replace with your API key
const API_BASE = "https://api.hyprlab.io";
const MODEL = "gemini-2.5-flash-preview";

async function generateContent() {
  const payload = {
    system_instruction: {
      parts: {
        text: "You are a helpful assistant.",
      },
    },
    contents: [
      {
        role: "user",
        parts: [
          {
            text: "Hello",
          },
        ],
      },
      {
        role: "model",
        parts: [
          {
            text: "Great to meet you. What would you like to know?",
          },
        ],
      },
      {
        role: "user",
        parts: [
          {
            text: "How many Rs are there in the word 'strawberry'?",
          },
        ],
      },
    ],
    generationConfig: {
      temperature: 0.7,
      topP: 0.95,
      topK: 0,
      max_output_tokens: 8192,
      response_mime_type: "text/plain",
      thinkingConfig: { thinkingBudget: 24576, includeThoughts: true },
    },
    safetySettings: [
      {
        category: "HARM_CATEGORY_HARASSMENT",
        threshold: "BLOCK_NONE",
      },
      {
        category: "HARM_CATEGORY_HATE_SPEECH",
        threshold: "BLOCK_NONE",
      },
      {
        category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        threshold: "BLOCK_NONE",
      },
      {
        category: "HARM_CATEGORY_DANGEROUS_CONTENT",
        threshold: "BLOCK_NONE",
      },
      {
        category: "HARM_CATEGORY_CIVIC_INTEGRITY",
        threshold: "BLOCK_NONE",
      },
    ],
  };

  try {
    const response = await axios({
      method: "post",
      url: `${API_BASE}/v1beta/models/${MODEL}:generateContent?key=${API_KEY}`,
      headers: {
        "Content-Type": "application/json",
      },
      data: payload,
    });

    // Handle the response
    if (response.data.candidates && response.data.candidates.length > 0) {
      console.log(
        "Model Response:",
        response.data.candidates[0].content.parts[0].text
      );
    } else {
      console.log("No response generated");
    }

    return response.data;
  } catch (error) {
    console.error(
      "Error:",
      error.response ? error.response.data : error.message
    );
    throw error;
  }
}

// Call the function
generateContent()
  .then((result) => {
    // Additional processing if needed
  })
  .catch((error) => {
    console.error("Failed to generate content:", error);
  });

===

Python

===

import requests

API_KEY = "API_HERE"  # Replace with your API key
API_BASE = "api.hyprlab.io"
MODEL = "gemini-2.5-flash-preview"

def generate_content(conversation):
    """
    Generate content using Gemini Model
    
    Args:
        conversation: List of message objects with role and text
    """
    payload = {
        "system_instruction": {
            "parts": {
                "text": "You are a helpful assistant."
            }
        },
        "contents": conversation,
        "generationConfig": {
            "temperature": 0.7,
            "topP": 0.95,
            "topK": 0,
            "max_output_tokens": 8192,
            "response_mime_type": "text/plain",
            "thinkingConfig": { "thinkingBudget": 24576, "includeThoughts": True }
        },
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_HARASSMENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_HATE_SPEECH",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_NONE"
            },
            {
                "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
                "threshold": "BLOCK_NONE"
            }
        ]
    }

    response = requests.post(
        f"{API_BASE}/v1beta/models/{MODEL}:generateContent?key={API_KEY}",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    
    return response.json()

# Example usage
conversation = [
    {
        "role": "user",
        "parts": [{
            "text": "Hello"
        }]
    },
    {
        "role": "model",
        "parts": [{
            "text": "Great to meet you. What would you like to know?"
        }]
    },
    {
        "role": "user",
        "parts": [{
            "text": "How many Rs are there in the word 'strawberry'?"
        }]
    }
]

response = generate_content(conversation)
if "candidates" in response:
    print(response["candidates"][0]["content"]["parts"][0]["text"])

✨ Gemini

PreviousOpenAI-FormatNextIMAGE

Last updated 8 days ago

Learn More at:

Model Name:

  • gemini-2.5-pro-preview

  • gemini-2.5-pro-preview-05-06

  • gemini-2.5-pro-preview-03-25

Discount:

  • 60% off

Prompt upto 200K:

  • $0.5 / 1M Tokens

  • $4 / 1M Tokens

Prompts longer than 200K:

  • $1 / 1M Tokens

  • $6 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

  • Thinking ✅

Model Name:

  • gemini-2.5-flash-preview

  • gemini-2.5-flash-preview-05-20

  • gemini-2.5-flash-preview-04-17

Discount:

  • 60% off

Input:

  • $0.06 / 1M Tokens

Output (Non-Thinking):

  • $0.24 / 1M Tokens

Output (Thinking):

  • $1.4 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

  • Thinking ✅

Model Name:

  • gemini-2.0-pro-exp-02-05

Discount:

  • 60% off

Input:

  • $0.5 / 1M Tokens

Output:

  • $2 / 1M Tokens

Context Length:

  • 2,097,152

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

Model Name:

  • gemini-2.0-flash

  • gemini-2.0-flash-exp

Discount:

  • 60% off

Input:

  • $0.04 / 1M Tokens

Output:

  • $0.16 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

Model Name:

  • gemini-2.0-flash-lite

  • gemini-2.0-flash-lite-preview-02-05

Discount:

  • 60% off

Input:

  • $0.03 / 1M Tokens

Output:

  • $0.12 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

Model Name:

  • gemini-2.0-flash-thinking-exp-01-21

  • gemini-2.0-flash-thinking-exp-1219

Discount:

  • 60% off

Input:

  • $0.04 / 1M Tokens

Output:

  • $0.16 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Reasoning ✅

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Code Execution ✅

Model Name:

  • gemini-exp-1206

Discount:

  • 60% off

Input:

  • $0.5 / 1M Tokens

Output:

  • $2 / 1M Tokens

Context Length:

  • 2,097,152

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

Model Name:

  • gemini-1.5-pro

  • gemini-1.5-pro-002

Discount:

  • 60% off

Prompt upto 128K:

  • $0.5 / 1M Tokens

  • $2 / 1M Tokens

Prompts longer than 128K:

  • $1 / 1M Tokens

  • $4 / 1M Tokens

Context Length:

  • 2,097,152

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

Model Name:

  • gemini-1.5-flash

  • gemini-1.5-flash-002

Discount:

  • 60% off

Prompt upto 128K:

  • $0.03 / 1M Tokens

  • $0.12 / 1M Tokens

Prompts longer than 128K:

  • $0.06 / 1M Tokens

  • $0.24 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

Model Name:

  • gemini-1.5-flash-8b

  • gemini-1.5-flash-8b-exp-0924

  • gemini-1.5-flash-8b-exp-0827

Discount:

  • 60% off

Prompt upto 128K:

  • $0.015 / 1M Tokens

  • $0.06 / 1M Tokens

Prompts longer than 128K:

  • $0.03 / 1M Tokens

  • $0.12 / 1M Tokens

Context Length:

  • 1,048,576

Moderation:

  • Unfiltered

Capabilities:

  • Image Input ✅

  • Audio Input ✅

  • Video Input ✅

  • File Input ✅

  • Structured Output ✅

  • Function Calling ✅

  • Code Execution ✅

  • Grounding ✅

https://ai.google.dev/gemini-api/docs
Page cover image