Getting Started
This guide walks through installing the Targon CLI and SDK, configuring credentials, and launching your first rental workload.
Prerequisites
- Python 3.9 or later (for the Python SDK)
- Node.js 20 or later (for the TypeScript SDK)
- Go 1.21 or later (for the Go SDK)
- Rust toolchain (for the CLI)
- A Targon account and API key
Install the CLI
The CLI is a standalone Rust binary. Build it from the targon-sdk repo:
git clone https://github.com/manifold-inc/targon-sdk.git
cd targon-sdk/cli
cargo build --release
See the CLI installation guide for details.
Install the SDK
The SDK lives under libs/ in the targon-sdk repository. Language packages are published separately.
Python
pip install targon-sdk
For local development from the repo:
git clone https://github.com/manifold-inc/targon-sdk.git
cd targon-sdk/libs/python
pip install -e ".[dev]"
Import the top-level API:
from targon import Client, Resources
from targon.client import CreateWorkloadRequest, PortConfig
TypeScript
npm install @targon/sdk
Source: libs/typescript
Go
go get github.com/manifold-inc/targon-sdk/libs/go
Source: libs/go
Configure Credentials
Store your API key with the CLI:
targon auth login
Follow the prompt to paste your key. Credentials are stored under ~/.targon/.
The Python SDK also accepts credentials from:
- The
TARGON_API_KEYenvironment variable - The same
~/.targon/credential files written by the CLI
from targon import Client
client = Client.from_env() # reads TARGON_API_KEY or ~/.targon/
# or
client = Client(api_key="your-api-key")
Check Available Resources
List compute that is available right now:
targon inventory --gpu
Or query inventory from Python:
from targon import Client
client = Client.from_env()
for item in client.inventory.capacity(gpu=True):
print(f"{item.name}: {item.available} available @ ${item.cost_per_hour}/hr")
Use targon inventory to compare GPU tiers, hourly cost, and availability before creating a workload.
Create a Rental
The fastest way to get started is through the dashboard:
- Open the Targon dashboard.
- Go to Rentals and click Create Rental.
- Pick a GPU or CPU configuration, image, ports, and optional volumes.
- Add an SSH key and deploy.
See the Rentals guide for the full walkthrough.
Create a Workload with the SDK
For programmatic control, create and deploy a rental workload with the Python SDK:
from targon import Client, Resources
from targon.client import CreateWorkloadRequest, PortConfig
client = Client.from_env()
workload = client.workload.create(
CreateWorkloadRequest(
name="my-training-job",
image="pytorch/pytorch:latest",
resource_name=Resources.H200_SMALL,
type="RENTAL",
ports=[
PortConfig(port=8080, routing="PROXIED"),
PortConfig(port=2222, routing="DIRECT"),
],
)
)
client.workload.deploy(workload.uid)
client.workload.wait_until_ready(workload.uid)
The SDK exposes service clients on Client for workloads, volumes, SSH keys, inventory, projects, and user account data. See the Workloads API reference for all workload types and fields.
You can also call the REST API directly:
curl -X POST https://api.targon.com/tha/v2/workloads \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-training-job",
"image": "pytorch/pytorch:latest",
"resource_name": "h200-small",
"type": "RENTAL",
"ports": [
{"port": 8080, "protocol": "TCP", "routing": "PROXIED"},
{"port": 2222, "protocol": "TCP", "routing": "DIRECT"}
]
}'
Then deploy it:
curl -X POST https://api.targon.com/tha/v2/workloads/wrk-<UID>/deploy \
-H "Authorization: Bearer <YOUR_API_KEY>"
Use targon workload get with the workload UID to confirm it is running.
Next Steps
- Pick a resource tier with
Resources. - Save configs with Templates.
- Attach persistent storage with Volumes.
- Choose hardware with the Compute resources guide.
- Deploy LLM inference on Rentals.
- Run confidential GPU VMs with the Virtual Machines guide.