dspy 3.1.3


pip install dspy

  Latest version

Released: Feb 05, 2026

Project Links

Meta
Author: Omar Khattab
Requires Python: <3.15,>=3.10

Classifiers

Development Status
  • 3 - Alpha

Intended Audience
  • Science/Research

Operating System
  • POSIX :: Linux

Programming Language
  • Python :: 3

DSPy: Programming—not prompting—Foundation Models

Documentation: DSPy Docs

PyPI Downloads


DSPy is the framework for programming—rather than prompting—language models. It allows you to iterate fast on building modular AI systems and offers algorithms for optimizing their prompts and weights, whether you're building simple classifiers, sophisticated RAG pipelines, or Agent loops.

DSPy stands for Declarative Self-improving Python. Instead of brittle prompts, you write compositional Python code and use DSPy to teach your LM to deliver high-quality outputs. Learn more via our official documentation site or meet the community, seek help, or start contributing via this GitHub repo and our Discord server.

Documentation: dspy.ai

Please go to the DSPy Docs at dspy.ai

Installation

pip install dspy

To install the very latest from main:

pip install git+https://github.com/stanfordnlp/dspy.git

📜 Citation & Reading More

If you're looking to understand the framework, please go to the DSPy Docs at dspy.ai.

If you're looking to understand the underlying research, this is a set of our papers:

[Jul'25] GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning
[Jun'24] Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
[Oct'23] DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
[Jul'24] Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together
[Jun'24] Prompts as Auto-Optimized Training Hyperparameters
[Feb'24] Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models
[Jan'24] In-Context Learning for Extreme Multi-Label Classification
[Dec'23] DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines
[Dec'22] Demonstrate-Search-Predict: Composing Retrieval & Language Models for Knowledge-Intensive NLP

To stay up to date or learn more, follow @DSPyOSS on Twitter or the DSPy page on LinkedIn.

The DSPy logo is designed by Chuyi Zhang.

If you use DSPy or DSP in a research paper, please cite our work as follows:

@inproceedings{khattab2024dspy,
  title={DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines},
  author={Khattab, Omar and Singhvi, Arnav and Maheshwari, Paridhi and Zhang, Zhiyuan and Santhanam, Keshav and Vardhamanan, Sri and Haq, Saiful and Sharma, Ashutosh and Joshi, Thomas T. and Moazam, Hanna and Miller, Heather and Zaharia, Matei and Potts, Christopher},
  journal={The Twelfth International Conference on Learning Representations},
  year={2024}
}
@article{khattab2022demonstrate,
  title={Demonstrate-Search-Predict: Composing Retrieval and Language Models for Knowledge-Intensive {NLP}},
  author={Khattab, Omar and Santhanam, Keshav and Li, Xiang Lisa and Hall, David and Liang, Percy and Potts, Christopher and Zaharia, Matei},
  journal={arXiv preprint arXiv:2212.14024},
  year={2022}
}
3.1.3 Feb 05, 2026
3.1.2 Jan 19, 2026
3.1.0 Jan 06, 2026
3.1.0b1 Nov 18, 2025
3.0.4 Nov 10, 2025
3.0.4b2 Oct 21, 2025
3.0.4b1 Sep 29, 2025
3.0.3 Aug 31, 2025
3.0.2 Aug 22, 2025
3.0.1 Aug 14, 2025
3.0.0 Aug 12, 2025
3.0.0b4 Aug 11, 2025
3.0.0b3 Jul 19, 2025
3.0.0b2 Jul 01, 2025
3.0.0b1 Jun 11, 2025
2.6.27 Jun 03, 2025
2.6.27a1 Jun 03, 2025
2.6.26 Jun 03, 2025
2.6.25 Jun 02, 2025
2.6.24 May 17, 2025
2.6.23 May 05, 2025
2.6.22 Apr 30, 2025
2.6.21 Apr 28, 2025
2.6.20 Apr 28, 2025
2.6.19 Apr 24, 2025
2.6.18 Apr 18, 2025
2.6.17 Apr 08, 2025
2.6.16 Mar 28, 2025
2.6.15 Mar 24, 2025
2.6.14 Mar 21, 2025
2.6.13 Mar 19, 2025
2.6.12 Mar 13, 2025
2.6.11 Mar 10, 2025
2.6.10 Mar 04, 2025
2.6.9 Mar 03, 2025
2.6.9rc1 Feb 27, 2025
2.6.8 Feb 27, 2025
2.6.7 Feb 27, 2025
2.6.6 Feb 24, 2025
2.6.5 Feb 20, 2025
2.6.4 Feb 18, 2025
2.6.3 Feb 13, 2025
2.6.2 Feb 03, 2025
2.6.1 Feb 03, 2025
2.6.0 Jan 30, 2025
2.6.0rc11 Jan 30, 2025
2.6.0rc8 Jan 01, 2025
2.6.0rc7 Dec 25, 2024
2.6.0rc6 Dec 22, 2024
2.6.0rc5 Dec 22, 2024
2.6.0rc4 Dec 18, 2024
2.6.0rc3 Dec 17, 2024
2.6.0rc2 Dec 13, 2024
2.6.0rc1 Dec 13, 2024
2.5.43 Dec 13, 2024
2.5.42 Dec 10, 2024
2.5.41 Nov 29, 2024
2.5.40 Nov 26, 2024
2.5.39 Nov 24, 2024
2.5.38 Nov 24, 2024
2.5.37 Nov 24, 2024
2.5.36 Nov 24, 2024
2.5.35 Nov 24, 2024
2.5.34 Nov 22, 2024
2.5.33 Nov 22, 2024
2.5.32 Nov 19, 2024
2.5.31 Nov 17, 2024
2.5.30 Nov 16, 2024
2.5.29 Nov 08, 2024
2.5.28 Nov 07, 2024
2.5.27 Nov 06, 2024
2.5.26 Nov 06, 2024
2.5.25 Nov 04, 2024
2.5.24 Nov 04, 2024
2.5.23 Nov 03, 2024
2.5.22 Nov 01, 2024
2.5.21 Oct 30, 2024
2.5.20 Oct 29, 2024
2.5.19 Oct 29, 2024
2.5.18 Oct 27, 2024
2.5.17 Oct 26, 2024
2.5.16 Oct 24, 2024
2.5.15 Oct 21, 2024
2.5.14 Oct 20, 2024
2.5.13 Oct 20, 2024
2.5.12 Oct 16, 2024
2.5.11 Oct 16, 2024
2.5.10 Oct 16, 2024
2.5.9 Oct 15, 2024
2.5.8 Oct 15, 2024
2.5.7 Oct 12, 2024
2.5.6 Oct 08, 2024
2.5.5 Oct 08, 2024
2.5.4 Oct 08, 2024
2.5.3 Oct 01, 2024
2.5.2 Sep 28, 2024
2.5.1 Sep 28, 2024
0.1.5 Apr 23, 2024
0.1.4 Apr 14, 2024
0.1.3 Apr 14, 2024
0.0.3 Apr 14, 2024
0.0.2 Apr 14, 2024
0.0.1 Apr 14, 2024

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
openai (>=0.28.1)
regex (>=2023.10.3)
orjson (>=3.9.0)
tqdm (>=4.66.1)
requests (>=2.31.0)
optuna (>=3.4.0)
pydantic (>=2.0)
litellm (>=1.64.0)
diskcache (>=5.6.0)
json-repair (>=0.54.2)
tenacity (>=8.2.3)
anyio
asyncer (==0.0.8)
cachetools (>=5.5.0)
cloudpickle (>=3.0.0)
numpy (>=1.26.0)
xxhash (>=3.5.0)
gepa[dspy] (==0.0.26)