Skip to main content

Health

Manage health in Credo AI.

Methods

check_liveness

Liveness Probe Kubernetes-style liveness probe endpoint.

This endpoint indicates whether the application is alive and running. It's used by Kubernetes and other orchestration platforms to determine if the container should be restarted.

A successful response (200 OK) indicates the application is alive. If this endpoint fails or returns an error, the orchestration platform may restart the container.

Returns: HealthResponse: A response object with message=True indicating the application is alive.

Example:

GET /livez

# Response:
\{
"message": true
\}

Note:

  • This endpoint should always return quickly (< 1 second)
  • It should not perform expensive operations or external calls
  • Used for liveness probes in Kubernetes deployments
  • Does not require authentication
response = client.health.check_liveness()

Parameters: None

Returns: Response object


check_readiness

Readiness Probe Kubernetes-style readiness probe endpoint.

This endpoint indicates whether the application is ready to serve traffic. It's used by Kubernetes and load balancers to determine if the instance should receive incoming requests.

A successful response indicates the application is ready to handle requests. If this endpoint fails, the instance will be removed from the load balancer pool until it becomes ready again.

This endpoint performs the following readiness checks:

  • Verifies that the CREDOAI_SERVER_BASE_URL service is ready by calling its /readyz endpoint

Returns: HealthResponse: A response object with message=True indicating the application is ready to serve traffic.

Raises: HTTPException: 503 Service Unavailable if any dependency check fails.

Example:

GET /readyz

# Response:
\{
"message": true
\}

Note:

  • This endpoint verifies that all dependencies are available
  • Includes checks for external API availability (CREDOAI_SERVER_BASE_URL)
  • Used for readiness probes in Kubernetes deployments
  • Should return quickly but may be slightly slower than /livez
  • Does not require authentication
response = client.health.check_readiness()

Parameters: None

Returns: Response object


Error Handling

from credoai.errors import ApiError, ClientValidationError
from credoai.auth import AuthenticationError

try:
response = client.health.check_liveness(...)
except ApiError as e:
print(f"API error {e.status_code}: {e.message}")
except ClientValidationError as e:
print(f"Validation error: {e}")
except AuthenticationError as e:
print(f"Auth error: {e}")