This repository was archived by the owner on Nov 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure_deployment_diag.py
More file actions
59 lines (51 loc) · 1.59 KB
/
azure_deployment_diag.py
File metadata and controls
59 lines (51 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""
Diagnostic script to check Azure OpenAI deployment availability.
This is not a unit test; it's a manual troubleshooting utility.
"""
import os
from dotenv import load_dotenv
from openai import AzureOpenAI
# Load environment variables
load_dotenv()
# Get Azure OpenAI configuration
endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
api_key = os.getenv("AZURE_OPENAI_API_KEY")
model = os.getenv("AZURE_DEPLOYMENT_NAME", "gpt-5-chat")
print(f"Endpoint: {endpoint}")
print(f"API Key: {'***' + api_key[-4:] if api_key else 'None'}")
print(f"Model/Deployment: {model}")
# Test common deployment names
deployment_names = [
"gpt-5-chat",
"gpt-5-mini",
"gpt-5-nano",
"gpt-4o",
"gpt-4.1"
]
client = AzureOpenAI(
azure_endpoint=endpoint,
api_key=api_key,
api_version="2024-02-01"
)
print("\nTesting deployment names:")
for deployment in deployment_names:
try:
print(f"Testing {deployment}...", end=" ")
response = client.chat.completions.create(
model=deployment,
messages=[
{"role": "user", "content": "Hello, world!"}
],
max_tokens=10
)
print("✅ SUCCESS")
print(f" Response: {response.choices[0].message.content}")
break
except Exception as e:
print(f"❌ FAILED: {str(e)}")
print("\nIf none of these work, you'll need to:")
print("1. Check your Azure OpenAI resource in the Azure portal")
print("2. Look at the 'Deployments' section")
print("3. Use the exact deployment name shown there")
print("4. Or create a new deployment if none exist")