The AI-102 exam has been retired
It was retired on June 30, 2026. It was replaced by AI-103 (Microsoft Azure AI Apps and Agents Developer Associate). Go to the AI-103 study guide →
Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.
3.2.1.2. Sampling and Generation Parameters
3.2.1.2. Sampling and Generation Parameters
Sampling parameters control the randomness and creativity of generated responses. Understanding these is critical for the exam.
Testable Pattern:
from openai import AzureOpenAI
client = AzureOpenAI(azure_endpoint=endpoint, api_key=key, api_version="2024-08-01-preview")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
temperature=0.7
)
answer = response.choices[0].message.content
Error Handling Pattern:
from openai import AzureOpenAI, APIError, RateLimitError
try:
response = client.chat.completions.create(model="gpt-4o", messages=messages)
except RateLimitError:
# Back off and retry - quota exceeded
time.sleep(60)
except APIError as e:
# Log error details: e.status_code, e.message
logging.error(f"API error: {e.status_code}")
CLI Equivalent (REST):
curl -X POST "https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version=2024-08-01-preview" \
-H "Content-Type: application/json" \
-H "api-key: {key}" \
-d '{"messages": [{"role": "user", "content": "Hello"}]}'
⚠️ Exam Trap: temperature=0 gives deterministic output; temperature=1.0+ increases creativity.
Written byAlvin Varughese
Founder•18 professional certifications