---
id: think
title: "Think and generate answer"
description: "Think and formulate an answer using agent identity, world facts, and opinions."
sidebar_label: "Think and generate answer"
hide_title: true
hide_table_of_contents: true
api: eJztWG1v4zYS/isD9sO1gfy6SXqnL4V3N9sLkO3uJW4L1BssJtJEYkORKknZ8Rn+74chJVtOmuwi6Ic74PzFNsV55u3hzFAb4bFwIl2IS0JntNSFuE5ETi6zsvbSaJGKeSn1HaDO4dbYqlHoCVADarciC42TugAsSHuQOWkv/TqBlbEqh1vMvEuCqKmllka74Sf9SQMAzEvpgHReG6l9GtcmQ7gkbyUtybWQAQK+DX/+5nYavosC075ATydYUrRE7cEb8CXBHw3ZdZR51Zehe+k8O9DZt1dVk3U1ZV4uybXqjofwsyMHFxfvGbgXDsiM9nTvG1RtYKLEyRDO7r0NNnEYnDeWfdNr0LTaa2UoyqPMaTCwsdpBrVBqYOAWNQneRB8bR3kMbh9KJMLUZJGTd56LVHhOn0hEjRYr8mQ53xuhsSKRiuDtZ5mLREhOdo2+FImw9EcjLeUi9bahRLispApFuhF+XbOc85bJkggvveKFWUjXeS622+soT86/NvmahR7ChWhpz4+wrpXMgrmj3x0TbtPTVlt2xkty/C9k8Tkj/hU2bJPotNTF55smL8j3ZKT2VJDtCc3bvfA67mX+32KjvEhPxtvW2PtorF5/uA3hO7Rgm+xWdKOU4BB08G9a8S2bFfeYm98p8wdhXrTOXT+w6zIGUjw8lO06VCYnxfSB4PLuRA1FIugeq5qhNnsfRDh3MjAOECw5QpuVUGNNFoyG2TmQL2XGRGrjLX4t0UNuYG2aVg3emMYDWi9vZSZRAYdVKVmQzugH8ScJOBlv+cM+u9poFzM6HY/569C3qybLyLnbRsFlu1m8mDNd6p6izDzkJhE36Cj/HLGkp8o9hpL5SznAxyL5alPi85dpmvP6X0jaRNCSK0SO/sU2nTECvGWELx2CoPThGXiH2eMDMAtVMBRB4BoZaNlx60n2l4TKlxlagly6rHGO0Q6dFNPx9HgwngwmJ/PJOH01Tsfj37g+cjWdTF/R8cnp9wP6+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D0leKgdnGWC4mw/FwzEtcOSvUPV37lxhFR93I14c1Z7Pvmf9/8/G/9uaj7bYsNgoITIbArE3bRhcCaykSsZyIJE53LJf2XoPEbnqdiJLbb7oQmw1XtJ+t2m55ue2Ki+tELNFKvOFWttiIXDr+nYv0FpWjZ2j17WU7cXwHT9ncDRaax4olqob/iUTc0br/0ibMUiVhTjbYEB+/iZoGYeLZiz8aAHk4ixKzLKPaP7v3ujeYfPxwNReJuGnf7vBcL1JhccXTFK6iqSZ4HqbDsLYRXesSqYiY/PkPrl8Qiw==
sidebar_class_name: "post api-method"
info_path: docs/api-reference/endpoints/agent-memory-api
custom_edit_url: null
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Think and generate answer"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/api/v1/agents/{agent_id}/think"}
  context={"endpoint"}
>
  
</MethodEndpoint>



Think and formulate an answer using agent identity, world facts, and opinions.

    This endpoint:
    1. Retrieves agent facts (agent's identity)
    2. Retrieves world facts relevant to the query
    3. Retrieves existing opinions (agent's perspectives)
    4. Uses LLM to formulate a contextual answer
    5. Extracts and stores any new opinions formed
    6. Returns plain text answer, the facts used, and new opinions

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
  children={"Request"}
>
</Heading>

<ParamsDetails
  parameters={[{"name":"agent_id","in":"path","required":true,"schema":{"type":"string","title":"Agent Id"}}]}
>
  
</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"required":true,"content":{"application/json":{"schema":{"properties":{"query":{"type":"string","title":"Query"},"thinking_budget":{"type":"integer","title":"Thinking Budget","default":50},"context":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Context"}},"type":"object","required":["query"],"title":"ThinkRequest","description":"Request model for think endpoint.","example":{"context":"This is for a research paper on AI ethics","query":"What do you think about artificial intelligence?","thinking_budget":50}}}}}}
>
  
</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"properties":{"text":{"type":"string","title":"Text"},"based_on":{"items":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"text":{"type":"string","title":"Text"},"type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"},"context":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Context"},"event_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Event Date"}},"type":"object","required":["text"],"title":"ThinkFact","description":"A fact used in think response.","example":{"context":"healthcare discussion","event_date":"2024-01-15T10:30:00Z","id":"123e4567-e89b-12d3-a456-426614174000","text":"AI is used in healthcare","type":"world"}},"type":"array","title":"Based On","default":[]},"new_opinions":{"items":{"type":"string"},"type":"array","title":"New Opinions","default":[]}},"type":"object","required":["text"],"title":"ThinkResponse","description":"Response model for think endpoint.","example":{"based_on":[{"id":"123","text":"AI is used in healthcare","type":"world"},{"id":"456","text":"I discussed AI applications last week","type":"agent"}],"new_opinions":["AI has great potential when used responsibly"],"text":"Based on my understanding, AI is a transformative technology..."}}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"properties":{"detail":{"items":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"}}}}}}
>
  
</StatusCodes>


      