{"id":5251,"library":"httpstan","title":"httpstan","description":"httpstan provides an HTTP-based REST interface to Stan, a powerful package for Bayesian inference. It acts as a lightweight shim that allows clients to interact with the Stan C++ library using a REST API. Key features include automatic caching of compiled Stan models and samples, and parallel sampling. It is currently at version 4.13.0. While the primary maintainer is taking a hiatus, the project has historically seen releases roughly every few months, and automated processes attempt to build and publish new wheels every two days upon changes in the codebase.","status":"maintenance","version":"4.13.0","language":"en","source_language":"en","source_url":"https://github.com/stan-dev/httpstan","tags":["Bayesian inference","MCMC","Stan","HTTP API","statistical modeling","backend"],"install":[{"cmd":"pip install httpstan","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Runtime environment.","package":"python","version":">=3.10, <4.0"},{"reason":"Required for compiling Stan models; system-level dependency.","package":"C++ compiler","version":"gcc >=9.0 or clang >=10.0"}],"imports":[{"note":"httpstan is primarily designed to be run as a separate HTTP server process, not typically imported directly for user-facing functions within client Python code. Client applications (like PyStan) interact with it via its REST API. Internal modules such as `httpstan.models` or `httpstan.services` are used by client libraries, but rarely by end-users directly.","symbol":"httpstan module (as server)","correct":"python3 -m httpstan"}],"quickstart":{"code":"import os\nimport subprocess\nimport time\nimport requests\n\n# Ensure httpstan is running in the background\n# In a real application, you might use a more robust process management.\n# For this example, we assume it's already running or launched separately.\n# If not running, uncomment the subprocess call below and handle its lifecycle.\n# subprocess.Popen(['python3', '-m', 'httpstan'])\n# time.sleep(5) # Give the server a moment to start\n\n# Define a simple Stan program\nprogram_code = \"\"\"\nparameters {real y;} model {y ~ normal(0,1);}\n\"\"\"\n\n# Compile the Stan program\nresponse = requests.post(\n    'http://localhost:8080/v1/models',\n    json={'program_code': program_code}\n)\nresponse.raise_for_status()\nmodel_name = response.json()['name']\nprint(f\"Model compiled with name: {model_name}\")\n\n# Draw samples from the compiled model\nsample_response = requests.post(\n    f'http://localhost:8080/v1/{model_name}/actions',\n    json={'type': 'stan::services::sample::hmc_nuts_diag_e_adapt'}\n)\nsample_response.raise_for_status()\n\n# In a real scenario, you'd typically stream the results from the response.iter_lines()\n# For simplicity, this example just prints the first few lines of the output.\nprint(\"\\nFirst few lines of sampling output:\")\nfor line in sample_response.iter_lines():\n    print(line.decode('utf-8'))\n    # Break after a few lines for brevity in quickstart\n    if len(line) > 100: # Heuristic to get some actual output\n        break","lang":"python","description":"To use httpstan, first run it as a standalone server. Then, interact with its REST API using HTTP requests to compile Stan models and draw samples. This example demonstrates compiling a simple Stan program and initiating sampling using the `requests` library."},"warnings":[{"fix":"Ensure your system has an up-to-date C++ compiler. For Linux, this often means upgrading `build-essential`. For macOS, ensure Xcode command line tools are updated.","message":"httpstan requires a modern C++ compiler (gcc >=9.0 or clang >=10.0) on the system. Installing on environments with older compilers will lead to build failures or runtime errors with 'undefined symbol'.","severity":"breaking","affected_versions":"All versions >=3.0"},{"fix":"Use a Linux or macOS environment, or consider using Windows Subsystem for Linux (WSL), a virtual machine, or Docker.","message":"httpstan officially supports only Linux and macOS on x86-64 CPUs. Installation on Windows is not supported via PyPI wheels and will likely result in 'No matching distribution found' errors or complex build failures if attempting from source.","severity":"gotcha","affected_versions":"All versions"},{"fix":"First, upgrade `pip`: `python -m pip install --upgrade pip`. If the issue persists for a new Python version, check httpstan's GitHub releases or issues for announcements regarding wheel availability. Building from source might be an option if documented.","message":"Users may encounter 'No matching distribution found for httpstan' when trying to install, especially for newer Python versions or on specific platforms. This can be due to an outdated `pip` or delayed wheel availability for a specific Python version.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Monitor the Stan developer forums and GitHub repository for updates on project stewardship and maintenance plans. Be prepared for potentially slower response times or consider contributing to the project.","message":"The primary maintainer of httpstan has announced a hiatus from active maintenance starting September 2024. While the project is stable, this might impact the cadence of future updates, feature development, and responsiveness to issues unless new maintainers step forward.","severity":"deprecated","affected_versions":"4.x and future"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}