Skip to main content

AI Model Client

In order to invoke Azure AI methods, you'll need to instantiate a Model Client. You have two ways of instantiating a Model Client

Using Statsig's Dynamic Config is a clean way to configure your AI Client, which provides maximum flexibility in being able to adjust the AI invocation parameters and even the endpoint without needing to modify code.

In your Statsig console, create a new Dynamic Config by going to: https://console.statsig.com/dynamic_configs, and clicking on Create button.

image

Once created, you can fill in the properties of this deployment like this:

image

The JSON of this looks like this:

{
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,
},
}

Once this is done, you can instantiate your Model Client directly by using the id of this Dynamic Config like this:

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

Option 2: Using hard-coded endpoint and key

This is the most direct way of instantiating an AI model client. However, this would mean you'll have to embed the endpoint and key in your code, or use another way (like an environment variable) to get the model endpoint and key into the process.

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