gemini_startChat
Start a stateful chat session with a Gemini model, returning a unique sessionId for continued interaction. Customize with initial history, generation settings, and safety configurations.
Instructions
Initiates a new stateful chat session with a specified Gemini model. Returns a unique sessionId to be used in subsequent chat messages. Optionally accepts initial conversation history and session-wide generation/safety configurations.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
generationConfig | No | Optional. Session-wide generation configuration settings. | |
history | No | Optional. An array of initial conversation turns to seed the chat session. Must alternate between 'user' and 'model' roles, starting with 'user'. | |
modelName | No | Optional. The name of the Gemini model to use for this chat session (e.g., 'gemini-1.5-flash'). If omitted, the server's default model (from GOOGLE_GEMINI_MODEL env var) will be used. | |
safetySettings | No | Optional. Session-wide safety settings to apply. | |
tools | No | Optional. A list of tools (currently only supporting function declarations) the model may use during the chat session. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"generationConfig": {
"additionalProperties": false,
"description": "Optional. Session-wide generation configuration settings.",
"properties": {
"maxOutputTokens": {
"description": "Maximum number of tokens to generate in the response.",
"minimum": 1,
"type": "integer"
},
"stopSequences": {
"description": "Sequences where the API will stop generating further tokens.",
"items": {
"type": "string"
},
"type": "array"
},
"temperature": {
"description": "Controls randomness. Lower values (~0.2) make output more deterministic, higher values (~0.8) make it more creative. Default varies by model.",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"topK": {
"description": "Top-k sampling parameter. The model considers the k most probable tokens. Default varies by model.",
"minimum": 1,
"type": "integer"
},
"topP": {
"description": "Nucleus sampling parameter. The model considers only tokens with probability mass summing to this value. Default varies by model.",
"maximum": 1,
"minimum": 0,
"type": "number"
}
},
"type": "object"
},
"history": {
"description": "Optional. An array of initial conversation turns to seed the chat session. Must alternate between 'user' and 'model' roles, starting with 'user'.",
"items": {
"additionalProperties": false,
"description": "A single message turn in the conversation history.",
"properties": {
"parts": {
"description": "An array of Parts making up the message content.",
"items": {
"additionalProperties": false,
"description": "A part of a historical message, primarily text for initialization.",
"properties": {
"text": {
"description": "Text content of the part.",
"type": "string"
}
},
"required": [
"text"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"role": {
"description": "The role of the entity that generated this content (user or model).",
"enum": [
"user",
"model"
],
"type": "string"
}
},
"required": [
"role",
"parts"
],
"type": "object"
},
"type": "array"
},
"modelName": {
"description": "Optional. The name of the Gemini model to use for this chat session (e.g., 'gemini-1.5-flash'). If omitted, the server's default model (from GOOGLE_GEMINI_MODEL env var) will be used.",
"minLength": 1,
"type": "string"
},
"safetySettings": {
"description": "Optional. Session-wide safety settings to apply.",
"items": {
"additionalProperties": false,
"description": "Setting for controlling content safety for a specific harm category.",
"properties": {
"category": {
"description": "Category of harmful content to apply safety settings for.",
"enum": [
"HARM_CATEGORY_UNSPECIFIED",
"HARM_CATEGORY_HATE_SPEECH",
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"HARM_CATEGORY_HARASSMENT",
"HARM_CATEGORY_DANGEROUS_CONTENT"
],
"type": "string"
},
"threshold": {
"description": "Threshold for blocking harmful content. Higher thresholds block more content.",
"enum": [
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
"BLOCK_LOW_AND_ABOVE",
"BLOCK_MEDIUM_AND_ABOVE",
"BLOCK_ONLY_HIGH",
"BLOCK_NONE"
],
"type": "string"
}
},
"required": [
"category",
"threshold"
],
"type": "object"
},
"type": "array"
},
"tools": {
"description": "Optional. A list of tools (currently only supporting function declarations) the model may use during the chat session.",
"items": {
"additionalProperties": false,
"description": "Represents a tool definition containing function declarations.",
"properties": {
"functionDeclarations": {
"description": "List of function declarations for this tool.",
"items": {
"additionalProperties": false,
"description": "Declaration of a single function that the Gemini model can request to call.",
"properties": {
"description": {
"description": "A description of what the function does.",
"minLength": 1,
"type": "string"
},
"name": {
"description": "The name of the function to be called.",
"minLength": 1,
"type": "string"
},
"parameters": {
"additionalProperties": false,
"description": "Schema defining the parameters the function accepts.",
"properties": {
"properties": {
"additionalProperties": {
"additionalProperties": false,
"description": "Schema defining a single parameter for a function declaration, potentially recursive.",
"properties": {
"description": {
"description": "Description of the parameter's purpose.",
"type": "string"
},
"enum": {
"description": "Allowed string values for an ENUM-like parameter.",
"items": {
"type": "string"
},
"type": "array"
},
"items": {
"$ref": "#/properties/tools/items/properties/functionDeclarations/items/properties/parameters/properties/properties/additionalProperties",
"description": "Defines the schema for items if the parameter type is ARRAY."
},
"properties": {
"additionalProperties": {
"$ref": "#/properties/tools/items/properties/functionDeclarations/items/properties/parameters/properties/properties/additionalProperties"
},
"type": "object"
},
"required": {
"description": "List of required property names for OBJECT types.",
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"description": "The data type of the function parameter.",
"enum": [
"OBJECT",
"STRING",
"NUMBER",
"BOOLEAN",
"ARRAY",
"INTEGER"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"description": "Defines the parameters the function accepts.",
"type": "object"
},
"required": {
"description": "List of required parameter names at the top level.",
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"const": "OBJECT",
"description": "The top-level parameters structure must be an OBJECT.",
"type": "string"
}
},
"required": [
"type",
"properties"
],
"type": "object"
}
},
"required": [
"name",
"description",
"parameters"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
},
"type": "array"
}
},
"type": "object"
}