casadi
CasADi -- framework for algorithmic differentiation and numeric optimization
What it is and what it does
CasADi is a symbolic computation and optimization framework written in C++ with Python bindings. It provides automatic differentiation, allowing you to define optimization problems symbolically and have gradients computed automatically. The package is designed for researchers and engineers working on nonlinear optimization, optimal control, and algorithmic differentiation tasks where you need to compute derivatives efficiently without hand-coding them.
The framework depends only on numpy at runtime and offers prebuilt wheels for Python 2.7 and 3.4–3.12 across macOS, Windows, and Linux. It has been in production use since 2017 and maintains active development. The copyleft license means that if you modify CasADi itself, those changes must remain open-source; using it unmodified in a proprietary application is permitted but may require review of your use case.
Use it for:
- Define and solve nonlinear optimization problems with automatic gradient computation
- Implement optimal control algorithms where symbolic differentiation reduces implementation burden
- Perform sensitivity analysis and parameter optimization in scientific computing workflows
- Build embedded optimization routines for real-time control systems
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CasADi is a framework for algorithmic differentiation and numeric optimization, providing symbolic computation and automatic differentiation capabilities for optimization problems.
Yes, if you need symbolic optimization with automatic differentiation. CasADi is actively maintained, has no known vulnerabilities, and offers broad platform support. The main consideration is the copyleft license: if you're building proprietary software, verify that using an unmodified library under LGPLv3+ aligns with your licensing strategy, or contact the maintainers about commercial options.
Install
casadi on PyPI
pip
pip install casadiuv
uv add casadipoetry
poetry add casadiInstalling casadi
Before you install
Medium install friction due to compiled C++ bindings, but prebuilt wheels are available for common Python versions (2.7, 3.10–3.12) and platforms (macOS, Windows, Linux). The project is actively maintained with a recent commit history and no known vulnerabilities.
License in practice
Licensed under LGPLv3+, a copyleft license requiring that derivative works and modifications remain open-source under the same license. Proprietary projects using CasADi must either comply with these terms or obtain a commercial license.
Quickstart
pip install casadi
import casadi as ca
import numpy as np
# Define a simple optimization variable
x = ca.SX.sym('x')
# Define objective and solve
objective = (x - 2)**2
solver = ca.nlpsol('solver', 'ipopt', {'x': x, 'f': objective})
result = solver(x0=0)
Requires a working C++ compiler or prebuilt wheel for your Python version and platform; wheels are provided for Python 2.7 and 3.4–3.12 on common architectures.
Verify before relying
- Whether CasADi's symbolic computation model is suitable for real-time or embedded optimization tasks
- Performance characteristics compared to other automatic differentiation frameworks for large-scale problems
- Availability of commercial licensing options for proprietary use
Package facts
| License | GNU Lesser General Public License v3 or later (LGPLv3+) (copyleft) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 338 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,536,190/month — #3,798 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: casadi-3.7.2-cp27-none-macosx_10_13_x86_64.macosx_10_13_intel.whl; casadi-3.7.2-cp27-none-manylinux1_i686.whl; casadi-3.7.2-cp27-none-manylinux2010_x86_64.whl; casadi-3.7.2-cp27-none-win_amd64.whl; casadi-3.7.2-cp310-none-macosx_10_13_x86_64.macosx_10_13_intel.whl; casadi-3.7.2-cp310-none-macosx_11_0_arm64.whl; casadi-3.7.2-cp310-none-manylinux2014_aarch64.whl; casadi-3.7.2-cp310-none-manylinux2014_i686.whl; casadi-3.7.2-cp310-none-manylinux2014_x86_64.whl; casadi-3.7.2-cp310-none-win_amd64.whl; casadi-3.7.2-cp311-none-macosx_10_13_x86_64.macosx_10_13_intel.whl; casadi-3.7.2-cp311-none-macosx_11_0_arm64.whl; casadi-3.7.2-cp311-none-manylinux2014_aarch64.whl; casadi-3.7.2-cp311-none-manylinux2014_i686.whl; casadi-3.7.2-cp311-none-manylinux2014_x86_64.whl; casadi-3.7.2-cp311-none-win_amd64.whl; casadi-3.7.2-cp312-none-macosx_10_13_x86_64.macosx_10_13_intel.whl; casadi-3.7.2-cp312-none-macosx_11_0_arm64.whl; casadi-3.7.2-cp312-none-manylinux2014_aarch64.whl; casadi-3.7.2-cp312-none-manylinux2014_i686.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
sparsediffpySparseDiffPy provides Python bindings to…
permissive · top 5,000 on PyPI
numdifftoolsComputes numerical derivatives, gradients,…
permissive · top 15,000 on PyPI
TheanoTheano is a Python library for defining,…
permissive · top 15,000 on PyPI
AeroSandboxAeroSandbox is an optimization toolkit for…
permissive · top 15,000 on PyPI
gekkoGEKKO is a Python package for optimization and…
permissive · top 15,000 on PyPI
dwave-optimizationFormulates nonlinear optimization models…
permissive · top 15,000 on PyPI
Theano-PyMCTheano-PyMC is an optimizing compiler for…
permissive · top 15,000 on PyPI
autogradAutograd automatically computes derivatives of…
permissive · top 5,000 on PyPI
pytensorPyTensor is a Python library for defining,…
permissive · top 5,000 on PyPI
symenginePython wrappers for SymEngine, a fast C++…
permissive · top 15,000 on PyPI