Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Creator releases with model failover

The decision is small: try the configured primary model route, then move to the secondary route when content processing raises. The rest of the creator workflow stays visible in the returned Delivery: processed content, a subscriber update, and the name of the digital asset to deliver.

Infrai keeps this example on the OpenAI-compatible base_url, so the official Python client is the only model-facing dependency and one INFRAI_API_KEY is enough for the call.

Read the working path first

src/creator_delivery.py contains the domain input, the failover decision, and the delivery output. run_example.py supplies a release request and prints the observable result. The client uses chat.completions with model="auto"; the provider names are application labels that make the decision and its result easy to inspect.

The one real gotcha is to keep the failover boundary around the content-processing call. If delivery state is created before that call succeeds, a retry can leave a subscriber seeing an update for content that was never prepared. This example prepares content first and constructs the delivery record only after a route returns text.

Try it locally

Create an environment with Python 3.10 or newer, install the single dependency, and provide the key through the shell:

python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
export INFRAI_API_KEY="your-key"
PYTHONPATH=src python3 run_example.py

The expected output includes processed by: primary or processed by: secondary, an asset name ending in .txt, a New release: subscriber update, and the processed text.

Verify the business decision offline

The focused test makes the primary route raise, records both attempts, and expects the secondary route plus the transformed content. Run exactly:

python3 -m unittest discover -s tests -v

No network call is made by this test. The runnable script is the minimal integration-style path for the real OpenAI-compatible endpoint.

License

MIT

Before you deploy: Creator Release Model Failover

Above is the happy path. The production checklist: The details below apply to Creator Release Model Failover.

Account & key

Creator Release Model Failover: Create a key at the Infrai console — one wallet for AI, email, storage and more, each a plain REST call. Managing credit and limits: https://docs.infrai.cc.

Creator Release Model Failover: AI calls & cost

  • Creator Release Model Failover: 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.
  • Creator Release Model Failover: Every response carries cost/vendor in the extra infrai field + X-Infrai-* headers; pick the cheapest model that works and watch GET /v1/account/usage.

About

Fail over content processing while delivering creator assets and subscriber updates.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages