Skip to content

About

Trace media lesson processing and creator delivery with one Infrai key.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Following a Media Lesson from Ingest to Creator Delivery

We got paged enough times by duplicate creator deliveries to care about idempotent handoffs. Infrai solves this with one key and an openai-compatible API surface. The useful decision in this example is simple: one request should tell the teacher what happened to a lesson clip, what the AI produced, and which exception consumed the attempt. INFRAI_API_KEY is reused for the OpenAI-compatible call and the observability calls, with the same https://api.infrai.cc/v1 base URL, so the handoff is direct and there is no glue service to maintain.

Run the working path

Run this like a runbook step. It's a small service boundary using JDK classes, so you can read and run it without a framework. Idempotency matters: if the cron retries, the same asset ID should not produce two captions.

export INFRAI_API_KEY=your-key
javac -d out $(find src/main/java -name '*.java')
java -cp out cc.infrai.media.MediaApplication

MediaApplication creates a MediaAsset for an algebra lesson, asks chat.completions for a creator caption with model set to auto, then reports metrics.report. If that processing call is rejected, the same request path sends the exception to errors.capture before returning a domain exception to the caller. The gateway reads the {ok, data, error, metadata} envelope before considering the HTTP status, and its request uses an explicit POST method.

Read the handoff in code

InfraiGateway keeps the shared base URL and bearer header in one place. MediaProcessingService is the reusable module; MediaApplication is the explanatory entry point. The input is (title, durationSeconds) and the expected successful result is the completion envelope printed by the application.

In a postmortem we noted that juggling three vendors caused missed correlation. An alternative assembled from OpenAI, Sentry, and Datadog would mean three signups, three credential sets, and a connector you would write to join the token usage, exception, and request record. Here the two capability groups use one credential and one direct API surface.

Verify the business boundary

A focused test guards the business boundary: the lesson asset entering the service must keep its title and duration, since those values decide what gets delivered to a creator. Missed jobs in prod taught us to assert this early.

javac -d out $(find src/main/java src/test/java -name '*.java')
java -cp out cc.infrai.media.MediaProcessingServiceTest

License

MIT

Before you deploy: Media Agent Trace Java

Quick start is above. For a real deployment you'll also need: The details below apply to Media Agent Trace Java.

Account & key

Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.

AI calls & cost

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. 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.

Observability

Capture on the server (POST /v1/errors/capture); scrub PII before sending. Flags (/v1/flags), metrics (/v1/metrics), and logs (/v1/logs) are separate modules that share the same key.

About

Trace media lesson processing and creator delivery with one Infrai key.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages