Skip to main content
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

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

api_key
string
required
Your MeshAI API key (msh_...). Can also be set via MESHAI_API_KEY environment variable.
agent_name
string
Name of the agent this client represents. Required for register(), start_heartbeat(), and track_usage().
base_url
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.
environment
string
default:"production"
Agent environment. One of production, staging, or dev. Can also be set via MESHAI_ENVIRONMENT.
heartbeat_interval
integer
default:"30"
Seconds between automatic heartbeats when start_heartbeat() is called. Can also be set via MESHAI_HEARTBEAT_INTERVAL.
timeout
integer
default:"10"
HTTP request timeout in seconds. Can also be set via MESHAI_TIMEOUT.
auto_register
boolean
default:"false"
If true, automatically calls register() on initialization. Requires agent_name to be set.

Properties

PropertyTypeDescription
client.agent_id`strNone`The agent ID after registration
client.agent_name`strNone`The agent name
client.is_registeredboolWhether the agent has been registered

Example

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

CategoryMethods
Agentsregister(), list_agents(), get_agent(), update_agent(), delete_agent()
Telemetryheartbeat(), start_heartbeat(), track_usage()
Costget_cost_summary(), get_cost_by_agent(), get_cost_by_model()
Anomalieslist_anomalies(), get_anomaly(), acknowledge_anomaly(), resolve_anomaly(), get_anomaly_summary()
Governanceclassify_risk(), create_policy(), list_approvals(), decide_approval(), list_audit_events()
Complianceget_readiness_score(), get_fria(), get_transparency_card(), create_incident()
Billingget_billing_info()