Metadata-Version: 2.4
Name: leptonai
Version: 0.47.0
Summary: NVIDIA DGX Cloud Lepton AI Platform, SDK and CLI
Author: Lepton Contributors
Project-URL: Homepage, https://docs.nvidia.com/dgx-cloud/lepton
Requires-Python: <3.15,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: anyio<=4.9.0,>=3.7.0
Requires-Dist: click
Requires-Dist: contextlib2
Requires-Dist: exceptiongroup
Requires-Dist: fastapi
Requires-Dist: httpx[http2]==0.27.2
Requires-Dist: rich
Requires-Dist: typing-extensions
Requires-Dist: loguru
Requires-Dist: requests
Requires-Dist: pydantic!=2.1.0
Requires-Dist: pyyaml
Requires-Dist: ledoc-ui
Requires-Dist: ray[default]
Provides-Extra: lint
Requires-Dist: black==23.12.0; extra == "lint"
Requires-Dist: ruff==0.5.7; extra == "lint"
Requires-Dist: pre-commit==4.6.0; python_version >= "3.10" and extra == "lint"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: responses; extra == "test"
Requires-Dist: respx; extra == "test"
Dynamic: license-file

<img src="https://raw.githubusercontent.com/leptonai/leptonai/main/assets/logo.svg" height=100>

# Lepton AI

**The Python library and `lep` CLI for NVIDIA DGX Cloud Lepton**

<a href="https://docs.nvidia.com/dgx-cloud/lepton">Homepage</a> •
<a href="https://github.com/leptonai/examples">Examples</a> •
<a href="https://docs.nvidia.com/dgx-cloud/lepton">Documentation</a> •
<a href="https://docs.nvidia.com/dgx-cloud/lepton/reference/cli/get-started/">CLI References</a>

The LeptonAI Python library lets you operate the [NVIDIA DGX Cloud Lepton](https://docs.nvidia.com/dgx-cloud/lepton) platform from Python and the command line. Key features include:

- A `lep` command-line tool to create and manage endpoints, batch jobs, dev pods, Ray and Slurm clusters, fine-tuning jobs, storage, secrets, and more.
- A `Client` to call your deployed endpoints like native Python functions.
- Pythonic configuration specs that are readily shipped to the cloud.
- Skills that let agents operate the Lepton platform for you.

## Getting started

Install the library, which also installs the `lep` command-line tool:

```shell
pip install -U leptonai
```

Log in to your workspace (this opens a browser to fetch credentials if you don't pass them in):

```shell
lep login
```

Deploy a container image as an endpoint, then inspect it:

```shell
lep endpoint create -n my-endpoint --container-image my-registry/my-app:latest
lep endpoint list
lep endpoint status -n my-endpoint
```

In workspaces with secure endpoint defaults enabled, an endpoint created without
`--tokens` is protected automatically. The create command prints the generated API
token; save that value so clients can authenticate. You can instead provide one or
more repeatable `--tokens` values, or explicitly opt out with
`--allow-unauthenticated-access` (the CLI displays a warning). The `--public` option
only controls IP reachability and does not disable API-token authentication.
`lep endpoint status` reports these dimensions separately as `IP Access` and
`API Token Authentication`.

SDK callers that leave endpoint authentication unspecified should use
`client.deployment.create_with_response(...)` and save the token from the returned
resource. The older `create(...)` method keeps its boolean return contract and cannot
return a server-generated credential, so it emits a `RuntimeWarning` for requests that
may ask the server to generate one. SDK updates may not clear `api_tokens` by sending
an empty list alone: set `allow_unauthenticated_access=true` in the same update, or
replace the list with at least one token.

`lep endpoint get` redacts literal tokens by default. Use `--show-tokens` only when you
need a credential-bearing response or reusable spec export, and handle that output as
a secret. The former hidden `update --remove-tokens` option is rejected; use
`--allow-unauthenticated-access` for an explicit opt-out.

Authentication-mode updates are explicit:

```shell
# Replace tokens and enable token authentication
lep endpoint update -n my-endpoint --tokens MY_TOKEN

# Clear tokens and explicitly allow requests without API-token authentication
lep endpoint update -n my-endpoint --allow-unauthenticated-access
```

You can also launch batch jobs and dev pods:

```shell
# Run a batch job
lep job create -n my-job --container-image my-registry/my-trainer:latest --command "python train.py"

# Launch an interactive dev pod
lep pod create -n my-pod --resource-shape gpu.a10
```

Run `lep --help`, or `lep <command> --help` for any subcommand, to explore everything. See the [CLI references](https://docs.nvidia.com/dgx-cloud/lepton/reference/cli/get-started/) for the full guide.

## Calling an endpoint from Python

Once an endpoint is running, call it from Python with the `Client`. It reads the endpoint's OpenAPI schema and exposes each path as a method:

```python
from leptonai.client import Client, local

# Connect to a workspace endpoint...
c = Client("my-workspace", "my-endpoint", token="MY_TOKEN")
# ...or to something running locally:
c = Client(local(port=8080))

# Discover the available paths and their docs
print(c.paths())
print(c.run.__doc__)

# Call the endpoint as if it were a local function
print(c.run(inputs="hello world"))
```

## Checking out more examples

You can find more examples in the [examples repository](https://github.com/leptonai/examples), and full guides in the [documentation](https://docs.nvidia.com/dgx-cloud/lepton).

## Skills: Operating Lepton from Claude Code or Codex

This repo ships an [agent skill](plugins/lepton-cli/skills/lepton-cli/SKILL.md) that lets [Claude Code](https://claude.com/claude-code) (or Codex) drive the `lep` CLI for you — listing endpoints, inspecting jobs and dev pods, checking workspace status, and managing workloads, all from natural language. It uses the same `lep` CLI installed above, so make sure it is authenticated to your workspace.

The plugin lives under [plugins/lepton-cli](plugins/lepton-cli) with per-agent manifests for Claude Code, Codex, and Cursor (`.claude-plugin/`, `.codex-plugin/`, `.cursor-plugin/`), all sharing the one skill at [skills/lepton-cli](plugins/lepton-cli/skills/lepton-cli). It is listed in two marketplaces in this repo: [.claude-plugin/marketplace.json](.claude-plugin/marketplace.json) for Claude Code and [.agents/plugins/marketplace.json](.agents/plugins/marketplace.json) for Codex.

**Codex** — add this repo as a marketplace, then install the plugin:

```text
codex plugin marketplace add leptonai/leptonai
codex plugin add lepton-cli@lepton-skills
```

Or browse interactively: run `/plugins` in the Codex CLI (or open **Plugins** in the Codex app), find **Lepton CLI**, and install.

**Claude Code** — install from the Lepton marketplace in one line, nothing to clone:

```text
/plugin marketplace add leptonai/leptonai
/plugin install lepton-cli@lepton-skills
```

Start a new session, then ask something like *"List the endpoints in my Lepton workspace."* The skill asks for explicit confirmation before any command that modifies or deletes a workload.

<details>
<summary><b>Codex, or Claude Code without plugins</b></summary>

Clone this repo, then copy the skill into your agent's skills directory:

```bash
# Codex
cp -R plugins/lepton-cli/skills/lepton-cli "${CODEX_HOME:-$HOME/.codex}/skills/lepton-cli"
# Claude Code (personal skill)
cp -R plugins/lepton-cli/skills/lepton-cli "$HOME/.claude/skills/lepton-cli"
```

Restart the agent afterward.
</details>

## Contributing

This repository uses [uv](https://docs.astral.sh/uv/) to manage its Python environment and dependencies. After installing uv, run these commands from the repository root:

```shell
uv sync --locked
uv run lep --help
```

This installs the local source and development tools into `.venv`, using the Python version in `.python-version` and the dependencies in `uv.lock`. Use `uv run lep` to run the CLI without activating the environment.

Contributions and collaborations are welcome and highly appreciated. Please check out the [contributor guide](https://github.com/leptonai/leptonai/blob/main/CONTRIBUTING.md) for how to get involved.

## License

The Lepton AI Python library is released under the Apache 2.0 license.

Developer Note: early development of LeptonAI was in a separate mono-repo, which is why you may see commits from the `leptonai/lepton` repo. We intend to use this open source repo as the source of truth going forward.
