{
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "description": "The text generated by the model."
    },
    "generation_id": {
      "type": "string",
      "description": "Unique identifier for the response generation."
    },
    "citations": {
      "type": "array",
      "description": "Optional. Citations for the sources of the information in the response.",
      "items": {
        "type": "object",
        "properties": {
          "start": { "type": "integer", "description": "Start index of the citation in the response text." },
          "end": { "type": "integer", "description": "End index of the citation in the response text." },
          "text": { "type": "string", "description": "The text of the citation." },
          "document_ids": { "type": "array", "items": { "type": "string" }, "description": "IDs of the documents cited." }
        }
      }
    },
    "documents": {
      "type": "array",
      "description": "Optional. List of documents used for generating the response.",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Unique identifier for the document." },
          "title": { "type": "string", "description": "Title of the document." },
          "snippet": { "type": "string", "description": "Snippet from the document." },
          "url": { "type": "string", "description": "URL to the document." },
          "timestamp": { "type": "string", "format": "date-time", "description": "Timestamp of the document." }
        }
      }
    },
    "chat_history": {
      "type": "array",
      "description": "The conversation history provided for context in the generation.",
      "items": {
        "type": "object",
        "properties": {
          "role": { "type": "string", "enum": ["USER", "CHATBOT", "SYSTEM"] },
          "message": { "type": "string", "description": "The message content from the chat history." }
        },
        "required": ["role", "message"]
      }
    },
    "search_queries": {
      "type": "array",
      "description": "Optional. List of search queries generated during the RAG process.",
      "items": {
        "type": "object",
        "properties": {
          "text": { "type": "string", "description": "The text of the search query." },
          "generation_id": { "type": "string", "description": "Unique identifier for the search query." }
        }
      }
    },
    "search_results": {
      "type": "array",
      "description": "Optional. List of documents retrieved from the searches.",
      "items": {
        "type": "object",
        "properties": {
          "connector": {
            "type": "object",
            "properties": {
              "id": { "type": "string", "description": "ID of the connector used for the search." }
            }
          },
          "document_ids": {
            "type": "array",
            "items": { "type": "string" },
            "description": "List of document IDs found by the search."
          },
          "search_query": {
            "type": "object",
            "properties": {
              "text": { "type": "string", "description": "The text of the search query." },
              "generation_id": { "type": "string", "description": "Unique ID for the query." }
            }
          }
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "api_version": {
          "type": "object",
          "properties": {
            "version": { "type": "string", "description": "Version of the API used." }
          }
        },
        "billed_units": {
          "type": "object",
          "properties": {
            "input_tokens": { "type": "integer", "description": "Number of input tokens billed." },
            "output_tokens": { "type": "integer", "description": "Number of output tokens billed." }
          },
          "required": ["input_tokens", "output_tokens"]
        },
        "tokens": {
          "type": "object",
          "properties": {
            "input_tokens": { "type": "integer", "description": "Total number of input tokens used." },
            "output_tokens": { "type": "integer", "description": "Total number of output tokens generated." }
          },
          "required": ["input_tokens", "output_tokens"]
        }
      }
    },
    "finish_reason": {
      "type": "string",
      "enum": ["COMPLETE", "MAX_TOKENS", "ERROR", "STOP_SEQUENCE"],
      "description": "The reason why the model stopped generating text."
    }
  },
  "required": ["text", "generation_id", "meta", "finish_reason"]
}
