--- id: dspy version: "3.3.0" license: MIT License Copyright (c) 2023 Stanford Future Data Systems Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) license_treatment: permissive maintenance: active --- # dspy — DSPy License: permissive · Maintenance: active · Downloads: 6.4M/mo ## What it is and what it does DSPy is a framework for composing language model systems as Python code rather than writing and tweaking prompts manually. It treats language model calls as declarative building blocks that can be combined into modular pipelines—from simple classifiers to complex retrieval-augmented generation (RAG) systems and agent loops. The core innovation is that DSPy includes algorithms to automatically optimize both the prompts and weights of these systems, teaching models to produce higher-quality outputs without hand-crafting every prompt. The framework depends on a suite of utilities: openai and litellm for LLM access, pydantic for data validation, requests and anyio for HTTP operations, tenacity for retry logic, diskcache for caching, and several text-processing libraries (regex, orjson, json-repair) for robustness. It's actively maintained and has substantial adoption, with no known security vulnerabilities. Use it for: - Build modular RAG pipelines where retrieval and generation steps are composed as Python functions and automatically optimized. - Create multi-stage language model programs where prompts and in-context examples are learned from data rather than hand-written. - Develop agent loops with self-refining constraints that enforce output quality and correctness. - Optimize classifier systems by letting DSPy tune prompts and demonstrations for your specific task and data. - Experiment rapidly with different LLM architectures and providers without rewriting prompt logic. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. DSPy is a framework for building and optimizing modular language model systems through Python code rather than manual prompt engineering, with built-in algorithms for teaching models to produce high-quality outputs. Yes. DSPy is actively maintained, has no security vulnerabilities, uses a permissive MIT license, and offers low install friction. It's well-suited for teams building production language model systems who want to move beyond manual prompt engineering. Start with it if you're composing multiple LLM calls into a pipeline or need systematic prompt optimization; skip it if you're only making single, one-off LLM requests. ## Install pip install dspy uv add dspy poetry add dspy ## Installing dspy Before you install: Low install friction with a pure Python wheel. Active maintenance with a recent release and strong community signal (37189 GitHub stars). Requires Python 3.10 or later but supports current versions. License in practice: MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects. Quickstart: pip install dspy import dspy # Create a simple DSPy module class SimpleQA(dspy.ChainOfThought): pass qa = SimpleQA() Requires Python 3.10 or later. Most functionality depends on configuring an LLM provider (e.g., via openai or litellm dependencies). Verify before relying: - Whether the framework's optimization algorithms work equally well across different LLM providers or have provider-specific limitations. - Performance characteristics and scalability limits for large-scale RAG pipelines or agent loops. - Compatibility and integration details with specific retrieval backends or vector stores. ## Package facts - License: MIT License Copyright (c) 2023 Stanford Future Data Systems Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 6.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags language model framework programming, prompt optimization automation, LLM pipeline composition, declarative AI system building, language model compiler, RAG pipeline framework, LLM weight and prompt optimization, llm-framework, prompt-optimization, rag-systems [View on SkillFed](https://skillfed.io/packages/dspy) · [View on PyPI](https://pypi.org/project/dspy/)