Practical overview
When it fits
Use it when a task benefits from generating and comparing multiple partial solutions instead of relying on a single model response.
Who it is for
- Python developers building LLM applications
- AI engineers experimenting with prompt-based reasoning
- Developers prototyping branching search and deliberate problem solving
Documented uses
- Add multi-step reasoning to an LLM application
- Explore several candidate reasoning paths
- Evaluate and prune partial solutions
- Retain the selected reasoning path and search metrics
Requirements & limits
The repository is public and licensed under Apache-2.0. The documented implementation uses Python 3.10+ and the Swarms package; model use requires a function-calling provider and an API key.
- Whether the selected model supports function calling
- Whether the task can define a useful thought description and evaluation criterion
- Whether breadth-first search or depth-first search better fits the task
- How candidate count, search depth and evaluation samples affect model-call volume
- Whether retaining tree and usage data is useful for evaluation
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Swarms and configure TreeOfThoughts
Prepare the documented Python implementation for Tree of Thoughts use.
Before you start
- Python 3.10 or later.
- The
swarmspackage. - A model that supports function calling through LiteLLM.
- An API key stored in a
.envfile in the working directory.
Steps
Install or upgrade Swarms with the command below.
pip3 install -U swarmsCreate a
.envfile containing an appropriate provider API key, such asOPENAI_API_KEY, and setWORKSPACE_DIRas shown in the README.Import
TreeOfThoughtsfromswarmsand configure its model, search algorithm, depth, thought description, and evaluation criteria.
Expected outcome
The documented TreeOfThoughts component is configured and ready for a task.
Guide limitations
- The model must support function calling.
- The documentation does not establish compatibility for models beyond those supported by LiteLLM.
- This recipe documents setup and configuration, not successful execution.
Run a TreeOfThoughts task and inspect its result
Execute the documented TreeOfThoughts quickstart and inspect the returned answer and search metadata.
Before you start
- Swarms is installed and configured as documented.
- A function-calling model and corresponding API key are available.
- A configured
TreeOfThoughtsinstance.
Steps
Create a
TreeOfThoughtsinstance with a model name, search algorithm, maximum depth, thought description, and evaluation criteria.Call
agent.run(task)with the problem statement.Print the returned answer.
Read
agent.last_resultto inspect the best reasoning steps, solved status, expanded nodes, model-call count, token usage, or the serialized tree.
Expected outcome
The task returns an answer, while `agent.last_result` exposes the documented search result and metadata.
Guide limitations
- The README does not guarantee that every task will be solved.
- Search cost grows with
num_thoughts,breadth,max_depth, andn_evaluate_samples;max_expansionscan bound expansion. - The model must support function calling.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 30 September 2026
- Original website title
- kyegomez/tree-of-thoughts · Official homepage title · retained in its source language

