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

# MeshAI Client

> MeshAI class constructor and configuration reference

The `MeshAI` class is the main entry point for the SDK. All operations (agent management, telemetry, cost, anomalies, and governance) are methods on this class.

## Constructor

```python theme={null}
from meshai import MeshAI

client = MeshAI(
    api_key="msh_...",
    agent_name="my-agent",
    base_url="https://api.meshai.dev",
    environment="production",
    heartbeat_interval=30,
    timeout=10,
    auto_register=False,
)
```

## Parameters

<ParamField path="api_key" type="string" required>
  Your MeshAI API key (`msh_...`). Can also be set via `MESHAI_API_KEY` environment variable.
</ParamField>

<ParamField path="agent_name" type="string">
  Name of the agent this client represents. Required for `register()`, `start_heartbeat()`, and `track_usage()`.
</ParamField>

<ParamField path="base_url" type="string" default="https://api.meshai.dev">
  MeshAI API base URL. Override for self-hosted or staging deployments. Can also be set via `MESHAI_BASE_URL`.
</ParamField>

<ParamField path="environment" type="string" default="production">
  Agent environment. One of `production`, `staging`, or `dev`. Can also be set via `MESHAI_ENVIRONMENT`.
</ParamField>

<ParamField path="heartbeat_interval" type="integer" default="30">
  Seconds between automatic heartbeats when `start_heartbeat()` is called. Can also be set via `MESHAI_HEARTBEAT_INTERVAL`.
</ParamField>

<ParamField path="timeout" type="integer" default="10">
  HTTP request timeout in seconds. Can also be set via `MESHAI_TIMEOUT`.
</ParamField>

<ParamField path="auto_register" type="boolean" default="false">
  If `true`, automatically calls `register()` on initialization. Requires `agent_name` to be set.
</ParamField>

## Properties

| Property          | Type  | Description |                                 |
| ----------------- | ----- | ----------- | ------------------------------- |
| `client.agent_id` | \`str | None\`      | The agent ID after registration |

## Example

```python theme={null}
from meshai import MeshAI

client = MeshAI(
    api_key="msh_...",
    agent_name="production-summarizer",
    environment="production",
)

# Register the agent
agent = client.register(
    framework="crewai",
    model_provider="openai",
    model_name="gpt-4o",
    description="Summarizes customer support tickets",
)

# Start automatic heartbeats
client.start_heartbeat()

# Use any SDK method
summary = client.get_cost_summary()
```

## Method Overview

| Category                                | Methods                                                                                                    |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [Agents](/sdk-reference/agents)         | `register()`, `list_agents()`, `get_agent()`, `update_agent()`, `delete_agent()`                           |
| [Telemetry](/sdk-reference/telemetry)   | `heartbeat()`, `start_heartbeat()`, `track_usage()`                                                        |
| [Cost](/sdk-reference/cost)             | `get_cost_summary()`, `get_cost_by_agent()`, `get_cost_by_model()`                                         |
| [Anomalies](/sdk-reference/anomalies)   | `list_anomalies()`, `get_anomaly()`, `acknowledge_anomaly()`, `resolve_anomaly()`, `get_anomaly_summary()` |
| [Governance](/sdk-reference/governance) | `classify_risk()`, `create_policy()`, `list_approvals()`, `decide_approval()`, `list_audit_events()`       |
| [Compliance](/sdk-reference/compliance) | `get_readiness_score()`, `get_fria()`, `get_transparency_card()`, `create_incident()`                      |
| [Billing](/sdk-reference/billing)       | `get_billing_info()`                                                                                       |
