Skip to main content

Lightweight health checks for Azure OpenAI and Azure AI Vision

Project description

az-ai-healthcheck

Python package License: MIT Downloads Downloads

GitHub contributors GitHub issues GitHub pull-requests PRs Welcome

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.analyze with VisualFeatures.CAPTION.
  • Sends an in-memory PNG. use_min_size_image=True (default) uses 50x50 to reduce 400s.
  • use_min_size_image=False can 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 requests only; 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}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

az_ai_healthcheck-0.1.6.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

az_ai_healthcheck-0.1.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file az_ai_healthcheck-0.1.6.tar.gz.

File metadata

  • Download URL: az_ai_healthcheck-0.1.6.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for az_ai_healthcheck-0.1.6.tar.gz
Algorithm Hash digest
SHA256 01e319d955e0df51f1d4f65b75d30e699acb3774e47999555d2e93c8935bbd9f
MD5 fe9c4d7c772914590a6b8d42f67460fe
BLAKE2b-256 407094ed362fa639b0864408e9be9bfec73299945b57d3f1d44c511e95ffbd19

See more details on using hashes here.

File details

Details for the file az_ai_healthcheck-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for az_ai_healthcheck-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d855a5f3404f23cb8247eca208014372e06ba31d3346e7d8dcdef7d67c23a70
MD5 a54b4f042638fd7d2af538467c1b9437
BLAKE2b-256 98bdab031c6e8d4f9de4e730160ffb261e82e253fc9ec44342220541c65160da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page