Cookbook
Hands-on, runnable recipes for building healthcare AI applications with HealthChain.
Getting started
Cookbooks are runnable scripts in the HealthChain repository. Clone the repo to get started:
git clone https://github.com/healthchainai/HealthChain.git
cd HealthChain
uv sync --all-extras # or: pip install healthchain
Each cookbook page states the exact pip install line it needs — optional capabilities live in extras ([cda], [examples], [sandbox], ...), so you only install what the example uses.
Run any cookbook from the repo root — e.g. python cookbook/ml_risk_to_fhir.py. Filter by Zero Setup below to find examples that run immediately with no external accounts.
From cookbook to service
Cookbooks are standalone scripts — run them directly to explore and experiment. When you're ready to build a proper service, scaffold a project and move your logic in:
# 1. Run a cookbook locally
python cookbook/cds_discharge_summarizer_hf_trf.py
# 2. Scaffold a project
healthchain new my-cds-service -t cds-hooks
cd my-cds-service
# 3. Move your hook logic into app.py, then run with config
healthchain serve
app.run() (used in cookbooks) is a convenience wrapper — equivalent to running uvicorn directly. healthchain serve reads healthchain.yaml for port, TLS, and deployment settings, and prints a startup banner so you can see what's active at a glance.
What moves from your script into healthchain.yaml:
# cookbook — everything hardcoded in Python
gateway = FHIRGateway()
gateway.add_source("medplum", FHIRAuthConfig.from_env("MEDPLUM").to_connection_string())
llm = ChatAnthropic(model="claude-opus-4-8", max_tokens=512)
app = HealthChainAPI(title="My App", service_type="fhir-gateway")
app.run(port=8000)
# healthchain.yaml — port, sources, and LLM provider declared here
service:
type: fhir-gateway
port: 8000
sources:
medplum:
env_prefix: MEDPLUM # credentials stay in .env
llm:
provider: anthropic
model: claude-opus-4-8
max_tokens: 512
# app.py — load from config instead
from langchain.chat_models import init_chat_model
from healthchain.config.appconfig import AppConfig
from healthchain.gateway import FHIRGateway, HealthChainAPI
config = AppConfig.load()
gateway = FHIRGateway.from_config(config)
llm = init_chat_model(f"{config.llm.provider}:{config.llm.model}")
app = HealthChainAPI(title="My App")
Credentials (API keys, client secrets) always stay in .env — never in healthchain.yaml.
Configuration reference
See the configuration reference for all available settings — security, compliance, and more.