DSPy Profiles
A companion tool for the DSPy framework to manage configuration profiles, inspired by the AWS CLI and Databricks.
dspy-profiles allows you to define, switch between, and manage different DSPy configurations for various environments (e.g., development, staging, production) without cluttering your code.
📘 Read the full documentation at nielsgl.github.io/dspy-profiles for installation, tutorials, CLI reference, and examples.
Requirements
- Python 3.12+
- DSPy 3.0+ (installed alongside your project)
The Problem
When working with DSPy, you often need to switch between different language models, retrieval models, and settings. Managing this directly in your code can be messy, error-prone, and insecure.
The Solution
dspy-profiles moves this configuration out of your code and into a simple profiles.toml file. It provides a powerful CLI and a clean Python API to manage and use these profiles seamlessly. The tool will automatically find your profiles.toml whether it's in your local project directory or in the global ~/.dspy/ folder.
Key Features
- Declarative Profiles: Define all your environment settings in a clear, human-readable TOML file.
- Powerful CLI: A rich command-line interface lets you manage your profiles without ever leaving the terminal.
- Seamless Python API: Activate profiles in your Python code with an elegant and intuitive API.
- Profile Inheritance: Create base profiles and extend them for different environments to avoid repetition.
- Environment Precedence: A clear and predictable activation logic ensures the right profile is always used.
- Validation & Testing:
validateandtestcommands to ensure your profiles are correct and your models are reachable.
Installation
# With pip
pip install dspy-profiles
# With uv
uv add dspy-profiles
# Or run it directly without installation
uvx dspy-profiles --help
# Or as a tool in your cli
uv tool install dspy-profiles
dspy-profiles --help
Quickstart
-
Initialize a default profile interactively:
dspy-profiles initThis will prompt you for your language model and optionally your API key and API base.
-
Use it in your Python code:
import dspy from dspy_profiles import profile with profile("default"): # Your DSPy code here, now using the settings from your 'default' profile. predictor = dspy.Predict("question -> answer") response = predictor(question="What is the capital of France?") print(response.answer)
-
Run any script with a profile, without changing your code:
# The new, convenient way to run any script with a profile dspy-run my_script.py # Specify a different profile, or run non-python commands dspy-run --profile production -- pytest
Documentation
The documentation site contains tutorials, API/CLI references, examples, and release notes: https://nielsgl.github.io/dspy-profiles/
Quick links:
- CLI overview: https://nielsgl.github.io/dspy-profiles/cli-reference/
dspy-runcommand: https://nielsgl.github.io/dspy-profiles/cli-run-reference/- Configuration reference: https://nielsgl.github.io/dspy-profiles/config-reference/
- CI & testing guide: https://nielsgl.github.io/dspy-profiles/ci-testing/
- Project roadmap: ROADMAP.md
- Release notes: CHANGELOG.md
Project Status & Roadmap
The project is under active development. All core features are implemented and stable.
- [x] Phase 1: DX, Packaging & Documentation: Professional PyPI packaging, CI/CD, and a full documentation site.
- [x] Phase 2: Core CLI & Env Var Enhancements:
import,diff,run, and robust activation precedence. - [x] Phase 3: Advanced Profile Features: Profile composition (
extends), inline overrides, andvalidate/testcommands. - [x] Phase 4: Python API & Runtime Utilities: Programmatic shortcuts like
lm()and runtime introspection withcurrent_profile(). - [x] Phase 5: Developer Experience Overhaul: A major refactor of the CLI, API, and documentation for clarity, stability, and ease of use.
- [x] Phase 6: QoL & Advanced Workflows: An interactive
initwizard, profile import/export, and async-friendly decorators.
See the Project Overview for detailed specifications.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Metadata
Release files for dspy-profiles 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dspy_profiles-0.4.0.tar.gz | 18.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dspy_profiles-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.8 kB
Release files / dspy_profiles-0.4.0.tar.gz
| Download URL | dspy_profiles-0.4.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad5fb0fbd9601c6d78f80dcbc271f26b5fabbfda90b324fa773d3cf48240b4f1
|
|
BLAKE2b-256 checksum How to use checksums |
6de2472e3adf7ac68e5f8ddf151f1c8f269ca5e7a16145c2290292d9d61f80c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2025.
Transparency logRelease files / dspy_profiles-0.4.0-py3-none-any.whl
| Download URL | dspy_profiles-0.4.0-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
704d61edc3cc0b679a474bb9596d0f59a0a2148e9aecdf97a259847a37340f2b
|
|
BLAKE2b-256 checksum How to use checksums |
ec57df4f7b13cad09a149fcf26f09e9ed74936206b9f2f8d69da1597faad1a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2025.
Transparency logSecurity for dspy-profiles 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for dspy_profiles-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 23, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.