Skip to content

How to integrate AI into existing systems without handing the model the keys

Mykhailo Poliarush7 min read

Here is how to integrate AI into existing systems: pick one workflow, connect a model to it through a narrow interface (an API call, retrieval over your own content, or an agent with a small set of tools), and keep permissions and business rules in your systems rather than in the model. Then test it like any other integration and roll it out in stages, whether your own team does the work or you buy AI integration services. Compatibility is a real blocker: 41.6% of EU companies that considered AI but did not use it in 2025 cited incompatibility with existing equipment, software or systems (Eurostat data).

Why is integrating AI into existing systems hard?

Because the model is the easy part. The hard parts are the ones your systems already have: data spread across applications, permissions that differ by user, and APIs that were designed for people, not for software that decides on its own what to call next.

Why EU enterprises that considered AI did not use it, 2025 (more than one answer allowed)

Lack of relevant expertise
70.3%
Unclear legal consequences
53.6%
Data protection and privacy concerns
52.7%
Data availability or quality
43.5%
Incompatible with existing equipment, software or systems
41.6%
Costs seem too high
38.4%
Ethical considerations
24.6%
AI not useful for the enterprise
17.8%

Source: Eurostat, isoc_eb_ai, EU27, enterprises with 10+ employees that ever considered AI (2025; dataset updated June 2026)

Security incidents start in the same place. In IBM's 2026 study of 602 breached organizations, more than 20% reported a breach targeting AI models or applications, and the most common causes were compromised APIs, applications or plug-ins (27%) and cloud misconfigurations affecting AI workloads (27%) (IBM). The study is run by Ponemon Institute and sponsored by IBM, a security vendor. The point holds anyway: the weak spots are the connections around the model.

What are the main AI integration patterns?

Start with the simplest pattern that does the job. Anthropic's engineering team gives the same advice: find "the simplest solution possible, and only increasing complexity when needed" (Anthropic).

  1. A model behind an API call. Your application sends text or a document to a model and gets back a structured result: a category, extracted fields, a summary, a draft reply. The model never touches your systems directly. It covers many useful cases and is the easiest pattern to test.
  2. Retrieval-augmented generation (RAG). The application searches your documents or records, passes the relevant passages to the model and asks it to answer from them. The term comes from a 2020 research paper that combined a model's built-in knowledge with a searchable index (Lewis et al.). Use it for support answers, internal search and policy questions.
  3. An agent with tools. The model decides which actions to take: look up an order, create a ticket, update a record. Each action is a tool your team defines. The Model Context Protocol (MCP) standardizes how applications expose tools, resources and prompts to models; its current version is dated 28 July 2026 (MCP specification).
  4. AI features inside software you already run. Your CRM, help desk or ERP vendor may ship AI features. Integration then means configuration, data access and testing, not new code.

Agents bring the most risk because they act. The MCP specification says hosts must obtain explicit user consent before invoking any tool, treats tool descriptions as untrusted unless they come from a trusted server, and notes that MCP itself cannot enforce these principles at the protocol level (MCP specification). Your implementation has to.

How to integrate AI into existing systems step by step

  1. Pick one workflow and one metric. For example, time to resolve a support ticket. Write down the baseline.
  2. Map the systems it touches. List every application, API and data store the workflow reads from or writes to, with an owner for each.
  3. Choose the pattern. API call if the output is a classification or draft; RAG if the answer lives in documents; agent only if the task needs several actions in an order nobody can fix in advance.
  4. Define the interface. Write the contract first: inputs, outputs, error cases, and for agents the exact list of tools and their side effects.
  5. Give the AI its own identity. A service account or delegated user token with the smallest set of permissions, never a shared admin key.
  6. Build an evaluation set. Real cases from logs and tickets, with the answer or action you expect.
  7. Test, then ship to a small group. Run the evaluation in CI, then release behind a feature flag.
  8. Measure against the baseline and decide: widen the rollout, fix or stop.

How do you give AI access to data safely?

Keep authorization in your systems. The OWASP Top 10 for LLM Applications, released on 18 November 2024, puts it directly: implement authorization in downstream systems rather than relying on an LLM to decide if an action is allowed.

LLM risks that matter most when AI touches your systems, and what OWASP recommends

LLM risks that matter most when AI touches your systems, and what OWASP recommends
RiskOWASP mitigations (selected)
LLM01 Prompt injectionEnforce privilege control and least privilege access; require human approval for high-risk actions; segregate and identify external content
LLM02 Sensitive information disclosureEnforce strict access controls; restrict data sources; sanitize data
LLM05 Improper output handlingTreat the model as any other user (zero trust); validate and encode output; use parameterized queries
LLM06 Excessive agencyMinimize extensions, their functions and permissions; execute in the user's context; require user approval; authorize in downstream systems
LLM08 Vector and embedding weaknessesPermission-aware vector and embedding stores; validate and authenticate data sources
LLM10 Unbounded consumptionInput validation; rate limiting

Source: OWASP Top 10 for LLM Applications 2025 (released 18 November 2024)

Three rules cover most cases:

  • Retrieval respects permissions. If a user cannot open a document in the source system, the AI must not quote it to them. That means permission-aware indexes, not one shared vector store.
  • Actions run as the user. When an agent acts on someone's behalf, it uses their scope, so audit logs and limits still work.
  • Access controls exist at all. In IBM's 2025 study, 97% of organizations that reported a breach of AI models or applications had no AI access controls in place (IBM).

If data quality or access is the blocker, fix it before the model. We cover that in AI-ready data.

How do you test an AI integration?

Test the integration and the AI separately, then together.

  • Contract tests for every API the AI calls, so a change in a downstream system fails in CI, not in production.
  • An evaluation suite of real cases with graders, run several times per case, because the same input can give different outputs. See LLM evaluation.
  • Tool-call tests for agents: did it call the right tool, with the right arguments, in the right order? See AI agent testing.
  • Attack cases for prompt injection through documents, emails and web pages the AI reads.
  • Failure tests: what happens when an API times out, returns an error or a rate limit.

How should you roll it out?

In stages, with a person in the loop where mistakes cost money:

  • Shadow mode first. The AI produces answers or proposed actions that people see but do not have to use. Compare them with what people actually did.
  • Human approval for high-impact actions, as OWASP recommends: refunds, record deletion, messages to customers.
  • Limits. Rate limits and budgets per user and per agent, so a loop cannot run up a bill or flood a system.
  • Monitoring. Log every model call and tool call with inputs, outputs, cost and latency, and sample production traffic into the evaluation set.

For risk vocabulary your compliance team will recognize, map the controls to the NIST Generative AI Profile, published on 26 July 2024.

In-house team or AI integration services?

  • In-house works when your engineers know the systems, can add evaluation and AI security skills, and the timeline allows it.
  • AI integration services fit when you need it in production soon, the integration crosses many systems, or nobody on the team has tested non-deterministic output before.
  • A mix often works best: a partner builds the first integration with your engineers, then hands over code, tests and runbooks.

What drives the cost of AI integration?

We have not found a reliable published price range, so here are the factors:

  • Number of systems and whether they have usable APIs.
  • Pattern: an API call is cheaper to build and test than RAG, and RAG is cheaper than an agent that writes to systems.
  • Data work: cleaning, indexing and permission mapping.
  • Security and compliance reviews for regulated data or actions.
  • Evaluation: how many real cases need expert answers.
  • Run cost: model usage, hosting, monitoring and the people who review flagged cases.

Common mistakes

  • Starting with an agent when an API call would do.
  • One admin key for everything. It turns a prompt injection into a full breach.
  • Indexing everything into one store and losing the permissions of the source systems.
  • No baseline, so nobody can tell if the integration helped.
  • Testing only the happy path and never the timeouts, errors and hostile inputs.

How SDCLabs can help

SDCLabs has built and tested software since 2011 and founded the open-source testing frameworks Codeception and CodeceptJS. Senior engineers run AI-assisted workflows, and automated tests verify every change before it ships.

Our API and integration services design the contracts, identities and tests that let AI call your systems safely, including Model Context Protocol (MCP) servers and scoped APIs. Our AI Ready Data Engine builds the pipelines, quality checks, semantic layer, vector search and access control that retrieval depends on. Not sure where to start? An AI readiness assessment maps your systems and data against your top use case and defines a first pilot. Engagements start in 1 to 2 weeks. Talk to us.

Related reading: APIs and integration for AI agents.

Frequently asked questions

What are AI integration services?

Engineering work that connects AI models to the applications, APIs and data you already run: choosing the pattern, building the interface, setting identities and permissions, and testing and monitoring the result. See our API and integration services.

Should I use RAG, an API call or an agent?

Use the simplest one that does the job. An API call suits classification, extraction and drafts; RAG suits answers that live in your documents; an agent only makes sense when the task needs several actions in an order nobody can fix in advance.

What is MCP and do I need it?

The Model Context Protocol standardizes how applications expose tools, resources and prompts to AI models; its current version is dated 28 July 2026 (MCP). You need it when several AI clients must reach the same tools, not for a single API call.

How do you secure an AI integration?

Give the AI its own identity with the smallest permissions, run actions in the user's context, make retrieval respect source permissions, require human approval for high-impact actions and keep authorization in downstream systems, as the OWASP Top 10 for LLM Applications recommends.

How do you test AI integrated into existing systems?

Combine contract tests for every API the AI calls, an evaluation suite of real cases run several times each, tool-call tests for agents, prompt-injection attack cases and failure tests for timeouts and errors. See AI agent testing.

#ai-integration#rag#mcp#ai-security
Mykhailo PoliarushMykhailo PoliarushFounder and CEOLeads SDCLabs, an AI development company founded in Krakow in 2011.LinkedInGitHub

Related posts

Get an estimate for your product.