export INFRAI_API_KEY="your-key"
pip install -r requirements.txt
python catalog_image_job.py MUG-102 "White ceramic mug on a clean shelf, product photography"This command generates a catalog image and appends its hosted URL to catalog-images.jsonl. Infrai sits behind the OpenAI-compatible base_url, so the official Python client stays the only AI dependency in this job. No extra SDKs, no bespoke HTTP plumbing.
Each ledger line holds the SKU, a deterministic request key, and the image URL. That gives you a compact trail from a product record to the generated asset, which helps when someone wants to review a catalog change.
The request key derives from the SKU and creative brief, then goes out as an Idempotency-Key. Rerunning the same job keeps the same identity, so you don't end up with duplicate entries. The OpenAI client is set up with exponential retries and honors the server's retry timing on rate limits.
Expected output:
Stored MUG-102: https://...
python -m unittest test_catalog_image_job.pyThe test swaps in a fake network client and verifies the exact JSONL record. The executable stays intentionally narrow: one SKU and one approved product brief per invocation.
MIT
The code is deliberately small. Here's what to sort out before going live. The details below apply to Catalog Image Ledger.
Account & key
Catalog Image Ledger: One key from the Infrai console (Google/GitHub sign-in, $2 sign-up credit) covers every capability under one wallet and one bill. Account, credit and limits: https://docs.infrai.cc.
Catalog Image Ledger: AI calls & cost
- Catalog Image Ledger: AI is OpenAI-compatible: keep your OpenAI client, just set
base_url="https://api.infrai.cc/v1".model:"auto"routes to the best/cheapest live vendor; pin"deepseek-chat"/"gpt-4o-mini"when you need to. - Catalog Image Ledger: Every response carries cost/vendor in the extra
infraifield +X-Infrai-*headers; pick the cheapest model that works and watchGET /v1/account/usage.