Prerequisites
Before you begin, prepare:- a trusted server runtime and application authentication boundary;
- a disposable personal workspace Praxa key with only the tutorial’s required scopes;
- synthetic input plus a persisted application request ID for replay tests;
- a fake upstream for unit tests and a non-production environment for canaries;
- an acceptance assertion that proves the FastAPI dependency boundary admits one task and maps failures without leaking upstream data.
1. Install dependencies
2. Implement the route
app/main.py
require_user, not the body. Do
not include the upstream response text in a production exception unless you
have explicitly redacted it.
3. Test with dependency overrides
tests/test_tasks.py
401 and prove
there is no upstream call.
4. Run the live acceptance check
requestId. Require the same logical run, then poll that run to a
terminal state. Revoke the test key after cleanup.
Troubleshooting
Best practices
- Create one
AsyncClientat application startup and close it at shutdown. - Resolve the user with a dependency before calling Praxa.
- Bound Pydantic models and request-body size.
- Do not include tenant, owner, scope, or Praxa key in the request model.
- Keep error details redacted and responses
no-store. - Use HTTPX
MockTransportfor unit tests and disposable keys for canaries.
FastAPI testing
Use the official TestClient and pytest guidance for the application boundary.
Optimize for production
- Reuse one configured HTTP or SDK client per process and bound concurrent upstream work.
- Prefer durable admission plus asynchronous readback over holding application requests open.
- Cache only non-sensitive, tenant-scoped reads within their documented freshness window.
- Measure p50/p95 latency, admission-to-terminal time, retries, conflicts, and connection reuse before tuning.
Cleanup and next steps
- Revoke the disposable Praxa key and require a later request to fail.
- Remove synthetic application records and any temporary environment files.
- Cancel or archive unresolved test runs according to the application policy.
- Retain only redacted request, run, and verification identifiers needed for the test record.