Builders · library

Build your own sustainability tool on the report-analyst library

Building your own sustainability tool? Use Open Sustainability Analyst as a library: keep your interface and workflow, get grounded report answers (evidence + gaps), and ship faster than rebuilding retrieval and prompting yourself.

Product shape

Two products, one engine

Open Sustainability Analyst ships a Streamlit analyst UI — and the same engine as a library so you can keep your own screens, workflows, and brand.

  1. Standalone analyst tool

    Deploy the Streamlit app when your team wants report analysis out of the box. Guides: Render · Streamlit Cloud.
  2. Library inside your product

    Import report_analyst.core.library (or call the REST API) when procurement, risk, or research needs a custom interface but still wants answers grounded in report evidence — not uncited chat.
  3. Same question sets either way

    Reuse built-in frameworks (TCFD, ESRS-oriented sets, …) or ship a tiny YAML for one topic. Customize YAML: framework guide.

Python

Call the library

Three calls cover the host-app pattern: resolve questions → analyze a PDF → build a brief from grounded rows.

  1. analyze_report → GroundedAnswer rows

    Each row carries answer, score, evidence, gaps, and sources — the same evidence contract the Streamlit UI shows.
    
                              from report_analyst.core.library import analyze_report, build_topic_brief
    
    answers = await analyze_report(
        "supplier-report.pdf",
        "examples/grounded_topic_brief/questions/water_risk_questions.yaml",
    )
    brief = build_topic_brief(answers, topic="Supplier water-risk brief")
    # brief["findings"] → answer + evidence + gaps for your UI
                            

    Source: report_analyst/core/library.py. Sync scripts can use analyze_report_sync.

  2. Pass a set id or your own YAML

    Use a built-in id ("tcfd") or a path to *_questions.yaml. The water-risk demo ships a three-question supplier screen in the example folder.
  3. Prefer HTTP? Use the API module

    report_analyst_api/ wraps the same analyzer over REST. In-process import is best when the host app already runs Python; the API fits microservices.

Demo app

Custom UI: one report, one topic, then use the data

The grounded topic-brief example is a small custom host app: analyze one PDF for water risk, show a readable brief, and expose grounded JSON for the rest of your product.

  1. What the demo does

    1. Upload one sustainability report in a custom page.
    2. Run the water-risk question set via the library.
    3. Show evidence-backed answers.
    4. Build a structured brief (GET /brief) your product can store or render.
  2. Run it locally

    Clone climateandtech/report-analyst, install core deps, then:
    
                              pip install -r requirements.txt fastapi uvicorn python-multipart
    export OPENAI_API_KEY=…   # or GOOGLE_API_KEY
    cd examples/grounded_topic_brief
    python app.py
    # open http://127.0.0.1:8765
                            
  3. Swap the topic

    Replace questions/water_risk_questions.yaml with your own ids/texts/guidelines (net-zero, human rights, biodiversity, …). Keep the host UI; change only the question set.

FAQ

When should I use the ready-made app vs the library?
Use the ready-made OSA app when analysts want frameworks out of the box. Use the library when you are building your product UI and want OSA’s grounded analysis underneath — usually the faster path than starting from a blank LLM stack.
Do I still need an LLM API key?
Yes — same as the Streamlit app. Set OPENAI_API_KEY or GOOGLE_API_KEY in the host process environment.
Can I use only the REST API?
Yes. Deploy report_analyst_api/ and keep a thin frontend. The library module is for in-process Python hosts that want typed grounded rows without an HTTP hop.

Need a walkthrough for your stack? Book a short setup chat.