← All articles

5 min read

Adding AI to Your Product Without Rewriting Your Backend

A practical playbook from shipping Gemini and DeepL features on a live Laravel platform: queues, provider seams, cheap classification, human review and cost tracking.

Almost every founder I talk to has the same request this year: “we want AI in the product.” Usually it comes with a quiet fear attached: that adding it means a rewrite, a new team, or a surprise bill from a model provider. It does not have to. Most valuable AI features are a backend integration problem, and integration is a problem we already know how to solve well.

I learned this building a multilingual car auction platform for the European market. Listings needed to appear in German, English, French and Italian, and they needed good descriptions. We added AI-generated listing content with the Gemini API and automated translation with the DeepL API, on a Laravel backend that was already live. Here is the playbook I would use on any existing product.

1. Never call an AI model inside a web request

Model calls are slow, occasionally fail, and sometimes take ten times longer than usual. If your checkout or “save listing” button waits on one, your product inherits all of that. Put every model call in a queued job and treat the result as something that arrives later.

class GenerateListingDescription implements ShouldQueue
{
    public int $tries = 3;
    public array $backoff = [10, 60, 300];   // seconds between retries

    public function __construct(public Listing $listing) {}

    public function handle(ContentGenerator $ai): void
    {
        // Same specs = same text: cache by a hash of the inputs, not the listing ID.
        $key  = 'listing-desc:' . $this->listing->specs_hash;
        $text = Cache::remember($key, now()->addDays(30),
            fn () => $ai->describe($this->listing->specs));

        $this->listing->update([
            'ai_description' => $text,
            'ai_status'      => 'needs_review',
        ]);
    }

    public function failed(Throwable $e): void
    {
        // The listing still publishes with its manual text. AI is an upgrade, not a dependency.
        $this->listing->update(['ai_status' => 'failed']);
    }
}

Three details in that small job save real money and real incidents: retries with backoff, caching by input rather than by record, and a failed() path where the product keeps working without AI.

2. Put a seam between your product and the provider

Notice the ContentGenerator interface in the job. Your domain code should never know whether the text came from Gemini, OpenAI, Anthropic or a local model. Hide the provider behind an interface you own. Then switching provider, A/B testing two models, or adding a cheaper fallback is a configuration change, not a refactor.

In Laravel this is now easier than ever. The first-party Laravel AI SDK reached v1.0 in September 2026, with one API across providers such as OpenAI, Anthropic and Gemini. I still recommend wrapping it in your own small interface, because your product’s vocabulary (“describe a vehicle”, “translate a listing”) is more stable than any SDK’s.

3. Classify cheaply, generate expensively, and only when needed

A pattern that cuts AI costs dramatically: use a fast, cheap step to decide whether you need the expensive step at all. Is this support ticket urgent? Is this listing already well described? Does this text need translating, or is it already in the target language?

The Laravel AI SDK 1.0 made this a first-class idea: classification is now its own capability, separate from text generation. Classify first, then send only the cases that need a written response to a more capable, more expensive model.

4. Keep a human in the loop where mistakes are expensive

On the auction platform, generated content landed as needs_review rather than going straight to buyers. That one status column is the difference between “AI helps our team” and “AI publishes things we did not check.”

The same principle applies when AI acts rather than writes. If an agent can issue refunds, delete files or email customers, those actions need approval. Laravel’s AI SDK now supports human-in-the-loop tool approvals, where a tool can pause the agent and wait for a person to approve, reject or edit the call. Use it for anything you could not undo.

5. Translation is a pipeline, not a function call

Multilingual content looks simple (“call DeepL, done”) until you hit the details:

  • Translate once, store forever. Store each language version in the database, keyed by source text hash, so editing a price never triggers four new translations.
  • Protect what must not change. Model names, VINs, units and brand terms should be shielded from translation, for example with a glossary or placeholders.
  • Translate the source, not a translation. Chaining German to English to Italian compounds errors.
  • Make it observable. Track characters translated per day. Translation APIs bill by volume, and a bug that re-translates everything every night is easy to miss.

6. Measure cost per feature, not per month

Log tokens or characters, latency and the feature name on every AI call. A monthly invoice tells you nothing. “Listing descriptions cost X per listing and save the sales team Y minutes” tells you whether the feature is worth keeping, and where to switch to a cheaper model.

A sensible order of work

  1. Pick one feature where AI saves your users or team visible time.
  2. Build it as a queued job behind your own interface, with caching and a non-AI fallback.
  3. Ship it with human review switched on.
  4. Add cost and quality logging, then relax review only where the data says it is safe.

None of this requires a rewrite. It requires a backend with clean boundaries, a queue, and an engineer who has done it before.

Want AI features in your product without betting the platform on them? I build AI, payment and third-party integrations on Laravel, Node.js and NestJS backends. Get in touch and we can map out the first feature together.

Share

Have a product in mind?

Open to senior backend roles and long-term product builds.

Get in touch