> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sudoapp.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# System Endpoints

> Health checks and model information endpoints

The system endpoints provide information about the Sudo API status and available models. These are typically used for health monitoring and discovering available AI models.

## Health Check

Check if the Sudo API and backend infrastructure are healthy and ready to accept connections.

### Basic Usage

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { Sudo } from "sudo-ai";

  const sudo = new Sudo({
    serverURL: "https://sudoapp.dev/api",
    apiKey: process.env.SUDO_API_KEY ?? "",
  });

  async function checkHealth() {
    try {
      // Check API health
      const healthStatus = await sudo.system.healthCheck();
      console.log(`API Status: ${JSON.stringify(healthStatus)}`);
    } catch (error) {
      console.error("Health check failed:", error);
    }
  }

  checkHealth();
  ```

  ```python Python theme={null}
  import os
  from sudo import Sudo

  with Sudo(
      server_url="https://sudoapp.dev/api",
      api_key=os.getenv("SUDO_API_KEY"),
  ) as client:
      # Check API health
      health_status = client.system.health_check()
      print(f"API Status: {health_status}")
  ```
</CodeGroup>

### Python Async Usage

<CodeGroup dropdown>
  ```python Python theme={null}
  import asyncio
  import os
  from sudo import Sudo

  async def check_health():
      async with Sudo(
          server_url="https://sudoapp.dev/api",
          api_key=os.getenv("SUDO_API_KEY"),
      ) as client:
          health_status = await client.system.health_check_async()
          return health_status

  # Run the async function
  health = asyncio.run(check_health())
  print(f"API Status: {health}")
  ```
</CodeGroup>

## Get Supported Models

Retrieve a list of all AI models supported by the Sudo API, including their capabilities and pricing information.

### Basic Usage

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { Sudo } from "sudo-ai";

  const sudo = new Sudo({
    serverURL: "https://sudoapp.dev/api",
    apiKey: process.env.SUDO_API_KEY,
  });

  async function getSupportedModels() {
    try {
      const models = await sudo.system.getSupportedModels();

      console.log(`Available models: ${models.data.length}`);
      models.data.forEach(m => {
        console.log(`- ${m.modelName} (${m.modelProvider})`);
      });
    } catch (error) {
      console.error("Failed to get models:", error);
    }
  }

  getSupportedModels();
  ```

  ```python Python theme={null}
  import os
  from sudo import Sudo

  with Sudo(
      server_url="https://sudoapp.dev/api",
      api_key=os.getenv("SUDO_API_KEY"),
  ) as client:
      # Get all supported models
      models = client.system.get_supported_models()
      
      print(f"Available models: {len(models.data)}")
      for model in models.data:
          print(f"- {model.model_name}: {model.model_provider}")
  ```
</CodeGroup>

### Python Async Usage

<CodeGroup dropdown>
  ```python Python theme={null}
  import asyncio
  import os
  from sudo import Sudo

  async def get_models_info():
      async with Sudo(
          server_url="https://sudoapp.dev/api",
          api_key=os.getenv("SUDO_API_KEY"),
      ) as client:
          models = await client.system.get_supported_models_async()
          return models

  # Get models asynchronously
  models = asyncio.run(get_models_info())
  print(f"Found {len(models.data)} models")
  ```
</CodeGroup>

## Error Handling

Both system endpoints can encounter various errors. Here's how to handle them:

<CodeGroup dropdown>
  ```typescript TypeScript theme={null}
  import { Sudo } from "sudo-ai";
  import * as errors from "sudo-ai/models/errors";

  const sudo = new Sudo({
    serverURL: "https://sudoapp.dev/api",
    apiKey: process.env.SUDO_API_KEY ?? "",
  });

  async function systemEndpointsWithErrorHandling() {
    try {
      // Try health check
      const health = await sudo.system.healthCheck();
      console.log("✅ Health check passed");
      
      // Try getting models
      const models = await sudo.system.getSupportedModels();
      console.log(`✅ Retrieved ${models.data.length} models`);
      
    } catch (error) {
      if (error instanceof errors.SudoError) {
        if (error.statusCode === 401) {
          console.log("❌ Authentication failed - check your API key");
        } else if (error.statusCode >= 500) {
          console.log("❌ Server error - the API may be experiencing issues");
        } else {
          console.log(`❌ API error: ${error.message}`);
          console.log(`Status: ${error.statusCode}`);
        }
        
        if (error instanceof errors.ErrorResponse) {
          console.log(`Error details: ${error.data$.error}`);
        }
      } else {
        console.log(`❌ Unexpected error: ${error}`);
      }
    }
  }

  systemEndpointsWithErrorHandling();
  ```

  ```python Python theme={null}
  import os
  from sudo import Sudo, errors

  with Sudo(
      server_url="https://sudoapp.dev/api",
      api_key=os.getenv("SUDO_API_KEY"),
  ) as client:
      try:
          # Try health check
          health = client.system.health_check()
          print("✅ Health check passed")
          
          # Try getting models
          models = client.system.get_supported_models()
          print(f"✅ Retrieved {len(models.data)} models")
          
      except errors.ErrorResponse as e:
          if e.status_code == 401:
              print("❌ Authentication failed - check your API key")
          elif e.status_code >= 500:
              print("❌ Server error - the API may be experiencing issues")
          else:
              print(f"❌ API error: {e.message}")
              print(f"Status: {e.status_code}")
              
      except errors.SudoError as e:
          print(f"❌ SDK error: {e.message}")
          
      except Exception as e:
          print(f"❌ Unexpected error: {e}")
  ```
</CodeGroup>

## Next Steps

Now that you understand the system endpoints:

1. **[Try AI Responses](/sdk/sudo-sdk/ai-responses)** - Start creating AI responses
2. **[Explore Streaming](/sdk/sudo-sdk/streaming)** - Add real-time capabilities
3. **[Advanced Features](/sdk/sudo-sdk/tool-calling)** - Function calling and more

<Tip>
  Use the health check endpoint in your application's readiness probes and the models endpoint to dynamically discover available AI models. Both TypeScript and Python SDKs provide the same system information with language-appropriate handling.
</Tip>
