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.7.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.7-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: az_ai_healthcheck-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 07b23ba1d282c090ac2b0158f0db7a7070ef0f173aaa1c068b2213a86d9e838b
MD5 4f0f3152d9d0b86d2c4546dcf7376e85
BLAKE2b-256 2d6874030e273a21d2c8cc2efb446e52b187a0a6a277d00dd0e1081a184468b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for az_ai_healthcheck-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a9bf49b9606f70cc9aeb8a3a766463beb9eee470c3142f849a84deb8b38d2c8a
MD5 3aaa6d119d5b94dc1853bd0b053a86cf
BLAKE2b-256 d51b0dddbf9b05bb5f369845b3b1ec052061beddf6b1bba77a4af4c08c1a870f

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