Tree of Thoughts is an open-source, plug-and-play implementation of the Tree of Thoughts (ToT) prompting framework from the Princeton and DeepMind paper. Instead of generating one linear chain of reasoning, it lets a language model explore multiple reasoning paths, evaluate them, and search for the best one.
Chain-of-thought prompting commits to a single line of reasoning, which fails on problems that need exploration, backtracking or lookahead. Tree of Thoughts generalizes it into a search problem: the model generates candidate thought steps, those candidates are scored by value estimation or voting, and breadth-first or depth-first search with pruning and backtracking explores the tree. The approach produced the paper’s headline result on the Game of 24 puzzle, where GPT-4 with ToT solved 74% of games versus 4% for plain chain-of-thought. This implementation, maintained as part of the Swarms ecosystem, packages the technique as a reusable component that works with any function-calling-capable model through LiteLLM, so it is not tied to a single provider. The repository includes examples for tasks such as Game of 24 and creative writing, making it a practical starting point for comparing search strategies on your own problems. It is Apache-2.0 licensed, has more than 4,500 stars on GitHub, and was still receiving updates in 2026.
Free. Tree of Thoughts is open source under the Apache-2.0 license; you only pay for the model API calls your searches make.
Researchers and agent builders tackling planning, puzzles, math and other search-heavy problems where a single reasoning chain is unreliable, and anyone who wants to experiment with deliberate, tree-search reasoning on top of existing models.