Skip to content

Google Models ​

Basic Chat ​

http
POST /v1beta/models/<Model ID>:generateContent
bash
curl --location --request POST 'https://neolink.com/api/v1beta/models/<Model ID>:generateContent' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "contents": [
             {
                 "parts": [
                     {
                         "text": "How does AI work?"
                     }
                 ]
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1beta/models/<Model ID>:generateContent"

headers = {
    "x-goog-api-key": "<API Key>",
    "Content-Type": "application/json",
}

payload = {
    "contents": [
        {
            "parts": [
                {
                    "text": "How does AI work?"
                }
            ]
        }
    ]
}

resp = requests.post(url, headers=headers, json=payload, timeout=30)
resp.raise_for_status()
data = resp.json()
print(data)

Authentication Note: Google model requests use Authorization: Bearer <API Key> in the header by default. If the Authorization parameter cannot be recognized, replace "Authorization": "Bearer <API Key>" with "x-goog-api-key": "<API Key>".

Optional Parameters ​

Google model parameters are centralized in the generationConfig object.

ParameterTypeRequiredDefaultDescription
generationConfig.temperaturefloatNo1.0Sampling temperature, range 0.0~2.0. Higher values (e.g., 1.5) make output more random and creative, lower values (e.g., 0.3) make output more deterministic and focused. 0 means almost deterministic output. Recommended to adjust only one of temperature, topP, or topK
generationConfig.topPfloatNo-Nucleus sampling threshold, range 0.0~1.0. The model considers tokens with cumulative probability up to topP. For example, 0.95 means only consider the most likely tokens that cumulatively reach 95% probability. Recommended to adjust only one of temperature, topP, or topK
generationConfig.topKintNo-Only sample from the top K most likely tokens. For example, setting it to 40 means the model only chooses from the 40 highest probability tokens each time. This is another way to control output diversity
generationConfig.maxOutputTokensintNo-Maximum tokens for response generation. Setting this parameter controls response length and cost. Different models have different maximum limits; values exceeding the limit are automatically adjusted
generationConfig.candidateCountintNo1Number of response candidates to generate. Setting it greater than 1 returns multiple different response candidates, each billed separately. Useful for scenarios requiring multiple different answers
generationConfig.stopSequencesarrayNo-List of stop sequences, up to 5 strings. Generation stops immediately when any stop sequence appears in the generated text. The stop sequence itself is not included in the output. Useful for controlling output format
generationConfig.presencePenaltyfloatNo0.0Presence penalty coefficient, range -2.0~2.0. Positive values penalize tokens that have already appeared, encouraging the model to talk about new topics; negative values encourage repeating existing topics
generationConfig.frequencyPenaltyfloatNo0.0Frequency penalty coefficient, range -2.0~2.0. Positive values penalize tokens based on their frequency in the text, decreasing likelihood of repeating the same words; negative values increase repetition likelihood
generationConfig.responseLogprobsboolNofalseWhether to return log probability information for output tokens. When enabled, the response includes log probabilities for each token, useful for analyzing model certainty and confidence
generationConfig.logprobsintNo-Number of candidate tokens to return at each position. When set, each output token position returns the specified number of alternative tokens and their probabilities, useful for analyzing the model's decision process
generationConfig.responseMimeTypestringNotext/plainMIME type of the response. Setting it to application/json forces the model to output valid JSON format. When using JSON mode, it's recommended to use responseSchema to define the JSON structure
generationConfig.responseSchemaobjectNo-JSON schema for the response, used for structured output. When defined, the model strictly generates JSON responses according to the schema. Must be used with responseMimeType: "application/json"
generationConfig.thinkingConfigobjectNo-Thinking configuration for controlling reasoning capabilities (only works with models that support thinking). When configured, the model performs internal reasoning before answering, and the reasoning process is reflected in the response
generationConfig.thinkingConfig.thinkingBudgetintNo-Token budget available for the thinking process. Setting it to 0 completely disables the thinking feature. Higher values allow deeper reasoning but increase latency and cost
safetySettingsarrayNo-Safety settings array for controlling harmful content filtering levels. Each setting includes category (e.g., HARM_CATEGORY_HATE_SPEECH) and threshold (e.g., BLOCK_MEDIUM_AND_ABOVE). Can adjust filtering strength based on application scenarios
toolsarrayNo-List of tools the model may call. Google models support specific tools like googleSearch (web search), urlContext (URL content extraction), etc. Each tool defines its functionality and parameters
toolConfigobjectNo-Tool configuration for controlling tool calling behavior. Can set functionCallingConfig.mode to AUTO (model decides), ANY (must call tools), or NONE (no tool calling)

Notes:

  • Google model reasoning and generation control parameters must be placed within the generationConfig object, which differs from the flat parameter structure of OpenAI and Anthropic.
  • thinkingBudget only works with models that support thinking (such as Gemini 2.0 Flash Thinking).
  • Recommended to adjust only one of temperature, topP, or topK; adjusting multiple may lead to unpredictable sampling behavior.
  • presencePenalty and frequencyPenalty can be used together; combining them provides more fine-grained control over output repetition and diversity.

Full Parameters Example ​

bash
curl --location --request POST 'https://neolink.com/api/v1beta/models/<Model ID>:generateContent' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "contents": [
             {
                 "parts": [
                     {
                         "text": "How does AI work?"
                     }
                 ]
             }
         ],
         "generationConfig": {
             "temperature": 1.0,
             "topP": 0.95,
             "maxOutputTokens": 2048,
             "thinkingConfig": {
                 "thinkingBudget": 1024
             }
         }
     }'
python
import requests

url = "https://neolink.com/api/v1beta/models/<Model ID>:generateContent"

headers = {
    "x-goog-api-key": "<API Key>",
    "Content-Type": "application/json",
}

payload = {
    "contents": [
        {
            "parts": [
                {
                    "text": "How does AI work?"
                }
            ]
        }
    ],
    "generationConfig": {
        "temperature": 1.0,
        "topP": 0.95,
        "maxOutputTokens": 2048,
        "thinkingConfig": {
            "thinkingBudget": 1024
        }
    }
}

resp = requests.post(url, headers=headers, json=payload, timeout=30)
resp.raise_for_status()
data = resp.json()
print(data)

Search Request ​

Native Model Search Request ​

http
POST /v1beta/models/<Model ID>:generateContent
bash
curl --location --request POST 'https://neolink.com/api/v1beta/models/<Model ID>:generateContent' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "contents": [
             {
                 "parts": [
                     {
                         "text": "How is the weather in Beijing today?"
                     }
                 ]
             }
         ],
         "tools": [
             {
                 "googleSearch": {}
             },
             {
                 "urlContext": {}
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1beta/models/<Model ID>:generateContent"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "contents": [
        {
            "parts": [
                {
                    "text": "How is the weather in Beijing today?"
                }
            ]
        }
    ],
    "tools": [
        {
            "googleSearch": {}
        },
        {
            "urlContext": {}
        }
    ]
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Default Search Request ​

http
POST /v1beta/models/<Model ID>:generateContent
bash
curl --location --request POST 'https://neolink.com/api/v1beta/models/<Model ID>:generateContent' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "contents": [
             {
                 "parts": [
                     {
                         "text": "How is the weather in Beijing today?"
                     }
                 ]
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1beta/models/<Model ID>:generateContent"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "contents": [
        {
            "parts": [
                {
                    "text": "How is the weather in Beijing today?"
                }
            ]
        }
    ]
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Supported Model IDs:

  • gemini-3-pro-preview-search

Video Understanding ​

http
POST /v1beta/models/<Model ID>:generateContent
bash
curl --location --request POST 'https://neolink.com/api/v1beta/models/<Model ID>:generateContent' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "contents": [
             {
                 "parts": [
                     {
                         "inline_data": {
                             "mime_type": "video/mp4",
                             "data": "<Base64 Code>"
                         }
                     },
                     {
                         "text": "Please summarize the main content of this video and list three key moments."
                     }
                 ]
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1beta/models/<Model ID>:generateContent"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "contents": [
        {
            "parts": [
                {
                    "inline_data": {
                        "mime_type": "video/mp4",
                        "data": "<Base64 Code>"
                    }
                },
                {
                    "text": "Please summarize the main content of this video and list three key moments."
                }
            ]
        }
    ]
}

resp = requests.post(url, headers=headers, json=payload, timeout=30)
resp.raise_for_status()
data = resp.json()
print(data)

Base64 Encoding Note: The <Base64 Code> parameter is the Base64-encoded string of the video file. Reference script:

bash
#!/usr/bin/env bash
set -euo pipefail
VIDEO_PATH="./demo.mp4"

if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
    B64FLAGS="--input"
else
    B64FLAGS="-w0"
fi
base64 $B64FLAGS "$VIDEO_PATH" > base64.txt