AI API integration

OpenAI and AI API integration, built for production traffic

Calling an AI API in a demo is one line of code. In production you need queues for slow jobs, webhooks you can trust, retries when a provider hiccups, a fallback when a content filter says no, and a cost per call you know in advance. We run more than 20 models from OpenAI, Google, ElevenLabs, Fal, Replicate and others across our own products.

  • One interface over every provider, so models can be swapped
  • Signed webhooks, retries and automatic refunds for failed runs
  • Structured output that fits straight into your database

Anatomy of a production AI call

  1. Price the run

    Cost rules per model (resolution, duration, add-ons) give the cost before the user clicks.

    • cost preview
    • plan limits
  2. Queue the job

    A background job with a concurrency limit per model, so one busy model doesn't hold up the rest.

  3. Call the provider

    OpenAI, Google, ElevenLabs, Fal or Replicate behind one interface, with retries and back-off.

  4. Receive the result

    Webhook signatures verified before anything is stored, and results saved with retries.

  5. Recover

    A refusal re-runs on a more lenient model; a job stuck for an hour is failed and refunded.

The pattern behind the AI calls in Postcrest, Twelve Lumens and Salestreak.
What we can build

AI APIs we integrate

Text, vision, image, voice and video models, from one call inside your app to pipelines that chain several providers.

Image models

OpenAI's gpt-image-2 for edits with up to 16 input images and for new generations, plus Flux, Seedream and Google's Nano Banana models through Fal and Replicate.

Vision and structured output

Photos and documents analysed with forced function calls and JSON schemas, so the answer always has the shape your code expects.

Voice and audio

ElevenLabs for text to speech, voice design, voice cloning and Scribe transcription with word timestamps, plus OpenAI's text-to-speech models.

Video

Image to video and multi-shot generation through Fal, Runway and others, with lip-sync and post-processing in ffmpeg.

Text and analysis

OpenAI models for captions, scripts, descriptions and replies, and Google Gemini on Vertex AI for video analysis.

Safety and cost controls

Cost previews, plan limits, concurrency per model, content-filter fallbacks and refunds when a run fails.

Proof, not promises

AI APIs we call in production every day

Postcrest runs more than 20 image, video, voice and music models behind one credit balance. Twelve Lumens and Salestreak send every upload through a vision model with forced function calls, then edit the photos with OpenAI's image model.

Each provider has its own failure modes: slow queues, rate limits, content filters, webhooks that arrive twice. The integration layer absorbs all of that, so the product only ever sees a result or a clear failure.

  • Fal webhooks verified with ED25519 signatures against Fal's published keys, within a five-minute window
  • Content-filter refusals retried once on a more lenient model, automatically
  • Generations that hang for more than an hour failed and refunded
  • Result storage retried with exponential back-off, up to five attempts
  • Photos sent to vision models at 1024 pixels and low detail to keep the cost per call down
Postcrest's video model picker with Grok Imagine, Gemini Omni Flash, WAN 3.0, Kling 3.0 and MiniMax and their credit costs
One picker across providers, each model with its cost per run (Postcrest).
Postcrest's voice design screen, where a voice is described in words before it is generated
Voice design in Postcrest: describe a voice in words and generate it.
AI models in production
20+
AI providers integrated directly
5+
window for a valid Fal webhook signature
300 s
before a stuck generation is failed and refunded
1 h
Who it's for

Who we build AI integrations for

SaaS products adding AI

A new AI feature in your existing product, with usage limits and costs that fit your pricing.

AI startups

A product built on several models, with a layer that lets you switch providers as the market moves.

Teams automating with AI

Classification, extraction and drafting built into your processes, with structured output and review steps.

Teams with a fragile AI prototype

A script that calls an API directly and falls over under load. We turn it into queued, monitored jobs that recover on their own.

How it works

How we build an AI integration

AI providers change their models, limits and prices often. We design for that.

  1. 1

    Benchmark on your data

    Candidate models tested on your real inputs for quality, speed and cost per result.

  2. 2

    Define the interface

    One internal interface per task, with inputs, outputs and cost rules, so providers can be swapped later.

  3. 3

    Queue everything slow

    Background jobs with concurrency limits per model and live progress in the interface.

  4. 4

    Make results trustworthy

    Signed webhooks, structured output with schemas, retries and idempotent storage.

  5. 5

    Plan for refusals and outages

    Fallback models, timeouts and refunds, so a failure costs the user nothing.

  6. 6

    Watch the bill

    Cost per call tracked, images downsized for analysis and cheaper models for simple steps.

Providers and tooling

Provider SDKs and plain HTTP clients behind our own interfaces, running as background jobs in Rails, with results stored on Cloudflare R2.

  • OpenAI API
  • Google Vertex AI
  • ElevenLabs
  • Fal
  • Replicate
  • Runway
  • Function calling
  • JSON Schema
  • Solid Queue
  • Cloudflare R2
Cost & timeline

What does an AI API integration cost?

Two budgets: the integration itself and the cost per call afterwards. Both depend on:

Number of models and providers
Each provider has its own API, limits, webhooks and failure modes to handle.
Quick or long-running
Quick calls can run inline; image, video and voice jobs need queues, webhooks and progress updates.
Output requirements
Free text is simple; structured output that must fit your data model needs schemas and validation.
Volume
The number of calls per day decides the running costs and how much optimisation pays off.
Billing your users
Credits, limits and cost previews if your customers pay per use.
FAQ

Questions about AI API integration

How much does an OpenAI integration cost?

It depends on the number of models and providers, whether the jobs are quick or long-running, and the volume. After a free intro call you get a written scope and estimate, including the expected cost per call.

How long does it take to integrate an AI API?

A single quick call can be live fast. Long-running image, video or voice jobs with webhooks, retries and billing take longer. The estimate after the intro call includes a timeline per phase.

Which AI providers do you work with?

OpenAI, Google (Gemini on Vertex AI), ElevenLabs, Fal, Replicate, Runway and others. Through Fal and Replicate we also run models such as Flux, Seedream, Kling and MiniMax.

What if a provider changes or removes a model?

Each model sits behind our own interface with its own cost rules, so moving to another model or provider is a contained change, not a rebuild.

How do you keep AI costs predictable?

With cost rules per model, a cost preview before each run, plan limits, smaller images for analysis and refunds for failed runs. You know the cost per result before you set your prices.

Is our data used to train the models?

With business APIs such as OpenAI's, data sent through the API isn't used for training by default. We check each provider's terms and keep uploads in private storage.

Can you add other AI providers?

Yes. A new provider gets the same treatment as the others: an adapter behind the shared interface, cost rules, retries and tests.

Need AI calls that don't break under load?

Tell us which models you want to use, for what and at what volume. You'll get an honest view on the architecture, the running costs and what to build first.

martin@balk.dev

Typically a reply within one business day.

Useful to mention

  • What you want to build, in a few sentences
  • Who is going to use it
  • Any deadline or launch date
  • Tools and systems it should connect to