Skip to content

Azure OpenAI Setup

The ai init openai command initializes the Azure OpenAI resource. This command is used to select or create an Azure OpenAI resource. The Azure OpenAI resource is required to use the Azure OpenAI service.

If you don't have the ai CLI installed ...

Before you begin, you'll need to install the ai CLI.

Install the ai CLI

Select or create Azure OpenAI resource
ai init openai

STEP 1: ⇛ Select your Azure subscription (if prompted)
STEP 2: ⇛ Select or create your Azure OpenAI resource
STEP 3: ⇛ Select or create an OpenAI chat model deployment (e.g. gpt-4o)
STEP 4: ⇛ Select or create an OpenAI embeddings model deployment (optional)

View Configuration

To view the persisted configuration, use the following commands:

Get chat endpoint
ai config @chat.endpoint
AI - Azure AI CLI, Version 1.0.0
Copyright (c) 2024 Microsoft Corporation. All Rights Reserved.

chat.endpoint (found at 'D:\src\book-of-ai\.ai\data')

  https://robch-future-900-oai-westus3.cognitiveservices.azure.com/
Get chat key
ai config @chat.key
AI - Azure AI CLI, Version 1.0.0
Copyright (c) 2024 Microsoft Corporation. All Rights Reserved.

chat.key (found at 'D:\src\book-of-ai\.ai\data')

  436172626F6E20697320636F6F6C2121