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 reusable HTTPX client admits and reconciles one task with bounded errors.
1. Install the client
2. Build a typed client
praxa_client.py
AsyncClient; do not create it in a hot loop. HTTPX enforces
timeouts by default, and explicit connect/overall values make your operational
contract clear.
3. Use it from a service
4. Test without the network
test_praxa_client.py
5. Verify end to end
- Submit one disposable task.
- Persist its request body digest, idempotency key, and run ID.
- Poll with
get_rununtilcompleted,failed, orcancelled. - Replay the exact task and require the same logical run.
- Revoke the key and require the next call to fail.
- Remove temporary files and preserve only the minimum redacted receipt.
Troubleshooting
Best practices
- Use Pydantic or an equivalent schema at your application boundary.
- Keep user and tenant authority out of the body.
- Reuse clients and bound connection pools.
- Record status/problem code, not raw sensitive bodies.
- Use FastAPI dependency injection for authenticated principals.
- Test with
MockTransportbefore a disposable staging canary.
FastAPI tutorial
Put the client behind a typed FastAPI route and dependency-based auth.
HTTPX timeouts
Review current connect, read, write, and pool timeout behavior.
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.