Microsoft Dev Blogs

Announcing the public preview of the Microsoft AI Chat Protocol library for JavaScript

thumbnail

Table of Contents


Introduction

The Microsoft AI Chat Protocol library for JavaScript is now available for public preview, offering developers a way to build AI-powered frontends easily. The library abstracts implementation-specific details, providing a clear separation between frontend and AI backend development workstreams. By adhering to the AI Chat Protocol API specification, a middle-tier endpoint can be used to access the AI backend, enabling communication between the frontend and backend.


Installation

The AI Chat Protocol library can be downloaded from npm. Ensure that the middle-tier endpoint meets the AI Chat Protocol API specification requirements. If authentication is necessary, TokenCredential can be passed in during installation.

npm install @microsoft/ai-chat-protocol

Usage

Once the client is set up in the frontend application, messages can be sent to the middle-tier endpoint to receive responses synchronously or via streaming. This code snippet demonstrates the use of React Hooks for handling the AI backend responses.

// Code example for sending messages to the middle-tier endpoint

Summary

The Microsoft AI Chat Protocol library for JavaScript provides developers with a streamlined way to integrate AI backend responses into their applications. By adhering to the AI Chat Protocol API specification, developers can consume different AI backends consistently and efficiently. The library is available on npm and open-source on GitHub.

For more information, refer to: