Skip to content

Configure an AI Connection

This tutorial demonstrates how to configure the AiConnection object used by AI-powered workflows, services, and application logic in Lowgile applications.

By the end of this tutorial, the configured AI connection will:

  • Connect the application to an AI provider,
  • Authenticate AI requests using provider credentials,
  • Configure the Large Language Model (LLM) used by the application, and
  • Enable optional LangSmith tracing.

Before beginning this tutorial, ensure the following resources are available:

  • Credentials for the AI provider and LLM you want to configure, and
  • LangSmith API credentials if tracing is enabled.
  1. Open the Lowgile platform editor.
  2. Select Configure from the left navigation.
  3. Open Settings.
  4. Locate Module Common.
  5. Open the Common.AiConnection dialog by clicking on the pencil icon.

Tip

For secret properties such as apiKey and tracingApiKey, click Set new value in the AiConnection editor to enter the secret value.

Set new value buttons for secret properties in the AiConnection editor
Figure 1:

Set new value buttons for secret properties in the AiConnection editor.

  1. Configure the following property values:

Note

This tutorial uses Azure OpenAI as the AI provider.

PropertyValueDescription
aiTypeAzureOpenAiSelects Azure OpenAI as the AI provider type.
instanceName<YOUR_AZURE_OPENAI_NAME>Identifies the Azure OpenAI resource or provider instance used by the connection.
deploymentNamegpt-4oSpecifies the model deployment used for chat, text-generation, or multimodal extraction calls.
embeddingsDeploymentNametext-embedding-3-smallSpecifies the embeddings deployment used when the application creates or queries embeddings.
apiKey<YOUR_API_KEY>Stores the Azure OpenAI API key used to authenticate requests.
apiVersion2024-06-01Specifies the Azure OpenAI API version used by the connection.
tracingEnabledtrueEnables tracing for AI calls.
tracingEndpointhttps://api.smith.langchain.comSpecifies the LangSmith tracing endpoint.
tracingApiKey<YOUR_TRACING_API_KEY>Stores the LangSmith API key used when tracing is enabled.
usdPer1000InputTokens0.005Defines the estimated input-token cost used for usage-cost tracking.
usdPer1000OutputTokens0.015Defines the estimated output-token cost used for usage-cost tracking.
  1. Click the Save button to close the AI Connection dialog.
  1. Use the console to verify that the configured AiConnection works correctly.

Remember: Open the console by clicking the console icon in the top-right nav bar, or press F8.

  1. Keep the module context set as wildcard (*) option

  2. Initialize the AI service using the global namespace with :

const ai = new Sys.Ai.SimpleAi(Common.$Config.AiConnection)
  1. Run a simple AI query:
return await ai.queryAndReturnText('What is the capital city of France?')
  1. If the AI connection is configured correctly, the console returns the following AI-generated response:
"The capital city of France is Paris."
Result [0] in 2230ms