# AI Model Client

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

To invoke Azure AI methods, instantiate a Model Client. You have two options.

## Option 1: (Recommended) using Statsig Dynamic Config

Using Statsig's Dynamic Config lets you adjust AI invocation parameters and the endpoint without modifying code, giving you maximum flexibility.

In your Statsig console, go to https://console.statsig.com/dynamic\_configs and click **Create** to create a new **Dynamic Config**.

![Dynamic Config creation interface](https://docs.statsig.com/images/integrations/azureai/model-client/29357d6f-c356-461c-afc7-e1673ba97f92.png)

After creation, fill in the properties of this deployment:

![Dynamic Config properties configuration screen](https://docs.statsig.com/images/integrations/azureai/model-client/e4d20573-9d1f-4d62-af11-408435d02f90.png)

The Dynamic Config JSON looks like this:

```plaintext
{
  endpoint: "https://FILL_IN_YOUR_ENDPOINT",
  key: "FILL_IN_YOUR_KEY",
  completion_defaults: {
    frequency_penalty: 0,
    presence_penalty: 0,
    temperature: 1,
    top_p: 1,
    max_tokens: 0,
    stop: [],
    seed: 0,
  },
}
```

After saving the Dynamic Config, instantiate your Model Client using the **id** of that config:

#### NodeJS

```js
const client = AzureAI.getModelClient("<dynamic_config_id>");
```

#### Python

```python
client = AzureAI.get_model_client("<dynamic_config_id>")
```

#### .NET

```csharp
var client = Server.GetModelClient("<dynamic_config_id>");
```

## Option 2: Using hard-coded endpoint and key

This option instantiates an AI model client directly. You must embed the endpoint and key in your code or load them using another mechanism, such as an environment variable.

#### NodeJS

```js
const modelClient = AzureAI.getModelClientFromEndpoint(
    "<DEPLOYMENT_ENDPOINT_URL>",
    "<DEPLOYMENT_KEY>"
);
```

#### Python

```python
modelClient = AzureAI.get_model_client_from_endpoint("<DEPLOYMENT_ENDPOINT_URL>", "<DEPLOYMENT_KEY>")
```

#### .NET

```csharp
var modelClient = Server.GetModelClientFromEndpoint(
    "<DEPLOYMENT_ENDPOINT_URL>",
    "<DEPLOYMENT_KEY>"
);
```
