Inspiration

The EU AI Act's Article 50 transparency mandate takes effect on August 2, 2026. From that date forward, every piece of AI-generated content distributed in the European market — images, video, audio — must carry a machine-readable disclosure of its synthetic origin. Non-compliance carries penalties up to €15 million or 3% of global annual turnover.

I realized that generative AI tools are scaling exponentially, but compliance labeling is still a manual afterthought. There's no middleware that intercepts synthetic media at creation time and guarantees it's born compliant before it ever touches production storage. Enterprises using tools like GPT-Image, Wan2.7, or Hume Octave for content at scale have no automated path to meet the deadline.

That gap — the space between "AI content generated" and "AI content legally distributed" — is what inspired MarkBlaze. I wanted to build the compliance layer that doesn't exist yet: invisible to end users, automatic for developers, and cryptographically auditable for regulators.

The cost motivation is also clear. If a company generates $N$ assets daily and each needs $C$ minutes of manual compliance review:

Annual labor=N×C×365

At modest enterprise scale ($N=200$, $C=4$ min), that's 292,000 minutes per year — eliminated entirely by automation.

What it does

MarkBlaze is a Compliance-as-a-Service (CaaS) middleware pipeline that automatically watermarks, certifies, and archives AI-generated media across three modalities — and exposes itself as a multi-model AI agent on the GMI Cloud AgentBox marketplace.

Core compliance pipeline:

  • Images — Generates via GMI Cloud GPU models, embeds invisible LSB steganography watermarks containing SHA-256 provenance, archives to Backblaze B2.
  • Audio — Synthesizes speech via Hume Octave TTS, produces hash-verified transcripts via AssemblyAI, binds transcript to manifest, archives both.
  • Video — Produces via GMI Cloud video models, validates provenance, archives with compliance metadata.

Agent functionality (GMI AgentBox):

MarkBlaze operates as a deployable AI agent — not just an API. The agent demonstrates the multi-model routing pattern described in the GMI AgentBox architecture:

  1. Multi-Model Labeling Agent (POST /api/agent/label) — A single request triggers a multi-step pipeline that routes across different models:
  • Classification step (CPU): Rule-based router analyzes the prompt and selects the optimal generation model (e.g., gpt-image-2-generate for photorealistic, wan2.7-image-pro for artistic, seedance-2-0-fast for speed-critical video)
  • Generation step (GPU): Offloads heavy inference to GMI Cloud
  • Watermarking step (CPU): LSB steganography injection
  • Optional audio disclosure step (GPU): Generates a spoken AI-disclosure statement ("This content was generated by artificial intelligence using the X model…") and attaches a hash-verified transcript — a multi-model chain in one call
  1. Compliance Verification Agent (POST /api/agent/verify) — Other AgentBox users can submit any asset URL or B2 key and receive a 7-point compliance audit report, enabling agent-to-agent verification workflows.

  2. Async Job Queue (POST /api/jobsGET /api/jobs/{job_id}) — For production workloads, users submit jobs asynchronously and poll for results. The Agent Dashboard shows real-time job status with polling indicators.

  3. Agent Marketplace Registration (GET /api/agent/info) — Returns structured metadata (capabilities, models, pricing, trust badge) so GMI Cloud's AgentBox catalog can list MarkBlaze alongside other agents.

Users interact via three interfaces:

REST API — Direct HTTP calls for programmatic integration CLI — python app.py --prompt "..." --modality image|video|audio Next.js Dashboard — Includes a dedicated Agent page (/agent) with an interactive multi-model demo, model routing visualization, pipeline step breakdown, and a live async job queue table

How I built it

Stack:

  • Backend: FastAPI (async) + genblaze SDK for pipeline orchestration
  • Frontend: Next.js 14, React 18, TypeScript
  • Storage: Backblaze B2 (S3-compatible, immutable object storage)
  • GPU Compute: GMI Cloud for multi-modal inference
  • Audio: Hume Octave TTS + AssemblyAI speech-to-text
  • Infrastructure: AWS CDK (Python) — Lambda ARM64, API Gateway, Secrets Manager, S3 + CloudFront Pipeline design: All orchestration lives in pipeline.py. Both the CLI (app.py) and API (main.py) delegate to the same pipeline — zero logic duplication. The pipeline uses Pipeline.arun() for non-blocking async execution, constructs a fresh ObjectStorageSink per request (never shared), and passes tenant_id for cache isolation.

Watermark engine: A custom LSB steganography module (watermark.py) built on Pillow. It encodes the provenance manifest into the least significant bits of RGBA pixel channels. The watermark is invisible to humans but extractable for machine audit. All processing happens in io.BytesIO streams — no temporary files ever touch disk.

Audio provenance chain: Hume generates speech → I extract the execution manifest → AssemblyAI transcribes with word-level timings → the transcript is SHA-256 hashed and bound to the original manifest:

verification_hash=H(transcript_text∥manifest_hash)

Development: Built entirely in Kiro IDE using spec-driven development. Product requirements, system design, and implementation tasks were authored as specs in .kiro/specs/. Engineering guardrails were enforced via compliance-rules.md — 10 sections covering everything from module boundaries to anti-patterns.

Deployment: Fully serverless via AWS CDK. The backend runs on Lambda (Docker container, ARM64) with a Mangum adapter. The frontend is statically exported and served through S3 + CloudFront. Secrets live in AWS Secrets Manager with least-privilege IAM. One-command deploy: cd infra && ./deploy.sh.

Agent architecture: I structured MarkBlaze as a GMI AgentBox-compatible agent. The /api/agent/label endpoint demonstrates multi-model routing — a classification step picks the optimal model, the generation step runs on GPU, watermarking runs on CPU, and an optional audio disclosure step chains another GPU model to generate a spoken AI-origin statement. This follows the AgentBox pattern where "a support agent might classify using a small model, pull context using an embedding model, and hand reasoning to a frontier model."

The async job queue (/api/jobs) provides the production pattern for long-running agent tasks — submit, get a job_id, poll until complete. The frontend Agent page implements client-side polling with setInterval to show real-time status transitions.

Add to "Accomplishments that I'am proud of":

  • Multi-model agent in one call: The /api/agent/label endpoint chains classification → GPU generation → CPU watermarking → optional GPU audio disclosure in a single request, demonstrating real multi-model routing rather than just wrapping a single model call.

  • Agent-to-agent verification: The /api/agent/verify endpoint means other agents on the GMI AgentBox marketplace can programmatically verify if media meets EU AI Act requirements — enabling composable compliance workflows across independent agents.

Add to "What's next for MarkBlaze":

  • Full GMI AgentBox marketplace listing - Register via console.gmicloud.ai with the live API Gateway endpoint, enabling any GMI Cloud user to discover and deploy MarkBlaze from the catalog with usage-based pricing.

  • Agent-to-agent orchestration - Enable MarkBlaze to call other AgentBox agents (e.g., a content moderation agent) as pipeline steps, creating composable compliance chains across the marketplace.

Challenges I ran into

  1. The watermark-or-quarantine invariant. Our core safety guarantee is that un-watermarked media never reaches production storage. But making the pipeline halt on any watermark failure means a single Pillow edge case (unusual color modes, truncated streams) can block an entire generation. I solved this with explicit quarantine paths and detailed error reporting — fail loud, never fail silent.

  2. Virtual stream processing end-to-end. Security requirements demand that un-watermarked content never touches the filesystem. Every boundary — image generation output, watermark injection, B2 upload — had to work with io.BytesIO objects. This complicated debugging significantly since you can't just "open the file and look at it" during development.

  3. Multi-modality in a unified schema. Images use steganography, audio uses transcript hashing, video uses metadata binding — three fundamentally different compliance strategies. Designing a single PipelineResult that works across all three without leaky abstractions required multiple iterations.

  4. SDK cost tracking breaking. Midway through development, I discovered that the genblaze SDK's cost_usd helper returns None. I had to build manual token aggregation by looping through step.metrics to extract tokens_in and tokens_out, then computing cost with configurable rates:

cost_usd = (token-in)* (rate-in) + (token-out)* (rate-out)/1000

  1. Async concurrency + tenant isolation. FastAPI processes requests concurrently on a single event loop. Ensuring pipeline state (sinks, caches, metrics) never leaks between concurrent tenants required strict per-request instantiation patterns — fresh ObjectStorageSink per call, explicit tenant_id scoping, and immediate teardown after arun() completes. ## Accomplishments that I'am proud of
  2. Zero-trust compliance chain: From generation to archival, every asset passes through manifest.verify(), watermark injection, and hash verification. There is no code path where an un-watermarked asset can reach the production B2 bucket.
  • Three modalities, one API call: POST /api/generate with "modality": "image|video|audio" handles the entire compliance lifecycle — generation, provenance extraction, watermarking/hashing, and immutable archival — in a single request.

  • Word-level audio audit: The transcript viewer lets compliance officers filter by confidence score, play back specific words, and verify that the cryptographic hash chain from manifest → transcript is intact. This is the level of granularity regulators will expect.

  • Full infrastructure-as-code: The entire deployment — Lambda, API Gateway, Secrets Manager, S3, CloudFront — is defined in two CDK stacks. A new environment goes from zero to production with one deploy.sh command.

  • Spec-driven development with Kiro: Every feature was designed before it was built. Requirements → design → tasks → implementation. The compliance-rules.md guardrails caught architectural violations automatically during development — preventing anti-patterns like shared sinks, hardcoded credentials, or duplicated pipeline logic.

  • Financial observability built-in: Despite the SDK's cost_usd returning None, I ship a working cost tracker that aggregates token usage across all pipeline executions and exposes it through both the API and the dashboard.

    What I learned

  • Compliance is an architectural concern, not a feature flag. You can't bolt watermarking onto an existing pipeline after the fact. It needs to be a first-class constraint that shapes every design decision — from stream processing (no temp files) to error handling (halt, don't skip).

  • Immutable storage changes your failure modes. Once something is in B2 with Object Lock, it's permanent. This means your "write" operation is irreversible — you must be absolutely certain the asset is compliant before the upload, not after.

  • Audio provenance is harder than image provenance. You can't embed invisible data into audio the way you embed it into pixels. Hash-binding a transcript to the generation manifest is the practical approach, but it requires an additional STT service in the chain — adding latency, cost, and another failure point.

  • Serverless + Docker + ARM64 is cost-efficient but finicky. Lambda container images on ARM64 save ~20% on compute cost, but multi-architecture Docker builds add complexity to CI/CD. Getting Pillow and av compiled for linux/arm64 in a Lambda-compatible container required careful base image selection.

  • Kiro's spec-driven workflow prevents scope creep. Having formalized requirements and tasks meant I never drifted into "nice to have" features. Every line of code traced back to a spec task. This discipline was critical for a hackathon timeline.

    What's next for MarkBlaze

  • C2PA integration — Embed Content Credentials (Coalition for Content Provenance and Authenticity) alongside our steganographic watermarks for industry-standard interoperability.

  • Real-time streaming compliance — Extend the pipeline to handle live video/audio streams, watermarking frames and audio chunks in real-time as they're generated.

  • GMI AgentBox marketplace listing — Register MarkBlaze as a deployable agent on GMI Cloud's AgentBox, enabling any developer to add EU AI Act compliance to their workflow with a single API integration.

  • Multi-jurisdiction support — The EU AI Act is first, but similar regulations are emerging in Canada (AIDA), Brazil (PL 2338), and China (Deep Synthesis Provisions). MarkBlaze will support configurable compliance profiles per jurisdiction.

  • Tamper detection alerting — Monitor B2 assets for unauthorized modifications using periodic verification sweeps, alerting compliance teams if any watermark has been stripped or altered.

  • Per-tenant billing and usage metering — Production multi-tenancy with API key authentication, per-tenant usage tracking, and integration with GMI's usage-based pricing model.

Built With

Share this project:

Updates