Tutorials
These tutorials are the public-alpha learning path. They use real provider packages by default and show how ReplayLab turns live interactions into local replay capsules and pytest provider replay guards.
The primary integration model is production-style startup instrumentation:
- initialize ReplayLab once near app startup with
auto_patch_integrations="auto" - keep normal provider client code
- wrap the request, job, or session body with
handle.capture(...) - use
replaylab replayandgenerate-testlater for local regression tooling
For ASGI web apps, the middleware can open the capture scope automatically at
the request boundary. The quickstart helper is replaylab.instrument_app(app, handle=handle);
direct ReplayLabASGIMiddleware registration remains available for teams that want explicit
framework configuration.
For background workers, the job decorator can open the capture scope automatically
at the job invocation boundary. It uses the same lifecycle primitive as
handle.capture(...) and the ASGI middleware.
For agent frameworks, start with provider-level compatibility scenarios before expecting native framework adapters. The PydanticAI and LangGraph tutorials show current validated behavior inside popular framework shapes while keeping ReplayLab framework-agnostic.
replaylab run is still useful for no-key dogfood examples, CI, local scripts, and generated tests, but it is not the production deployment model.
If you do not have provider credentials yet, use the deterministic no-network dogfood path in Quickstart. If you want the shortest PyPI-installed first project without provider credentials, start with First PyPI Project. If you want a polished customer-style walkthrough, use ReplayLab In 10 Minutes.
Recommended Order
- ReplayLab In 10 Minutes: run the customer demo loop with OpenAI and HTTP loopback providers, clean and failed viewers, report diff, and generated pytest.
- First PyPI Project: install
replaylab==0.1.0a4from PyPI and run the full loop with local HTTP and no keys. - OpenAI Responses: capture and replay OpenAI Responses calls, including fully consumed
responses.create(..., stream=True)streams. - Anthropic Messages: capture and replay Anthropic Messages calls, including fully consumed Messages streams.
- Gemini Generate Content: capture and replay Google Gen AI Gemini calls, including fully consumed
generate_content_stream(...)streams. - HTTP Capture And Replay: capture and replay a real HTTP request with
requestsfrom normal app startup. - ASGI/FastAPI Middleware: capture request-scoped provider work without adding
handle.capture(...)to each endpoint. - Worker Job Adapter: capture job-scoped provider work without adding
handle.capture(...)to each job body. - PydanticAI Compatibility: validate OpenAI Responses capture inside a PydanticAI Agent.
- LangGraph Compatibility: validate provider calls inside LangGraph nodes.
- LangChain ChatOpenAI Compatibility: validate ChatOpenAI calls routed through OpenAI Responses.
- Generate Pytest Regressions: turn a replayable capsule into a pytest test.
- Local React Viewer: open replay and diff results in a self-contained local viewer.
- AI-Assisted Diagnosis: explain replay reports and plan instrumentation from secret-safe summaries.
Matching Notebooks
The same tutorial flow is available as Jupyter notebooks:
examples/tutorials/openai_responses_capture_replay.ipynbexamples/tutorials/http_capture_replay.ipynbexamples/tutorials/generate_pytest_regression.ipynb
The notebooks are intentionally committed without outputs or execution counts. They are not executed in CI because they can use real provider credentials and network calls.