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
Option 1: (Recommended) Using Statsig Dynamic Config
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.
Once created, you can fill in the properties of this deployment like this:
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:
- NodeJS
- Python
- .Net
const client = AzureAI.getModelClient("<dynamic_config_id>");
client = AzureAI.get_model_client("<dynamic_config_id>")
var client = Server.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.
- NodeJS
- Python
- .Net
const modelClient = AzureAI.getModelClientFromEndpoint(
"<DEPLOYMENT_ENDPOINT_URL>",
"<DEPLOYMENT_KEY>"
);
modelClient = AzureAI.get_model_client_from_endpoint("<DEPLOYMENT_ENDPOINT_URL>", "<DEPLOYMENT_KEY>")
var modelClient = Server.GetModelClientFromEndpoint(
"<DEPLOYMENT_ENDPOINT_URL>",
"<DEPLOYMENT_KEY>"
);