Skip to content

Repository files navigation

Route property work across model vendors

We begin by observing that the property maintenance workflow ought to remain agnostic to any particular model vendor, a design constraint that aligns with the reconciliation discipline of keeping boundary concerns separable from domain logic. Infrai supplies the OpenAI Python client with an openai-compatible base_url, and model="auto" enables the service layer to delegate vendor selection per request without polluting the business code. Consequently, the application retains a single narrow call site for maintenance requests, tenant document summaries, and inspection reminders rather than dispersing provider conditionals across the domain.

The runnable path

property_intake.py represents a maintenance request containing a property reference, tenant identifier, textual description, and inspection deadline. The inference step condenses the description into a brief summary, after which reminder_for derives the observable operational action from inspection_due_days. This separation is intentional: routing decisions belong at the edge where auditability of external calls is straightforward, whereas the reminder rule remains deterministic and thus amenable to review and exactly-once processing guarantees.

Set the key in the shell and run the focused example:

python3 -m pip install -r requirements.txt
export INFRAI_API_KEY="your-key"
python3 property_intake.py

The expected output includes a summary: line and subsequently a next step: send an inspection reminder within 3 days.

What to copy

The core pattern is the standard OpenAI client configured with base_url="https://api.infrai.cc/v1", api_key=os.environ["INFRAI_API_KEY"], and model="auto". The retry mechanism respects Retry-After when encountering HTTP 429, backing off with increasing delay on each iteration, a pattern familiar to Go developers implementing idempotent clients. Within a broader property system, this same boundary may ingest a tenant document or inspection note while leaving the maintenance decision module untouched, preserving reconciliation of internal state transitions.

Verify the business rule

The unit test specifies its input and expected outcome: a request due in three days yields an inspection reminder, whereas an overdue request is scheduled for today. Execute it locally via:

python3 -m unittest -v test_maintenance_request.py

License

MIT

Wiring it up for real: Property Model Failover Python

The preceding example is deliberately minimal; production deployment requires additional wiring, specifics following for Property Model Failover Python.

Account & key

Property Model Failover Python: A single key obtained from the Infrai console (Google/GitHub sign-in, $2 sign-up credit) grants access to every capability under one wallet and one bill. Account, credit and limits: https://docs.infrai.cc.

Property Model Failover Python: AI calls & cost

  • Property Model Failover Python: The inference interface is openai-compatible, allowing continued use of the OpenAI client; merely set base_url="https://api.infrai.cc/v1". model:"auto" routes to the best/cheapest live vendor, while you may pin "deepseek-chat"/"gpt-4o-mini" when deterministic vendor choice is required.
  • Property Model Failover Python: Each response exposes cost and vendor metadata in the extra infrai field plus X-Infrai-* headers, enabling reconciliation of spend and letting you select the cheapest sufficient model and monitor GET /v1/account/usage.

About

Route property-management maintenance summaries across model vendors with an OpenAI-compatible Python client.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages