|
| 1 | +# Azure ChatProtocol REST client library for JavaScript |
| 2 | + |
| 3 | +Azure APIs for the Azure Chat protocol. |
| 4 | + |
| 5 | +**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** |
| 6 | + |
| 7 | +Key links: |
| 8 | + |
| 9 | +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/machinelearning/ai-chat-protocol) |
| 10 | +- [Package (NPM)](https://www.npmjs.com/package/@azure/ai-chat-protocol) |
| 11 | +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure/ai-chat-protocol?view=azure-node-preview) |
| 12 | +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/machinelearning/ai-chat-protocol/samples) |
| 13 | + |
| 14 | +## Getting started |
| 15 | + |
| 16 | +### Currently supported environments |
| 17 | + |
| 18 | +- LTS versions of Node.js |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | + |
| 22 | +- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. |
| 23 | + |
| 24 | +### Install the `@azure/ai-chat-protocol` package |
| 25 | + |
| 26 | +Install the Azure ChatProtocol REST client REST client library for JavaScript with `npm`: |
| 27 | + |
| 28 | +```bash |
| 29 | +npm install @azure/ai-chat-protocol |
| 30 | +``` |
| 31 | + |
| 32 | +### Create and authenticate a `ChatProtocolClient` |
| 33 | + |
| 34 | +To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), |
| 35 | +provide an instance of the desired credential type obtained from the |
| 36 | +[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. |
| 37 | + |
| 38 | +To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) |
| 39 | + |
| 40 | +After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. |
| 41 | +As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) |
| 42 | +can be used to authenticate the client. |
| 43 | + |
| 44 | +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: |
| 45 | +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET |
| 46 | + |
| 47 | +## Troubleshooting |
| 48 | + |
| 49 | +### Logging |
| 50 | + |
| 51 | +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: |
| 52 | + |
| 53 | +```javascript |
| 54 | +const { setLogLevel } = require("@azure/logger"); |
| 55 | + |
| 56 | +setLogLevel("info"); |
| 57 | +``` |
| 58 | + |
| 59 | +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). |
0 commit comments