Building APIs for Generative AI. Developer setup and best practices.
O'Reilly Super Stream | July 2024
Natalia Venditto
microfrontend.dev - @anfibiacreativa
Image credit DALLE3
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/10953587/91bcacba-efb2-4ad0-b77a-d6e9af548fb8.jpg)
Principal Owner JavaScript DX, Azure
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455970/nataliavenditto.png)
Once upon a time, developers built APIs for the web.
© DallE 3
Today, developers build APIs for the web -and AI-.
ML/DATA PROFESSIONALS
WEB DEVELOPERS
Who understand AI and have been working with it and different models for a long time.
Backend and frontend developers that must integrate AI in their workloads.
!==
WEB DEVELOPERS
Backend and frontend developers that must integrate AI in their workloads.
Where to start
Application Design
microfrontend.dev - @anfibiacreativa
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
EFFECTIVE APPLICATION DESIGN IS COMPOSABLE AND API-CENTRIC
A green field or brown field web application, will more likely succeed and demand more effort to integrate with AI -and other emerging technologies- when it's API-First at its core.
AI MODELS
USE-CASE
TECH STACK
DESIGN
Understanding the use-case in depth.
microfrontend.dev - @anfibiacreativa
Designing the user interface and the API specification on top of it.
Selecting the tech-stack including the frameworks and middleware and the database model
>>>
>>>
Web Development
USE-CASE
MODEL/PATTERN
DESIGN
Understanding the use-case in depth, is of higher priority than it ever was.
microfrontend.dev - @anfibiacreativa
Designing the user interface and the API specification on top of it.
Defines whether retrieval is based on text similarity or vector representation.
ORCHESTRATOR
Tech-stack and frameworks to orchestrate, offer the ability to reduce the effort in API development.
Web Development + AI
The process
Business Automation
Customer Support
Personalization
Analytics
Other...
High level use-cases
Customer Support
API/Model
Language/Framework
Pattern
CHAT BOT
COMPLETIONS/GPT 4O
RAG
TS/LANGCHAIN.JS
Building blocks*
excluding deployment infrastructure and pipelines
API/Model
COMPLETIONS/GPT 4O
Retrieval
Embeddings
Data Sources
The model in depth
Tools
eg: Function Calling
DATASET
Response
Retriever
SELECTS RELAVANT PASSAGES
FORMULATES RESPONSE
microfrontend.dev - @anfibiacreativa
DATASET
Response
Retriever
SELECTS RELAVANT PASSAGES
FORMULATES RESPONSE
microfrontend.dev - @anfibiacreativa
Message Processing API
User Interaction API
Model Interaction API
Knowledge Base Retrieval API
Embeddings API
User input and chatbot responses
Messages routing and preprocessing
Interactions with the GPT model deployed to a service
Information retrieval from a knowledge base
Embeddings generation and management
Custom APIs
Message Processing API
User Interaction API
Model Interaction API
Knowledge Base Retrieval API
Embeddings API
User input and chatbot responses
Messages routing and preprocessing
Interactions with the GPT model deployed to a service
Information retrieval from a knowledge base
Embeddings generation and management
SDK
Orchestrator
An API contracts helps us swap between
- local and remote models
- different languages and orchestrators
microfrontend.dev - @anfibiacreativa
microfrontend.dev - @anfibiacreativa
User Interaction API
User input and chatbot responses
The Chat App Protocol as example
A collection of types and functionality as a contract for Chat Applications.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455938/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455955/qrcode_github.com__1_.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11414036/05-30-24-api-example.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455955/qrcode_github.com__1_.png)
Go to app code demo, swapping backends.
Patterns
Versioning
Spec authoring
Multiple protocols
Diagnostics
API challenges
Extensibility
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455952/Screenshot_2024-07-05_at_4.24.32_PM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/11455953/qrcode_typespec.io.png)
Go to generating an API with TypeSpec demo.
TypeSpec
A framework to describe API shapes using declarations, interfaces, models, decorators, enums, unions, type literals, and other entities idiomatic to TypeScript developers, to emit contracts and specifications.
Thank you!
@anfibiacreativa - https://www.microfrontend.dev
Learn more
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1325595/images/10961059/Screenshot_2023-11-29_at_7.51.54_PM.png)
All images except those that credited to Unsplash and respective author, were generated with Bing Image Generator.
Generative AI Developer Setup and Best Practices
By Natalia Venditto
Generative AI Developer Setup and Best Practices
- 47