gemini-1.5-pro

This documentation is valid for the following model: gemini-1.5-pro

Model Overview

This multimodal AI model designed to process and understand text, images, and code. It excels in tasks requiring long-context understanding and interleaving of different modalities.

How to Make a Call

Step-by-Step Instructions

1️ Setup You Can’t Skip

▪️ Create an Account: Visit the AI/ML API website and create an account (if you don’t have one yet). ▪️ Generate an API Key: After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

2️ Copy the code example

At the bottom of this page, you'll find a code example that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

3️ Modify the code example

▪️ Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key from your account. ▪️ Insert your question or request into the content field—this is what the model will respond to.

4️ (Optional) Adjust other optional parameters if needed

Only model and messages are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding API schema, which lists all available parameters along with notes on how to use them.

5️ Run your modified code

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

API Schema

Generate a conversational response using a language model.

post

Creates a chat completion using a language model, allowing interactive conversation by predicting the next response based on the given chat history. This is useful for AI-driven dialogue systems and virtual assistants.

Authorizations
Body
modelundefined · enumRequiredPossible values:
frequency_penaltynumber | nullableOptional
max_tokensnumber · min: 1OptionalDefault: 512
presence_penaltynumber | nullableOptional
streambooleanOptionalDefault: false
top_pnumber · min: 0.1 · max: 1Optional
temperaturenumber · max: 2Optional
stopany ofOptional
stringOptional
or
string[]Optional
or
any | nullableOptional
tool_choiceany ofOptional
string · enumOptionalPossible values:
or
Responses
201Success
post
POST /v1/chat/completions HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 391

{
  "model": "gemini-1.5-pro",
  "frequency_penalty": 1,
  "logit_bias": {
    "ANY_ADDITIONAL_PROPERTY": 1
  },
  "max_tokens": 512,
  "presence_penalty": 1,
  "messages": [
    {
      "role": "system",
      "content": "text",
      "name": "text"
    }
  ],
  "stream": false,
  "top_p": 1,
  "temperature": 1,
  "stop": "text",
  "tools": [
    {
      "type": "function",
      "function": {
        "description": "text",
        "name": "text",
        "parameters": {
          "ANY_ADDITIONAL_PROPERTY": null
        }
      }
    }
  ],
  "tool_choice": "none"
}
201Success

No content

Code Example

import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Content-Type":"application/json", 

        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json"
    },
    json={
        "model":"gemini-1.5-pro",
        "messages":[
            {
                "role":"user",

                # Insert your question for the model here, instead of Hello:
                "content":"Hello"
            }
        ]
    }
)

data = response.json()
print(data)
Response
{'id': '2025-04-09|09:52:24.921507-07|9.7.175.26|-701765511', 'object': 'chat.completion', 'choices': [{'index': 0, 'finish_reason': 'stop', 'logprobs': None, 'message': {'role': 'assistant', 'content': 'Hello there! How can I help you today?\n'}}], 'created': 1744217544, 'model': 'google/gemini-1.5-pro', 'usage': {'prompt_tokens': 5, 'completion_tokens': 173, 'total_tokens': 178}}

Last updated

Was this helpful?