Here are examples for each of the key areas of the Azure OpenAI REST API that are important for the AI-102 exam:
Control Plane API
Example: Creating an Azure OpenAI Resource
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.CognitiveServices/accounts/{account-name}?api-version=2024-10-01
Request Body:
{
"location": "eastus",
"sku": {
"name": "S0"
},
"kind": "OpenAI",
"properties": {
"networkAcls": {
"defaultAction": "Deny",
"virtualNetworkRules": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Network/virtualNetworks/{vnet-name}/subnets/{subnet-name}"
}
]
}
}
}
This example shows how to create an Azure OpenAI resource using the control plane API 1.
Data Plane - Authoring API
Example: Fine-Tuning a Model
POST https://{endpoint}/openai/deployments/{deployment-id}/fine-tune?api-version=2024-10-21
Request Body:
{
"training_file": "file-id",
"model": "gpt-4",
"hyperparameters": {
"batch_size": 32,
"learning_rate": 0.01
}
}
This example demonstrates how to fine-tune a model using the authoring API 1.
Data Plane - Inference API
Example: Creating a Completion
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-10-21
Request Body:
{
"prompt": "Translate the following English text to French: 'Hello, how are you?'",
"max_tokens": 60,
"temperature": 0.7
}
This example shows how to create a completion for a given prompt using the inference API 1.
Authentication
Example: API Key Authentication
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-10-21
Headers:
api-key: YOUR_API_KEY
This example demonstrates how to authenticate API calls using an API key 1.
REST API Versioning
Example: Specifying API Version
POST https://{endpoint}/openai/deployments/{deployment-id}/completions?api-version=2024-10-21
This example shows how to specify the API version using the api-version
query parameter 1.
These examples cover the essential aspects of the Azure OpenAI REST API that are relevant for the AI-102 exam. If you have any specific questions or need further assistance, feel free to ask!
Are you ready to dive deeper into your exam preparation? 😊
1: Azure OpenAI REST API reference