liveBook · Manning

Interface

As explained in Designing AI Systems

A consistent interface is a uniform software interface that presents the same interaction model across different implementations or providers.

A consistent interface gives consumers the same interaction model across different implementations or providers. It keeps application code focused on the operation requested while adapters handle implementation-specific details. Without it, each new workflow or model provider can require custom integration code. section 2.3.1 section 3.2.2

For model inference, applications request a model through the Model Service. The service routes the request and applies configured fallback logic; provider adapters translate messages, responses, and errors. Adding a provider means implementing another adapter rather than changing application calls. section 3.2.2 section 3.10

Listing 3.8 Provider adapter interface
from abc import ABC, abstractmethod
from typing import List, Iterator
 
class ModelProvider(ABC):
    """Abstract base class that all provider adapters implement"""
 
    @abstractmethod
    def chat(self, model: str, messages: List[ChatMessage],
             config: ChatConfig) -> ChatResponse:    #A
        """Generate a response synchronously"""
        pass
 
    @abstractmethod
    def chat_stream(self, model: str, messages: List[ChatMessage],
                    config: ChatConfig) -> Iterator[ChatChunk]:    #B
        """Generate a response with streaming tokens"""
        pass
 
    @abstractmethod
    def get_capabilities(self) -> List[ModelInfo]:    #C
        """Report what this provider supports"""
        pass

The Python ModelProvider contract requires synchronous chat, streaming chat, and capability reporting. Concrete adapters implement those operations for their providers. section 3.2.2

A uniform interface does not imply identical capabilities. The minimal provider contract includes get_capabilities() so the service can discover differences such as vision support, function calling, and context window size. section 3.2.2

Normalizing provider differences

OpenAI places system prompts in the messages array, while Anthropic accepts them as a separate parameter. Their response structures and token-count fields also differ. Adapters translate these conventions so applications can switch providers and aggregate usage without provider-specific parsing in application code. section 3.2.1 section 3.10

The same principle applies to workflow endpoints: workflows within a domain share authentication mechanisms, response formats, and API conventions. A registered custom model likewise remains accessible by name through the Model Service, retaining its consistent response format, logging, and fallback support instead of bypassing the platform. section 2.3.2 section 3.1.4

How Designing AI Systems covers it

How deep it goes
Defines a minimal abstract provider contract and explains adapter translation, routing, fallback configuration, and capability reporting.
Examples
Compares OpenAI, Anthropic, and Google message formats, response structures, and token fields.
What you can do after
Evaluate and understand how a shared provider contract enables model switching without changing application code.
How it connects
Connects the adapter pattern with routing, fallback, capability discovery, and gRPC contracts.

Also explained in

Compare how 13 books explain interface →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.