# Install & Authentication

> Install the meshive Python package, understand API key permission scopes and expiry, log in with meshive login, or pass credentials via environment variables.

Source: https://docs.meshive.ai/sdk-cli/install-auth/

## Install

Requires **Python 3.10+**. The runtime dependencies are [`httpx`](https://www.python-httpx.org/) (0.27 or later, below 1.0), `certifi` and `truststore`.

For the **CLI**, install with [uv](https://docs.astral.sh/uv/getting-started/installation/) or [pipx](https://pipx.pypa.io/) so the `meshive` command stays in its own environment without hitting `externally-managed-environment` on Homebrew Python or modern Debian/Ubuntu. For the **Python SDK** inside a project or virtual environment, add `meshive>=1,<2` with `uv add` or `pip install`:

**uv (recommended)**

```bash
# Install the CLI globally
uv tool install meshive

# Or add the SDK to a Python project
uv add "meshive>=1,<2"
```

**pipx**

```bash
pipx install meshive
```

**pip (venv / project)**

```bash
pip install "meshive>=1,<2"
```

If `meshive` isn't found afterwards, run `uv tool update-shell` (or `pipx ensurepath`) and open a new terminal. Upgrade with `uv tool upgrade meshive` (or `pipx upgrade meshive`).

Verify the install:

```bash
meshive --version
```

These references describe **1.x**. In a requirements file, keep the same pin (`meshive>=1,<2`) so you get fixes without breaking changes. CPU lines, local storage created with a pod, template port changes, storage usage warnings, waiting starts, transaction lookup, editing pods and storage, connecting to storage over SSH and model sets arrived in **1.2** (1.1 was not released on its own); if you use them, pin `meshive>=1.2,<2`.

> **Caution — 1.10 locks new public ports:**
> From **1.10.0**, pods created by the SDK and CLI get [locked](/documentation/endpoint-access/) public ports, and an edit locks the ports it newly makes public. A script that creates a pod and then calls its public URL without an [access key](/documentation/endpoint-access-keys/) gets `401`. Create a key and send it, or pass `lock_public_ports=False` (`--no-lock`) to keep the behavior of 1.9 and earlier. Ports that are public already, and pods you already have, aren't changed.

### Upgrading from a pre-1.0 release

1.0.0 works with code written for the 0.1 releases; no changes are needed. Change your pin to `meshive>=1,<2`, reinstall, and regenerate your lock file if you use one. Most pre-1.0 releases are being removed from PyPI (0.1.4 stays; the [1.0.0 release notes](/release-notes/2026-10-13/) list the dates), so a pin to one of them stops installing after its removal date. Environments where one is already installed keep working.

## Authentication

The SDK and CLI authenticate with a **Meshive API Key**. Issue one in the [console](https://console.meshive.ai) under **Account → API keys** — keys belong to your account, not to a workspace, so you can create one before any workspace exists. Keys look like `meshive_` followed by a 64-character token and come in two permission levels:

| Permission | What it allows | Expiry |
| --- | --- | --- |
| **Read only** | Everything that lists or shows resources | **Required**: 365 days by default and at most |
| **Read & write** | The above, plus creating and renaming workspaces, deleting empty ones, creating, changing and deleting pods, storage, servings and tasks — including anything that spends credit — and hosting actions: removing or unlisting your machines, revealing machine logins and issuing install commands | **Required**: 30 days by default, 90 at most |

Every key expires. A write key that leaks can create pods on your account, delete pods, storage volumes and servings one at a time, and run your hosting actions: remove or unlist your machines, reveal their logins and issue install commands; it can't delete a workspace that still holds assets, finished tasks, saved credentials or the other things listed under [Deleting a workspace](/sdk-cli/sdk/workspaces/#deleting-a-workspace). A read key can fetch pod and task logs, which routinely contain tokens your container printed. Keys issued before this rule was introduced keep working until you revoke them. Revoke any key at any time from the same console page; the SDK reports a revoked or expired key as `AuthenticationError`, and a read-only key used for a write command as `PermissionDeniedError`.

The same page shows API key activity. **Actions** lists changes, checks and estimates with their results. **Reads** summarizes read requests by hour; see [Activity log](/sdk-cli/mcp/safety/#activity-log).

When a key stops or deletes a pod, or deletes a storage volume, a serving, a workspace or a machine, unlists a machine, reveals a machine login or issues an install command, the key's owner gets an email naming the key and where the request came from (SDK & CLI, or the MCP client). If you didn't expect it, revoke the key.

> **Note:**
> The `meshive_…` API key is a separate credential from the `mk-…` keys used by the serverless inference gateway — they are not interchangeable.

The recommended flow is `meshive login`, which verifies the key against the API and stores it locally so later commands need no flags:

1. ### Log in

   ```bash
   meshive login          # prompts for the key (hidden input)
   ```

   The key is verified before it is saved. On success it's written to `~/.meshive/credentials.json` with file mode `0600` (owner read/write only).

2. ### Use any command

   ```bash
   meshive me             # works with no --api-key
   ```

3. ### Log out when done

   ```bash
   meshive logout         # removes the saved credentials
   ```

### Providing the key without logging in

`meshive login` is optional. You can also pass the key per-command or via the environment. The resolution order is **`--api-key` flag › `MESHIVE_API_KEY` env › `meshive login` file**:

**Environment**

```bash
export MESHIVE_API_KEY=meshive_xxxxxxxx
meshive me
```

**Per-command flag**

```bash
meshive me --api-key meshive_xxxxxxxx
```

## Relocating the config directory

By default credentials live in `~/.meshive/` (directory mode `0700`). Set **`MESHIVE_CONFIG_DIR`** to relocate it — useful for test isolation or juggling multiple accounts:

```bash
export MESHIVE_CONFIG_DIR=/path/to/alt-config
```

## Next

- [CLI Reference](/sdk-cli/cli/) — every command, flag, and filter
- [Python SDK](/sdk-cli/sdk/) — sync and async clients, models, and error handling
- [AI Agents (MCP)](/sdk-cli/mcp/) — connect Claude Code, Codex, Cursor, and other agents
