Skip to main content
Yosavo Studio by Youssef Ibaichou , home
Expertise

AI Integration

My focus with AI is applied product engineering: integrating models into real workflows, validating outputs, controlling cost, handling failures and making AI useful inside production software.

LLM integration · Structured output · Validation · Cost control

How I think about it

How I think about AI

The model is only one component of an AI feature. Production AI also requires context management, validation, error handling, security, cost control and a clear reason for using AI in the first place.

  • Start with the product problem; use AI only where it beats a rule.
  • Treat model output as untrusted input — validate it before it touches the product.
  • Keep the provider behind your own interface.
  • Measure cost per feature, not just per request.

Key experience

Where this comes from

  • Python AI prototypes and automations: LLM integrations, document extraction and file-analysis workflows.
  • AI features on Nexus Inclusion integrated through AWS Bedrock, with a Node.js backend.
  • AI is part of the product scope for Yotria, the portfolio SaaS I'm building as founder.
  • Applied engineering — integrating models into products and workflows, not training them.

Scope

What I know

  • LLM integration architecture
  • Prompt design
  • Structured output
  • Output validation
  • Reliability & fallbacks
  • Context management
  • RAG concepts
  • Provider abstraction
  • Cost control
  • Security & prompt injection
  • AI features in SaaS
  • When not to use AI

Deep dive

AI Integration in practice

On this page (12 topics)

LLM integration architecture

The model call is one step in a longer pipeline. The application decides when AI is appropriate and what the user is allowed to do; the backend builds the context, calls the provider with server-side credentials, validates the response, and only then hands a result to the product. The browser never talks to the model provider directly.

  1. User

    acts in the product

  2. Application

    permissions, intent

  3. Backend

    context, credentials

  4. Model provider

    one step, not the system

  5. Validated response

    schema, rules, fallback

  6. Product

    shows or uses the result

AI request flow: the user acts in the application, the backend calls the model provider, and only a validated response reaches the product.

Prompt design

A production prompt is closer to an API contract than a chat message: a system instruction that defines the task and its constraints, clearly separated user input, only the context needed, and an explicit output format. User content is delimited and treated as data, never as instructions. Prompts are versioned and tested against real examples like any other code.

Structured output

Applications need data they can act on — a category to route a ticket, fields to fill a form, a list to display — not a paragraph to parse with regular expressions. Asking for a defined JSON structure, using the provider's structured-output features where they exist, turns a model response into something the rest of the system can validate and use.

Example structured model response
{
  "category": "billing",
  "confidence": 0.92,
  "recommendations": [
    "Route to the billing support queue",
    "Attach the customer's latest invoice"
  ]
}

Validation

Every response is validated against a schema before use: required fields present, types correct, values within an allowed set, confidence within range. An invalid response is retried once with the validation error included, then falls back — to a default, a rule-based path or a person — and the failure is logged so it can be measured.

Reliability

Models can be confidently wrong. Reliability comes from the system around them: narrowly defined tasks, grounding in provided context, deterministic business rules the AI output can't override, confidence thresholds that send uncertain cases to human review, and timeouts and retries for provider errors.

For anything consequential — money, permissions, legal content — AI suggests and a rule or a person decides.

Context

Output quality depends more on context than on prompt wording. Send what the task needs — the relevant document section, the user's settings, recent history — and nothing else. Excess context costs money, slows responses and can dilute the answer. User-specific context must respect the same permissions as the rest of the application.

Retrieval-augmented generation (RAG)

RAG grounds answers in your own content. Documents are split into chunks, the chunks are turned into embeddings and stored for similarity search, the most relevant chunks are retrieved for each question, and the model answers using that context.

Most of the engineering is in the retrieval: chunk boundaries that keep meaning intact, metadata for filtering by tenant and permission, and checking that the right passages are found before judging the answer.

  1. Documents

  2. Chunks

  3. Embeddings

  4. Retrieval

    filtered by permission

  5. Context

  6. Response

RAG pipeline: documents are chunked and embedded, relevant chunks are retrieved for each question, and the model answers using that retrieved context.

AI providers

Model providers change quickly in quality, price and limits. I keep the provider behind a small internal interface — task in, validated result out — so switching models, or using different providers for different tasks, is a configuration change rather than a rewrite. That doesn't mean abstracting every provider feature; it means the product depends on our contract, not theirs.

Managed services such as AWS Bedrock help by putting several model families behind one AWS API with IAM-based access. The product should still depend on its own interface rather than on any single provider's request format.

Cost

AI cost scales with tokens — input context, output length — and with the number of calls. The levers are mostly architectural.

  • Use the smallest model that does the task well; reserve larger models for harder tasks.
  • Keep context tight and cap output length.
  • Cache results for identical inputs.
  • Don't call a model for cases a rule can handle.
  • Enforce per-tenant usage limits that match the pricing plan.

Security

API keys stay on the server. Sensitive data is sent only when the task needs it and the provider's data handling is acceptable. Prompt injection — instructions hidden in user content or documents — is a real risk, so model output never directly triggers privileged actions; it goes through the same authorization and validation as user input. Retrieval and tools only reach what the current user is allowed to see.

AI in SaaS

The most useful SaaS AI features are usually unglamorous: classifying incoming items, extracting fields from documents, summarising long threads, drafting content for a person to edit, recommending next actions, automating repetitive workflow steps. Each one needs an owner, a success measure, a cost budget and a fallback for when the model is unavailable.

Related: SaaS Development expertise

When not to use AI

If the logic can be written as rules — validation, calculations, routing on known fields, permissions — deterministic code is cheaper, faster, testable and explainable. AI is the wrong tool when an error is unacceptable and can't be reviewed, when the input space is small and known, or when nobody can say which problem it solves.

Simple rules should remain rules. A good AI feature starts as a problem statement, not as a model.

In practice

Common problems I work with

  • An AI prototype that works in a demo but not on real data
  • Free-form model output parsed with fragile string logic
  • No validation or fallback when the model returns something unexpected
  • Costs growing faster than usage
  • Sensitive data sent to providers without a clear reason
  • AI added where a simple rule would do

Real products

How it connects to real products

AI is part of the scope of products I lead and build — approached as product engineering, with the same rules on permissions, validation and cost as any other feature.

  • Accessibility Technology / SaaS

    Nexus Inclusion

    AI features integrated through AWS Bedrock in a Node.js backend — on an accessibility SaaS where I lead delivery and technical decisions.

  • SaaS / Portfolio Builder

    Yotria

    AI is part of the product scope for this portfolio builder I'm developing as founder.

    Coming soon

See all selected work

Related expertise

Node.js

APIs, integrations and serverless workloads with careful async design.

  • API architecture
  • Async patterns
  • Serverless
  • Observability

API Development

Predictable API contracts: validation, errors, authorization, idempotency and webhooks.

  • API design
  • Error handling
  • Idempotency
  • Webhooks

AWS

Workload-first cloud architecture: serverless, storage, data, security and cost.

  • Serverless
  • S3 & DynamoDB
  • IAM
  • Cost awareness

SaaS Development

Tenancy, permissions, plans, billing and the realities of running SaaS in production.

  • Multi-tenancy
  • Permissions
  • Billing
  • Production delivery

Related services

  • AI Prototypes & Automation

    Test and build practical AI-powered workflows, agents, and proof-of-concepts before investing in a full product.

    Learn more
  • SaaS Product Development

    Design and build SaaS products from MVP to production, including architecture, user management, subscriptions, integrations and cloud infrastructure.

    Learn more
  • Custom Software Development

    Build reliable web platforms, SaaS products, dashboards, APIs, and internal tools with modern full-stack technologies.

    Learn more
Let's talk

Have a technical challenge?

Whether it's an architecture decision, a delivery problem or something specific to AI Integration, I can help you find a practical path forward.

What happens next

  1. Share your goal

    A few lines about the product, problem, or audit need.

  2. Get a quick read

    A practical reply on the best technical path forward.

  3. Move forward

    A clear scope, estimate, or concrete next step.