Help Needed with Azure/AWS AI Playground Access and Usage

Hi KodeKloud Community,

I recently upgraded to the KodeKloud AI Plan, which includes access to the Azure and AWS AI Playgrounds. I’m looking for some guidance on how to properly use the resources provided with the plan.

I contacted KodeKloud Support regarding this, and they recommended that I post my questions here because the Community/Discord has members with more specialized technical knowledge.

At the moment, I can access the Azure OpenAI Playground, but I’m not sure about the complete process for using the provided Azure/AWS resources.

Could someone please help me understand the following?

Azure AI Playground

  • How should I access and use the Azure OpenAI resources provided with the AI Plan?
  • How do I authenticate with the provided Azure resources?
  • Are there any specific endpoints, API keys, deployments, or other credentials that I need to configure?
  • Which models/resources are available for experimentation?
  • Is there any recommended setup or documentation for getting started?

AWS AI Playground

  • How do I access the AWS AI Playground included with the AI Plan?
  • How should I authenticate/configure the AWS resources?
  • Which AI services/models are available?
  • Are there any prerequisites or recommended steps before using them?

If there is an official KodeKloud guide or documentation covering the Azure/AWS AI Playgrounds, please point me to it as well.

I would really appreciate a step-by-step explanation of how to get started with both playgrounds, particularly the authentication and configuration of the resources provided by KodeKloud.

Thank you in advance for your help!

Best regards,

Nivrutti

I poked around the Azure AI playground a bit, and can see why you might be confused. I’ve asked one of my colleagues, who’s fairly expert in the area, what he thinks might help, and will get back to you.

Thanks! Rob for quick response, I am waiting for further update.

We’ll need to wait to get more info, but in the meantime, here’s something to try:

  • Take a look at this sample code for the OpenAI API; there’s an example directory for Azure OpenAI.
  • The playground creates for you a single project to use. The chat example (these are jupyter notebooks, which VSCode code open for you) needs the endpoint and a key in your environment to work. Setting it up is a bit of a stretch – I did it using “uv”:
    cd azure # the sample code dir
    uv init; uv venv
    uv add python-dotenv
    uv add openai
    
  • The example asks you for a piece of info that I cannot find listed in the Azure UI, annoyingly. You need the existing “deployment” in the Open AI project. I opened a Cloud Shell window and used the command:
    az cognitiveservices account deployment list -g kml_rg_main-RESOURCE-GROUP -n kk_ai_main-THE-OPENAI-PROJ-NAME
    
    This is not particularly “discoverable”, but it will give you what the notebook expects.

This is probably not going to be easy for a beginner, but if you can navigate simple Azure CLI commands, it does work.

Here’s a test script to try that’s based off the info I just gave:

# Sample code to use Azure OpenAI API

import os
import openai
import dotenv
from azure.identity import DefaultAzureCredential, get_bearer_token_provider

dotenv.load_dotenv()

use_azure_active_directory = False  # Set this flag to True if you are using Azure Active Directory

if not use_azure_active_directory:
    endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
    api_key = os.environ["AZURE_OPENAI_API_KEY"]

    client = openai.AzureOpenAI(
        azure_endpoint=endpoint,
        api_key=api_key,
        api_version="2023-09-01-preview"
    )


if use_azure_active_directory:
    endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]

    client = openai.AzureOpenAI(
        azure_endpoint=endpoint,
        azure_ad_token_provider=get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"),
        api_version="2023-09-01-preview"
    )

# We copy this from the Azure OpenAI Studio portal. You can also use the list_deployments() method to get a list of deployments.
deployment = "kk_deploy_main-82b209231e924296" # Fill in the deployment name from the portal here

# For all possible arguments see https://platform.openai.com/docs/api-reference/chat-completions/create
response = client.chat.completions.create(
    model=deployment,
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the air velocity of a laden swallow."},
        {"role": "assistant", "content": "African or European?"},
    ],
    temperature=0.7,
)

print(f"{response.choices[0].message.role}: {response.choices[0].message.content}")

The requirements for this script are:

openai>=1.0.0,<2.0.0
azure-identity>=1.12.0,<2.0.0
python-dotenv