---
title: "Generate"
method: POST
path: "/v1/session/generate"
---

# Generate

`POST /v1/session/generate`

Handles generation requests.

## Request body

- SessionRequest — Schema for the request body for triggering a model generation.
  - `id` string — The Session ID (UUID4) this request belongs to.
  - `messages` MessageInput[], required — new query messages
    - `id` string — A unique identifier for the message - uuid4 int.
    - `parent_id` string — The ID of the parent message.
    - `turn` string — The turn identifier is used to group/message are part of the same conversation turn.
    - `group` string — The Group ID (UUID4) identify messages part of the same generation or action.
    - `actor` string — The actor of the message - user or agent.
    - `role` 'user' | 'agent' | 'system' — Describe the role associated with the completion
    - `timestamp` integer — DEPRECATED: The Unix timestamp (in seconds) of when the message was created.
    - `created_at` number — The Unix timestamp (in seconds, including fractional parts) indicating when the message was created.
    - `message_type` 'result' | 'source' | 'debug' | 'info' | 'error' | 'thinking' | 'update' | 'delete' | 'confirmation_request' | 'confirmation_response' | 'query', required — Type of message
    - `icon` string, nullable — Custom svg icon to use in the UI.
    - `text_color` string, nullable — Custom text color to use in the UI.
    - `title` string, nullable — Descripting title of the message.
    - `state` 'undefined' | 'start' | 'end' | 'query' | 'running_agent' | 'agent_done' | 'coding' | 'code_result' | 'calling_tool' | 'tool_result' | 'generating' | 'answering' | 'thinking' | 'planning' | 'reviewing' | 'understanding' | 'retrieving' | 'grounding'
    - `content` string, nullable — The content of the message encoded as utf-8 bytes.
    - `mime_type` 'text/plain' | 'text/markdown' | 'text/serialized-json' | 'application/octet-stream' | 'image/jpeg' | 'image/png' | 'image/tiff' | 'image/gif' | 'image/svg+xml' | 'image/webp' | 'image/avif' | 'audio/wav' | 'audio/mpeg' | 'audio/ogg' | 'video/webm' | 'video/mp4' | 'text/c' | 'text/c++' | 'text/java' | 'text/rust' | 'text/go' | 'text/python' | 'text/php' | 'text/perl' | 'text/ruby' | 'text/swift' | 'text/kotlin' | 'text/scala' | 'text/javascript' | 'text/typescript' | 'text/html' | 'text/css' | 'text/csv' | 'text/xml' | 'text/yaml' | 'text/toml' | 'text/sql' | 'application/json' | 'application/jsonl' | 'application/pdf' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/msword' | 'application/vnd.ms-excel' | 'application/vnd.ms-powerpoint' | 'application/rtf' | 'application/vnd.oasis.opendocument.text' | 'sec-gemini/graph' | 'sec-gemini/timeline' | 'sec-gemini/table' | 'sec-gemini/image' | 'sec-gemini/code' | 'sec-gemini/markdown' | 'sec-gemini/json' | 'sec-gemini/html' | 'sec-gemini/canvas' — Completion type
    - `status_code` integer — The status code of the message. 2xx is Okay, 4xx is a client error, 5xx is a server error.
    - `status_message` string — Explain status code reason.
    - `usage` UsageInput — Tracks token usage for a chat completion request and response.
      - `prompt_tokens` integer — Number of tokens in the prompt
      - `generated_tokens` integer — Number of tokens used during generation
      - `total_tokens` integer — Total number of tokens used in the request (prompt + generation)
      - `cached_token_count` integer — Number of tokens used in the cached response
      - `thoughts_token_count` integer — Number of tokens used in the thoughts
      - `tool_use_prompt_token_count` integer — Number of tokens used in the tool use prompt
      - `prompt_tokens_details` ModalityTokenCount[], nullable
        - `modality` 'MODALITY_UNSPECIFIED' | 'TEXT' | 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' — Server content modalities.
        - `tokenCount` integer, nullable — Number of tokens.

## Response `200`

Successful Response

- SessionResponse
  - `id` string, required
  - `messages` MessageOutput[], required
    - `id` string — A unique identifier for the message - uuid4 int.
    - `parent_id` string — The ID of the parent message.
    - `turn` string — The turn identifier is used to group/message are part of the same conversation turn.
    - `group` string — The Group ID (UUID4) identify messages part of the same generation or action.
    - `actor` string — The actor of the message - user or agent.
    - `role` 'user' | 'agent' | 'system' — Describe the role associated with the completion
    - `timestamp` integer — DEPRECATED: The Unix timestamp (in seconds) of when the message was created.
    - `created_at` number — The Unix timestamp (in seconds, including fractional parts) indicating when the message was created.
    - `message_type` 'result' | 'source' | 'debug' | 'info' | 'error' | 'thinking' | 'update' | 'delete' | 'confirmation_request' | 'confirmation_response' | 'query', required — Type of message
    - `icon` string, nullable — Custom svg icon to use in the UI.
    - `text_color` string, nullable — Custom text color to use in the UI.
    - `title` string, nullable — Descripting title of the message.
    - `state` 'undefined' | 'start' | 'end' | 'query' | 'running_agent' | 'agent_done' | 'coding' | 'code_result' | 'calling_tool' | 'tool_result' | 'generating' | 'answering' | 'thinking' | 'planning' | 'reviewing' | 'understanding' | 'retrieving' | 'grounding'
    - `content` string, nullable — The content of the message encoded as utf-8 bytes.
    - `mime_type` 'text/plain' | 'text/markdown' | 'text/serialized-json' | 'application/octet-stream' | 'image/jpeg' | 'image/png' | 'image/tiff' | 'image/gif' | 'image/svg+xml' | 'image/webp' | 'image/avif' | 'audio/wav' | 'audio/mpeg' | 'audio/ogg' | 'video/webm' | 'video/mp4' | 'text/c' | 'text/c++' | 'text/java' | 'text/rust' | 'text/go' | 'text/python' | 'text/php' | 'text/perl' | 'text/ruby' | 'text/swift' | 'text/kotlin' | 'text/scala' | 'text/javascript' | 'text/typescript' | 'text/html' | 'text/css' | 'text/csv' | 'text/xml' | 'text/yaml' | 'text/toml' | 'text/sql' | 'application/json' | 'application/jsonl' | 'application/pdf' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/msword' | 'application/vnd.ms-excel' | 'application/vnd.ms-powerpoint' | 'application/rtf' | 'application/vnd.oasis.opendocument.text' | 'sec-gemini/graph' | 'sec-gemini/timeline' | 'sec-gemini/table' | 'sec-gemini/image' | 'sec-gemini/code' | 'sec-gemini/markdown' | 'sec-gemini/json' | 'sec-gemini/html' | 'sec-gemini/canvas' — Completion type
    - `status_code` integer — The status code of the message. 2xx is Okay, 4xx is a client error, 5xx is a server error.
    - `status_message` string — Explain status code reason.
    - `usage` UsageOutput — Tracks token usage for a chat completion request and response.
      - `prompt_tokens` integer — Number of tokens in the prompt
      - `generated_tokens` integer — Number of tokens used during generation
      - `total_tokens` integer — Total number of tokens used in the request (prompt + generation)
      - `cached_token_count` integer — Number of tokens used in the cached response
      - `thoughts_token_count` integer — Number of tokens used in the thoughts
      - `tool_use_prompt_token_count` integer — Number of tokens used in the tool use prompt
      - `prompt_tokens_details` ModalityTokenCount[], nullable
        - `modality` 'MODALITY_UNSPECIFIED' | 'TEXT' | 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' — Server content modalities.
        - `tokenCount` integer, nullable — Number of tokens.
  - `status_code` integer, required — The status code of the message. 2xx is Okay, 4xx is a client error, 5xx is a server error.
  - `status_message` string, required — Explain status code reason.
  - `usage` UsageOutput, required — Tracks token usage for a chat completion request and response.
    - `prompt_tokens` integer — Number of tokens in the prompt
    - `generated_tokens` integer — Number of tokens used during generation
    - `total_tokens` integer — Total number of tokens used in the request (prompt + generation)
    - `cached_token_count` integer — Number of tokens used in the cached response
    - `thoughts_token_count` integer — Number of tokens used in the thoughts
    - `tool_use_prompt_token_count` integer — Number of tokens used in the tool use prompt
    - `prompt_tokens_details` ModalityTokenCount[], nullable
      - `modality` 'MODALITY_UNSPECIFIED' | 'TEXT' | 'IMAGE' | 'VIDEO' | 'AUDIO' | 'DOCUMENT' — Server content modalities.
      - `tokenCount` integer, nullable — Number of tokens.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/google/apis/sec-gemini.md) · [All operations](https://skmtc.net/google/apis/sec-gemini/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/sec-gemini/versions/cc76ee2bed1c/schema)
