Skip to content

Python SDK

Read your account, workspaces, pods, storage, assets, GPUs, templates, serverless deployments, and machines from Python with the sync Meshive and async AsyncMeshive clients — typed models and a structured error hierarchy.

The SDK exposes two clients with identical method names — Meshive (synchronous) and AsyncMeshive (asyncio). Both read the same credentials and configuration as the CLI (see Authentication).

from meshive import Meshive
with Meshive() as client: # reads MESHIVE_API_KEY
me = client.me()
print(me.email, me.user_role)
for ws in client.list_workspaces():
print(ws.namespace_name, ws.status)
detail = client.get_workspace("my-workspace")
print(detail.price_per_hour, detail.gpus)
pods = client.list_pods("my-workspace")
pod = client.get_pod(pods[0].pod_name, "my-workspace")
print(pod.status, pod.raw) # .raw holds the full payload
usage = client.get_pod_metrics(pod.pod_name, "my-workspace")
print(usage.cpu_usage_rate, [g.vram_usage_rate for g in usage.gpus])
# what can I rent right now?
for gpu in client.list_gpus(min_vram=40):
print(gpu.gpu_model, gpu.vram, gpu.price_per_hour, gpu.available_gpus)
credit = client.get_credit()
print(credit.paid_balance, credit.bonus_balance)
# host view: the machines you contribute to the network
machines = client.list_machines()
for m in machines:
print(m.machine_id, m.status, m.gpu_count, m.gpu_model)
machine = client.get_machine(machines[0].machine_id)
print(machine.earning_hourly, machine.raw)

Using the client as a context manager (with / async with) ensures the underlying HTTP connection is closed. Otherwise, call client.close() (or await client.close()) yourself.

Meshive(api_key=None, *, base_url=None, timeout=30.0, max_retries=2)
AsyncMeshive(api_key=None, *, base_url=None, timeout=30.0, max_retries=2)

With no arguments, credentials resolve in the usual order (explicit argument › environment variable › meshive login file). You can also pass the key explicitly:

client = Meshive(api_key="meshive_xxxxxxxx")

timeout is the per-request timeout in seconds (default 30.0). max_retries controls automatic retries of rate limits, gateway errors and dropped connections (0 disables them). If no API key can be resolved, the first request raises ConfigurationError.

Both clients expose the same methods (await them on AsyncMeshive):

MethodReturnsDescription
me()WhoAmIThe current API key’s owner.
list_api_keys()list[ApiKey]Your active API keys (prefixes only).
get_credit()CreditCredit balance and auto-recharge setting.
list_credit_history(*, start_date=None, end_date=None)list[CreditHistoryEntry]Top-ups and refunds (default: last 90 days).
list_workspaces()list[Workspace]Workspaces you can access.
get_workspace(workspace)WorkspaceDetailCost and resource summary of one workspace.
list_members(workspace)list[Member]Members of a workspace.
list_pods(workspace)list[Pod]Pods in a workspace (by ID).
get_pod(pod_name, workspace)PodA single pod.
wait_for_pod(pod_name, workspace, *, until="running", timeout=600, interval=5)PodPoll until the pod reaches a status.
get_pod_metrics(pod_name, workspace)PodMetricsLive CPU/RAM/GPU/disk usage of a pod.
list_storages(workspace)list[Storage]Storages (volumes) in a workspace.
get_storage(storage_name, workspace)StorageA single storage.
list_gpus(*, rental_type="demand", min_vram=None)list[GpuAvailability]GPU tiers you can rent right now, with prices.
list_templates(workspace=None, *, app_type=None)list[Template]Official templates, plus a workspace’s custom ones when workspace is given.
get_template(template_id, workspace=None)TemplateA single template (custom ones need their workspace).
list_servings(workspace)list[Serving]Serverless serving deployments in a workspace.
get_serving(serving_id)ServingA single serving deployment.
list_tasks(workspace, *, status=None, limit=50, offset=0)list[Task]Serverless tasks, newest first. status is a string or list of statuses.
get_task(task_id)TaskA single task.
list_assets(workspace, *, asset_type=None, status=None, page=1, page_size=20)AssetPageOne page of a workspace’s assets. Iterate it, or read .items, .total, .pages.
get_asset(asset_id)AssetA single asset with its version stack.
get_asset_storage(workspace)AssetStorageManaged asset storage usage, cost, and credit status.
list_machines()list[Machine]Machines you host.
get_machine(machine_id)MachineA single machine.
get_machine_metrics(machine_id)MachineMetricsLive metrics of a machine.
get_earnings(*, start_date=None, end_date=None)EarningsHost earnings summary and daily history.

Responses are parsed into lightweight dataclasses. Frequently used scalar fields are typed; deeply nested structures aren’t enumerated — the full original payload is preserved on .raw, so the SDK keeps working even when the backend adds fields.

FieldTypeNotes
emailstr
usernamestr | None
user_rolestr
rawdictFull payload.
FieldTypeNotes
namespace_namestrID — pass to list_pods / get_pod.
workspace_namestrDisplay label.
descriptionstr
member_countint
statusstr
price_per_hourstr
resourcesWorkspaceResources.pod, .storage, .serverless counts. Includes stopped pods and paused deployments.
created_at / updated_atdatetime | None
rawdictFull payload.

To count only what a workspace is actually running, read ws.raw["activeResources"] — same three keys, but pods you stopped and deployments you paused are left out. A typed field will follow in a later SDK release.

FieldTypeNotes
pod_namestrID — pass to get_pod.
namespace_namestrOwning workspace ID.
user_aliasstrDisplay label.
statusstr
rental_typestrspot / demand.
price_per_hourstr
is_maintenancebool
created_atdatetime | None
rawdictFull payload — machine, template, request, linked storages, …
FieldTypeNotes
machine_idstrID — pass to get_machine.
namestrDisplay label.
machine_typestrgpu / cpu / storage.
statusstr
gpu_modelstrEmpty for cpu/storage machines.
gpu_countint
earning_hourlyfloat
uptime_ratefloat0.01.0.
host_tierstr
rawdictFull payload — specs, full state, pod uses, …
FieldTypeNotes
namespace_name / workspace_namestrID / display label.
price_per_hourstrWhat the workspace is being billed right now.
weekly_avg_daily_coststrAverage daily cost over the last 7 days.
gpus / vcpusintTotals across the workspace’s pods.
ram / total_storageint / floatIn MiB (divide by 1024 for GB).
resourceslist[ResourceCondition]One per type (pod, storage, serverless) with .active, .paused, .disabled.
costslist[DailyCost]Recent daily costs (.date, .pod, .storage, .serverless, .task, .asset, .total).
rawdictFull payload — maintenance schedule, messages from hosts, …

user (email), role (admin / billing / viewer), joined_at, raw.

FieldTypeNotes
pv_namestrID — pass to get_storage.
namespace_name / user_aliasstrOwning workspace / display label.
storage_typestrnfs, hostPath, …
statusstr
total_size / available_sizefloatIn MiB.
usage_ratefloat0.01.0.
price_per_hourstr
linked_podslist[str]Names of the pods it is mounted in.
is_maintenance / encryptedbool
created_atdatetime | None
rawdictFull payload — host machine, warning thresholds, …

Both expose cpu_cores, cpu_usage_rate, ram_size (MiB), ram_usage_rate, and gpus — a list of GpuUsage with gpu_number, core_usage_rate, vram_usage_rate, vram_size (MiB) and temp. Rates are 0.01.0; a pod rate is None when the measurement is unavailable. PodMetrics adds ephemeral_storage_request / ephemeral_storage_usage (MiB); MachineMetrics adds cpu_allocated, ram_allocated, root_volume_size / root_volume_usage_rate, pv_volume_size / pv_volume_usage_rate, and network_receive / network_transmit (bytes per second).

FieldTypeNotes
gpu_modelstr
vramintGB. One entry per (model, VRAM) tier.
rental_typestrdemand / spot — the type the price is for.
price_per_hourstrPer GPU.
vcpu_recommended / ram_recommendedintSuggested pairing per GPU.
available_gpusintTotal across machines.
max_gpus_per_podintThe most one pod can get on a single machine.
machine_countint
rawdictFull payload — per-machine combinations, CPU/RAM prices, …
  • ApiKey: key_id, name, prefix (meshive_a1b2c3d4 — the secret is never returned), scopes, status, created_at, last_used_at, expires_at.
  • Credit: balance, paid_balance (GPU pods and workspaces), bonus_balance (serverless inference only), auto_recharge, auto_recharge_threshold, auto_recharge_amount, has_default_payment_method.
  • CreditHistoryEntry: entry_id, amount (negative for refunds), is_paid, payment_method, created_at. Stripe receipt and invoice links are not exposed to the SDK.

template_id (ID), name, description, is_official, deploy_type, app_type, app_sub_type, image, hardware_type, cuda_version, framework, framework_version, raw (environment variables, endpoints, volume mounts, semantic paths).

serving_id (ID), namespace_name, model_name, api_model_id, framework, status, paused, min_replicas / max_replicas / current_replicas / healthy_replicas, endpoint_url, price_per_hour, billing_active, raw (replicas, live metrics, scaling state).

task_id (ID, task_…), name, namespace_name, status, pod_name, image, gpu_model, gpu_count, cpu_cores, ram_gb, price_per_hour, cost_so_far, total_cost, created_at, container_running_at, finished_at, failure_reason, exit_code, raw. For get_task the payload also carries the script, requirements, environment (secret values masked) and the compute/disk cost breakdown.

Asset, AssetVersion, AssetPage, AssetStorage

Section titled “Asset, AssetVersion, AssetPage, AssetStorage”
FieldTypeNotes
Asset.asset_idstrID (asset_…) — pass to get_asset.
Asset.name / asset_type / status / status_reasonstrType is one of dataset, model, adapter, checkpoint, output, config, file.
Asset.storage_providerstrmeshive_r2 (managed), user_s3, or external.
Asset.version_count / size_bytes / file_countintReady versions; size and files of the latest ready version.
Asset.in_useboolWhether a pod or task currently uses it (raw["activeUsageContexts"] says which).
Asset.latest_version / versionsAssetVersion / list[AssetVersion]versions is filled by get_asset only (newest first).
AssetVersionversion_number, status (uploading / ready / failed), total_size_bytes, file_count, ingest_source, storage_provider, created_at, deleted, import_failure_reason; file entries in raw["files"].
AssetPageitems, total, page, page_size, pages; iterable.
AssetStoragemanaged_bytes, price_per_gb_month, estimated_monthly_cost, credit_state (normal / grace / blocked), credit_blocked, blocks_at, purge_deadline_at, paid_balance_available.

current_hourly, daily, accumulated_until_payout, and history — a list of DailyEarning (date, cpu, gpu, storage, total), newest first.

All SDK errors subclass MeshiveError:

ExceptionWhen
ConfigurationErrorNo API key could be resolved (raised before any request).
AuthenticationError401 — missing/invalid/expired key, or an inactive account.
PermissionDeniedError403 — the key lacks the required scope.
NotFoundError404 — the resource doesn’t exist.
RateLimitError429 — rate limit exceeded. Exposes .retry_after (seconds, may be None).
MeshiveAPIErrorAny other 4xx/5xx.

MeshiveAPIError (and its subclasses) carry .status_code, .title, .message, and .raw (the parsed response body).

from meshive import Meshive, MeshiveError, RateLimitError, NotFoundError
try:
with Meshive() as client:
pod = client.get_pod("does-not-exist", "my-workspace")
except NotFoundError as err:
print("no such pod:", err.message)
except RateLimitError as err:
print("slow down; retry after", err.retry_after, "s")
except MeshiveError as err:
print("request failed:", err)
from meshive import (
Meshive, AsyncMeshive, # clients
WhoAmI, ApiKey, Credit, CreditHistoryEntry, # account
Workspace, WorkspaceResources, WorkspaceDetail, # workspaces
ResourceCondition, DailyCost, Member,
Pod, PodMetrics, Storage, GpuUsage, # pods / storage
Asset, AssetVersion, AssetPage, AssetStorage, # assets
GpuAvailability, Template, # catalog
Serving, Task, # serverless
Machine, MachineMetrics, Earnings, DailyEarning, # host
MeshiveError, ConfigurationError, MeshiveAPIError, # errors
AuthenticationError, PermissionDeniedError,
NotFoundError, RateLimitError, WaitTimeoutError,
__version__,
)