DEV Community

Cover image for AI in APIs
Z for Superface

Posted on • Originally published at superface.ai

AI in APIs

Artificial Intelligence (AI) is making its way into everyday developer life, but the use of AI along the API lifecycle is yet to be improved. For decades APIs have relied on tedious manual work. Tasks like API design, API documentation, discovery, contract, and API integration are primarily manual, but a change is coming.

APIs can leverage AI, and AI can significantly benefit from APIs. Though the use of AI in APIs is a vast topic, we will split it into two. The first is employing AI (precisely ML – machine learning algorithms) to deliver or integrate APIs. The second topic is enabling AI, which can either mean making AI accessible via APIs or making the APIs accessible to an AI.

Using AI in APIs

Using AI/ML can enhance a developer's life, boost efficiency, and lead to better applications and shorter delivery times. Following are a few examples of employing AI in APIs delivery and consumption.

AI client and server code-gen

The most straightforward use of AI/ML is to generate API calls or server code on behalf of a programmer. Solutions like GitHub Copilot can create code stubs, reducing developers' need to write the API calls boilerplate. As a larger corpus of API calls is needed, this approach is primarily suitable for public APIs.

Screenshot of JavaScript function for fetching a NASA Picture of the Day fully generated by Copilot

API client code generation with GitHub Copilot

AI API design

A good API design is a function of developer experience and operational efficiency. Algorithm-guided API design can improve the efficient layout of resources. Traffic recording and profiling information from API observability tools (Akita, Optic, Seekret, …) already provide valuable insights and can be the input for the AI-guided API design.

AI can also aid in designing APIs from the ground up, mapping the use cases into correct API protocol/style semantics. For example, from the operation name "make payment," the algorithm may infer an unsafe, idempotent operation and, therefore, the POST HTTP method.

Screenshot of Jurassic-X prompt: "What HTTP method to use for 'make payment'" and an answer suggesting to use POST method

Jurrasic-X assists in mapping a use case to an HTTP method

AI API integration

The opposite approach to AI-guided API design is that an algorithm can infer what operation to invoke, what the parameters are, and how to map them from the user input to the expected result. These algorithms can take a business case for an API (e.g., "how to fulfill an order") and API documentation as input and figure out the required API communication to complete the use case.

Screenshot of a prompt for OpenAI GPT-3 asking how to fulfill an order and autocompleted answer detailing what HTTP method, URL, parameters, and payload should be used.

OpenAI GPT-3 aiding with API integration

AI API security

Currently, the most mature area is using AI/ML algorithms to analyze valuable information from the API traffic. For example, an algorithm can check whether there are sensitive data in the traffic or when a malicious communication pattern threatens your systems. The existing tools (Traceable, Aiculus) already help security, DevOps, and compliance teams in their work.

Levels of enabling AI

Beyond helping developers deliver or consume APIs, AI can greatly benefit from them. Here's how APIs will gradually enable AI.

1. APIs as the interface to AI

APIs are vital in making AI and its infrastructure accessible to other applications. Many AI/ML models and algorithms are proprietary (OpenAI) or resource-consuming, so they can't be self-hosted by their users. API is the standard way to make AI available in these cases. The same applies to AI/ML and data science infrastructure (Google, Azure, AWS), where users can develop and run their models.

2. Self-integrating applications

Self-integrating applications are the revolutionary step in distributed systems. It enables applications to integrate without the need for human intervention. This integration can be direct between two applications or via an intermediary – an integration platform.

Advanced integration platforms can infer common integration patterns, and when a new application enters the organizational landscape, it can be automatically hooked into the existing applications.

Several integration platforms already employ algorithms to assist engineers in their repetitive tasks of data mapping and system integrations (Dell Boomi, Snaplogic). Still, we need the new infrastructure to enable applications to integrate without assistance.

Superface is the pioneer in direct self-integrating applications, enabling them to integrate autonomously without needing an intermediary.

3. Autonomous applications

An autonomous application can navigate and make decisions in its landscape. Unlike a self-integrating application, an autonomous application can decide which API to connect and when.

The critical difference to the present API clients is that the autonomous applications are programmed for a job, not how the job is executed with a particular API at a given time.

To illustrate, a manufacturing application can be programmed to check the status of the works on the product. However, it is not instructed on how to do it and what APIs to ask. Instead, when executed within a landscape, the application will determine what APIs are available and which ones to call to get the answer.

Conceptual scheme of autonomous APIs: the client application asks a landscape registry on what's available and learns how to connect; the API announces to the registry its presence and connection instructions for the client; the API communication is then direct between the client and the API.

Autonomous application conceptual scheme

4. Autonomous Business Integrations

Autonomous business integrations take the concept of autonomous application to the next level. The application can discover and connect to an API without human intervention, but it can also enter a business contract on its user's behalf. The autonomous business integrations (ABI) will fully unlock the digital business-making where software can evaluate, enter or fulfill contracts.

An example would be a commerce application that needs to send text messages to its users in various countries. At any given time, such an application can quickly evaluate all available API providers, their costs and quality, make the purchase, and send the messages at the best price and quality.

5. AI applications

The pinnacle of interfaces for AI is a system where the tasks are not hard-coded in the application. Instead, the application can infer (e.g., for a user's input) what job to execute, the available APIs in its landscape to fulfill the task, and which one to use. This ultimate step will unlock the reasoning AI that would be able to navigate in the universe of humanity's capabilities.

But if the technological Singularity can happen, it will.

– Vernor Vinge


At Superface.ai, we are committed to researching and advancing AI in APIs. We have released the infrastructure for self-integrating applications and are heading forward to introducing the autonomous business integrations and, at a later stage, towards the AI systems.

If you are working in one of the areas, or you think I've missed one, let me know in comments!

Top comments (0)