Skip to main content

JavaScript SDK Overview

The JavaScript/TypeScript SDKs provide comprehensive access to Azure AI services for both Node.js and browser environments. This guide covers installation, authentication, and usage examples.

Installation

Azure AI Foundry SDK

Foundry Local SDK

Azure AI Services

Authentication

All SDKs support Azure Active Directory authentication:
Ensure you’re authenticated with Azure CLI: az login

Azure AI Foundry

Project Client

Connect to your Azure AI Foundry project:

Chat Completions

Use the OpenAI-compatible client:

Streaming Responses

List Connections

Foundry Local

Initialize Manager (Node.js)

List and Download Models

Model Management

OpenAI Integration

Use Foundry Local with the OpenAI SDK:

Browser Usage

For browser environments, manually specify the host:
In browser version, init(), isServiceRunning(), and startService() are not available. Start the service using the Foundry Local CLI.

Azure AI Search

Search Client

Upload Documents

Azure AI Services

Speech Recognition

Speech Synthesis

Content Safety

Error Handling

TypeScript Types

Leverage TypeScript for type safety:

Best Practices

Use environment variables for configuration:
Create .env file:
Always use async/await with proper error handling:
Reuse client instances for better performance:

Package References

REST API

Foundry REST API documentation

Python SDK

Python SDK reference

.NET SDK

C# and .NET SDK documentation

TypeScript Guide

TypeScript documentation