{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/octen-ai/json-schema/octen-ai-answer-response-schema.json",
  "title": "AnswerResponse",
  "description": "A non-streaming Answer response. Returned when `stream=false`.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/octen-ai-answer-api-openapi.yml#/components/schemas/AnswerResponse",
  "type": "object",
  "required": [
    "request_id",
    "object",
    "created",
    "model",
    "choices"
  ],
  "properties": {
    "request_id": {
      "type": "string",
      "description": "The unique identifier for this request."
    },
    "object": {
      "type": "string",
      "enum": [
        "chat.completion"
      ],
      "description": "The object type, always `chat.completion` for non-streaming responses."
    },
    "created": {
      "type": "number",
      "description": "Unix timestamp (in seconds) of when the completion was created."
    },
    "model": {
      "type": "string",
      "description": "The model used for this completion."
    },
    "choices": {
      "type": "array",
      "description": "A list of completion choices containing the synthesized response.",
      "items": {
        "$ref": "#/$defs/ChatCompletionChoice"
      }
    },
    "queries": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The list of sub-queries automatically generated from the user message by the system."
    },
    "search_results": {
      "type": "array",
      "description": "Search results grouped by query. Each sub-query has a corresponding result group.",
      "items": {
        "$ref": "#/$defs/SearchResultGroup"
      }
    },
    "meta": {
      "$ref": "#/$defs/AnswerMeta"
    },
    "warning": {
      "type": [
        "string",
        "null"
      ],
      "description": "Warning message, if any."
    }
  },
  "$defs": {
    "AnswerMeta": {
      "type": "object",
      "description": "Metadata for the Answer response.",
      "properties": {
        "usage": {
          "$ref": "#/$defs/SynthesisUsage"
        },
        "latency": {
          "type": "integer",
          "description": "Total request latency in milliseconds."
        }
      }
    },
    "ChatAnnotation": {
      "type": "object",
      "description": "A citation annotation. Returned only when `octen_search` was used, currently only for `anthropic/` models. For other models, results are still available in `search_results`.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "url_citation"
          ],
          "description": "The annotation type."
        },
        "url_citation": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string",
              "description": "The URL of the cited source."
            },
            "title": {
              "type": "string",
              "description": "The title of the cited source."
            },
            "start_index": {
              "type": "integer",
              "description": "Start position of the cited span in `content`."
            },
            "end_index": {
              "type": "integer",
              "description": "End position of the cited span in `content`."
            }
          }
        }
      }
    },
    "ChatCompletionChoice": {
      "type": "object",
      "description": "A single completion choice in a non-streaming response.",
      "properties": {
        "index": {
          "type": "integer",
          "description": "The index of this choice. Usually 0."
        },
        "finish_reason": {
          "type": "string",
          "enum": [
            "stop",
            "length",
            "tool_calls",
            "content_filter",
            "error"
          ],
          "description": "The reason the model stopped generating. `stop` indicates normal completion."
        },
        "message": {
          "$ref": "#/$defs/ChatCompletionMessage"
        },
        "logprobs": {
          "$ref": "#/$defs/ChatLogprobs"
        }
      }
    },
    "ChatCompletionMessage": {
      "type": "object",
      "description": "The assistant's response message.",
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "assistant"
          ],
          "description": "The role of the message author. Always `assistant`."
        },
        "content": {
          "type": [
            "string",
            "null"
          ],
          "description": "The assistant's text content. May be `null` when the model only produces tool calls or refuses."
        },
        "tool_calls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ChatToolCall"
          },
          "description": "Custom function calls generated by the model. Present only when `finish_reason` is `tool_calls`."
        },
        "annotations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ChatAnnotation"
          },
          "description": "Citation annotations. Present only when `octen_broad_search` or `octen_search` was used."
        },
        "refusal": {
          "type": [
            "string",
            "null"
          ],
          "description": "A model-generated refusal message, or `null`."
        },
        "reasoning": {
          "type": [
            "string",
            "null"
          ],
          "description": "Reasoning text. Present only for reasoning models, otherwise `null`."
        },
        "reasoning_details": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ChatReasoningDetail"
          },
          "description": "Detailed reasoning information. Present only for reasoning models."
        }
      }
    },
    "ChatLogprobs": {
      "type": [
        "object",
        "null"
      ],
      "description": "Log probability information for the output tokens. Present only when `logprobs` is `true`, otherwise `null`.",
      "properties": {
        "content": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "properties": {
              "token": {
                "type": "string",
                "description": "The token text."
              },
              "logprob": {
                "type": "number",
                "description": "The log probability of this token."
              },
              "bytes": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "integer"
                },
                "description": "UTF-8 byte representation."
              },
              "top_logprobs": {
                "type": "array",
                "description": "The top candidate tokens at this position, same structure.",
                "items": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "ChatReasoningDetail": {
      "type": "object",
      "description": "Detailed reasoning information. Returned only for reasoning models.",
      "properties": {
        "format": {
          "type": "string",
          "enum": [
            "unknown",
            "openai-responses-v1",
            "azure-openai-responses-v1",
            "xai-responses-v1",
            "anthropic-claude-v1",
            "google-gemini-v1"
          ],
          "description": "The format of the reasoning information."
        },
        "index": {
          "type": "integer",
          "description": "The position of this entry in the output. Usually 0."
        },
        "type": {
          "type": "string",
          "enum": [
            "reasoning.text",
            "reasoning.summary",
            "reasoning.encrypted"
          ],
          "description": "The kind of reasoning information."
        },
        "text": {
          "type": "string",
          "description": "Reasoning text. Present only when `type` is `reasoning.text`."
        },
        "summary": {
          "type": "string",
          "description": "Reasoning summary. Present only when `type` is `reasoning.summary`."
        },
        "data": {
          "type": "string",
          "description": "Encrypted reasoning. Present only when `type` is `reasoning.encrypted`."
        }
      }
    },
    "ChatToolCall": {
      "type": "object",
      "required": [
        "id",
        "type",
        "function"
      ],
      "description": "A custom function call generated by the model.",
      "properties": {
        "index": {
          "type": "integer",
          "description": "The index of this tool call in the array."
        },
        "id": {
          "type": "string",
          "description": "A unique identifier for this tool call. Referenced by the corresponding `tool` message's `tool_call_id`."
        },
        "type": {
          "type": "string",
          "enum": [
            "function"
          ],
          "description": "The type of tool call. Always `function`."
        },
        "function": {
          "$ref": "#/$defs/ChatToolCallFunction"
        }
      }
    },
    "ChatToolCallFunction": {
      "type": "object",
      "required": [
        "name",
        "arguments"
      ],
      "description": "The function invocation details within a tool call.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the function to call."
        },
        "arguments": {
          "type": "string",
          "description": "The arguments to the function, as a JSON string generated by the model."
        }
      }
    },
    "SearchResult": {
      "type": "object",
      "description": "A single search result.",
      "properties": {
        "title": {
          "type": "string",
          "description": "The title of the result page."
        },
        "url": {
          "type": "string",
          "description": "The URL of the result page."
        },
        "highlight": {
          "type": "string",
          "description": "Query-relevant highlight snippets. Returned only if highlight.enable is true."
        },
        "full_content": {
          "type": "string",
          "description": "Full raw page content. Returned only if full_content.enable is true."
        },
        "authors": {
          "type": "string",
          "description": "Website name or author."
        },
        "time_published": {
          "type": "string",
          "format": "date-time",
          "description": "Publish time in ISO 8601."
        },
        "time_last_crawled": {
          "type": "string",
          "format": "date-time",
          "description": "Last crawl time in ISO 8601."
        },
        "favicon": {
          "type": "string",
          "description": "The favicon URL of the result site."
        },
        "cover_image": {
          "type": "object",
          "description": "The page cover image. Returned only when `include_images` is true and the page has a cover image.",
          "properties": {
            "url": {
              "type": "string",
              "description": "The cover image URL."
            },
            "description": {
              "type": "string",
              "description": "Text description of the cover image."
            }
          }
        },
        "images": {
          "type": "array",
          "description": "In-body images of the page, in order of appearance. Returned only when `include_images` is true.",
          "items": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "description": "The image URL."
              },
              "description": {
                "type": "string",
                "description": "Text description of the image."
              }
            }
          }
        }
      }
    },
    "SearchResultGroup": {
      "type": "object",
      "description": "A group of search results for a single sub-query.",
      "properties": {
        "query": {
          "type": "string",
          "description": "The sub-query that produced these results."
        },
        "results": {
          "type": "array",
          "description": "The search results for this sub-query.",
          "items": {
            "$ref": "#/$defs/SearchResult"
          }
        },
        "latency": {
          "type": "integer",
          "description": "Search latency for this query in milliseconds."
        }
      }
    },
    "SynthesisUsage": {
      "type": "object",
      "description": "Token usage information for the Answer response. When `stream=true`, this is only present in the `usage` type chunk.",
      "required": [
        "num_search_queries",
        "prompt_tokens",
        "completion_tokens",
        "total_tokens"
      ],
      "properties": {
        "num_search_queries": {
          "type": "integer",
          "description": "Total number of search queries executed across all sub-queries."
        },
        "prompt_tokens": {
          "type": "integer",
          "description": "Number of input tokens."
        },
        "completion_tokens": {
          "type": "integer",
          "description": "Number of output tokens."
        },
        "total_tokens": {
          "type": "integer",
          "description": "Total tokens used (prompt_tokens + completion_tokens)."
        }
      }
    }
  }
}