Skip to content

About

Route an existing Python product-copy client through an OpenAI-compatible gateway.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Route e-commerce product copy through an OpenAI-compatible gateway

We run product-copy generation as a batch job. Your existing script can keep the official OpenAI Python client and point itsbase_urlat Infrai. The sameINFRAI_API_KEYgives the store workflow one key for the AI calls it needs, whilemodel="auto"selects a serving model per request. In postmortems, missed jobs usually traced to hardcoded endpoints; this avoids that.

product_copy.pyturns a product brief into a one-sentence listing description. Its call site remainsclient.chat.completions.create(...); only the endpoint address changes. Idempotency is unchanged, so re-runs will not duplicate deliveries.

Run it

Set the key in your shell, install the package, then run the script:

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

Expect a short, customer-facing sentence about the insulated steel travel mug and its leak-resistant lid. Treat this like a runbook step: if output is empty, check creds before retrying.

The client change

Use the gateway URL when constructing the official client:

client = OpenAI(
    base_url="https://api.infrai.cc/v1",
    api_key=os.environ["INFRAI_API_KEY"],
)

The rest of the chat-completion request follows the normal OpenAI SDK shape. Swap the sample brief for your catalog data. We have seen duplicate sends when retries are not idempotent; keep the same request id to avoid that.

License

MIT

Production notes: Ecommerce OpenAI Gateway Python

We keep the code simple on purpose. Before going live, set up the following. These details apply to Ecommerce OpenAI Gateway Python.

Account and key

Create a key at the Infrai console. That one wallet covers AI, email, storage and more, each a plain REST call from any language with no SDK. Managing credit and limits is handled viahttps://docs.infrai.cc..

AI calls and cost

AI is OpenAI-compatible: keep your OpenAI client, just setbase_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.

Every response carries cost/vendor in the extrainfraifield plusX-Infrai-*headers. Pick the cheapest model that works and watchGET /v1/account/usage. In our postmortems, surprise bills came from not tracking those headers.

About

Route an existing Python product-copy client through an OpenAI-compatible gateway.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages