az-ai-healthcheck
Lightweight health checks for Azure OpenAI and Azure AI Vision — no heavy SDKs required for OpenAI, and an optional extra for Vision.
- Minimal data-plane calls with tiny payloads and short timeouts
- Clear, predictable behavior (always returns
HealthResult) - Small install footprint; add Vision via optional extras
- Perfect for application startup probes and CI/CD smoke tests
Installation
Core (OpenAI only):
pip install az-ai-healthcheck
With Vision support:
pip install "az-ai-healthcheck[vision]"
Quickstart
Set your credentials (example using environment variables), then call the checks.
import os
from az_ai_healthcheck import check_azure_openai, check_azure_ai_vision
res_aoai = check_azure_openai(
endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
api_key=os.environ["AZURE_OPENAI_API_KEY"],
api_version="2024-02-15-preview",
deployment="gpt-4o-mini",
)
print(res_aoai)
res_vision = check_azure_ai_vision(
endpoint=os.environ["AZURE_VISION_ENDPOINT"],
api_key=os.environ["AZURE_VISION_API_KEY"],
)
print(res_vision)
Sample output
# HealthResult full repr examples (your values will vary)
print(res_aoai)
# HealthResult(provider='azure_openai',
# endpoint='https://my-endpoint.openai.azure.com',
# ok=True,
# status_code=200,
# message='Azure OpenAI reachable. Credentials and deployment appear valid.')
print(res_vision)
# HealthResult(provider='azure_ai_vision',
# endpoint='https://my-cv.cognitiveservices.azure.com',
# ok=False,
# status_code=401,
# message='Azure Vision authentication/permission failed (401/403). Verify API key and endpoint.')
Usage
Azure OpenAI (Chat Completions) health check
from az_ai_healthcheck import check_azure_openai
res = check_azure_openai(
endpoint="https://my-endpoint.openai.azure.com",
api_key="***",
api_version="2024-02-15-preview",
deployment="gpt-4o",
timeout=10.0,
)
print(res.ok, res.status_code, res.message)
Behavior:
- 200 -> ok=True
- else (401/403 and other non-2xx, or network errors) -> ok=False with details
Azure AI Vision (Image Analysis) health check
from az_ai_healthcheck import check_azure_ai_vision
res = check_azure_ai_vision(
endpoint="https://my-cv.cognitiveservices.azure.com",
api_key="***",
timeout=10.0,
)
print(res.ok, res.status_code, res.message)
- Uses
ImageAnalysisClient.analyzewithVisualFeatures.CAPTION. - Sends an in-memory PNG.
use_min_size_image=True(default) uses 50x50 to reduce 400s. use_min_size_image=Falsecan trigger 400 (e.g., InvalidImageSize) → returns ok=False with details.- 404 is treated as failure with guidance (often wrong endpoint/path; occasionally an image too small to analyze).
Notes
- Azure OpenAI uses
requestsonly; no SDK dependency. - Azure Vision requires
azure-ai-vision-imageanalysis(install via extra). - No custom User-Agent header is set (keep requests minimal).
Troubleshooting
- Azure OpenAI 404: API key may be valid, but the endpoint/path, api-version, or deployment is likely incorrect. Verify the endpoint format (no extra path), the
api-version, and the deployment name. - Azure AI Vision 404: Often indicates a wrong endpoint/path. In some cases a too-small test image can also lead to errors—try the default
use_min_size_image=True. - 401/403: Permission/auth errors. Check keys, role assignments, and resource-level access.
CI/CD and startup probes
Use these checks in your pipelines or app startup to fail fast with clear guidance.
def app_startup_probe():
from az_ai_healthcheck import check_azure_openai
res = check_azure_openai(endpoint=..., api_key=..., api_version=..., deployment=...)
if not res.ok:
raise RuntimeError(f"OpenAI health check failed: {res.message}")
Release files for az-ai-healthcheck 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| az_ai_healthcheck-0.1.7.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| az_ai_healthcheck-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 kB
Release files / az_ai_healthcheck-0.1.7.tar.gz
| Download URL | az_ai_healthcheck-0.1.7.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07b23ba1d282c090ac2b0158f0db7a7070ef0f173aaa1c068b2213a86d9e838b
|
|
BLAKE2b-256 checksum How to use checksums |
2d6874030e273a21d2c8cc2efb446e52b187a0a6a277d00dd0e1081a184468b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / az_ai_healthcheck-0.1.7-py3-none-any.whl
| Download URL | az_ai_healthcheck-0.1.7-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9bf49b9606f70cc9aeb8a3a766463beb9eee470c3142f849a84deb8b38d2c8a
|
|
BLAKE2b-256 checksum How to use checksums |
d51b0dddbf9b05bb5f369845b3b1ec052061beddf6b1bba77a4af4c08c1a870f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|