> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/erste-schritte/python-quickstart.md).

# Schnellstart des Python-SDK

{% hint style="success" %}
**Was Sie bauen werden:** In 5 Minuten durchsuchen Sie den GPU-Marktplatz, mieten einen Server und verbinden sich per SSH — alles per Code oder CLI.
{% endhint %}

## Voraussetzungen

* **Python 3.9+** installiert
* **Clore.ai Konto** — [hier anmelden](https://clore.ai)
* **API-Schlüssel** — holen Sie ihn aus Ihrem [Clore.ai-Dashboard](https://clore.ai)
* **Guthaben** — mindestens \~5$ in BTC, CLORE, USDT oder USDC

***

## Schritt 1: Installieren Sie das SDK

```bash
pip install clore-ai
```

Installation überprüfen:

```bash
clore --version
```

***

## Schritt 2: Konfigurieren Sie Ihren API-Schlüssel

**Option A: Umgebungsvariable (empfohlen)**

```bash
export CLORE_API_KEY=your_api_key_here
```

**Option B: CLI-Konfiguration (gespeichert in `~/.clore/config.json`)**

```bash
clore config set api_key YOUR_API_KEY
```

***

## Schritt 3: Suche nach einer GPU

### CLI

```bash
clore search --gpu "RTX 4090" --max-price 5.0 --sort price --limit 10
```

Sie sehen eine Tabelle mit Server-IDs, GPU-Spezifikationen, RAM, Preis und Standort.

### Python

```python
from clore_ai import CloreAI

client = CloreAI()

servers = client.marketplace(gpu="RTX 4090", max_price_usd=5.0)
for s in servers[:5]:
    print(f"Server {s.id}: {s.gpu_count}x {s.gpu_model} — ${s.price_usd:.4f}/h — {s.location}")
```

**Ausgabe:**

```
Server 142: 1x NVIDIA GeForce RTX 4090 — $0.0800/h — EU
Server 305: 1x NVIDIA GeForce RTX 4090 — $0.0950/h — US
Server 891: 2x NVIDIA GeForce RTX 4090 — $0.1200/h — EU
```

{% hint style="info" %}
**Tipp:** Die `marketplace()` Methode filtert clientseitig. Sie können auch nach `min_gpu_count`, `min_ram_gb`, und `available_only` (Standard: `True`).
{% endhint %}

***

## Schritt 4: Bereitstellen (Server mieten)

### CLI

```bash
clore deploy 142 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password MySecurePass123 \
  --port 22:tcp \
  --port 8888:http
```

### Python

```python
order = client.create_order(
    server_id=142,
    image="cloreai/ubuntu22.04-cuda12",
    type="on-demand",
    currency="bitcoin",
    ssh_password="MySecurePass123",
    ports={"22": "tcp", "8888": "http"}
)

print(f"Bestellung erstellt! ID: {order.id}")
print(f"IP: {order.pub_cluster}")
print(f"Ports: {order.tcp_ports}")
```

{% hint style="warning" %}
**Der erste Start dauert 1–5 Minuten.** Der Server lädt das Docker-Image und startet Dienste. Wenn `pub_cluster` ist `None`, warten Sie und prüfen Sie erneut mit `my_orders()`.
{% endhint %}

***

## Schritt 5: Verbindung per SSH

### CLI (verbindet automatisch)

```bash
clore ssh 38
```

Die CLI sucht die Bestellung, findet die öffentliche IP und den SSH-Port und führt `ssh` für Sie aus.

### Manuelles SSH

```bash
ssh root@<pub_cluster> -p <ssh_port>
# Passwort: MySecurePass123
```

***

## Schritt 6: Aufräumen

Wenn Sie fertig sind, stornieren Sie die Bestellung, um die Abrechnung zu stoppen:

### CLI

```bash
clore cancel 38
```

### Python

```python
client.cancel_order(order_id=38, issue="Done with my work")
print("Bestellung storniert")
```

***

## Vollständiges Skript: Suche → Bereitstellen → Überwachen → Stornieren

```python
from clore_ai import CloreAI
import time

client = CloreAI()  # Verwendet die CLORE_API_KEY-Umgebungsvariable

# 1. Finde die günstigste RTX 4090
servers = client.marketplace(gpu="RTX 4090", max_price_usd=5.0)
servers.sort(key=lambda s: s.price_usd or float("inf"))

if not servers:
    print("Keine RTX 4090 verfügbar unter $5/h")
    exit(1)

best = servers[0]
print(f"Bestes Angebot: Server {best.id} — ${best.price_usd:.4f}/h — {best.location}")

# 2. Bereitstellen
order = client.create_order(
    server_id=best.id,
    image="cloreai/ubuntu22.04-cuda12",
    type="on-demand",
    currency="bitcoin",
    ssh_password="MySecurePass123",
    ports={"22": "tcp"}
)
print(f"Bestellung {order.id} erstellt!")

# 3. Warten auf IP-Zuweisung
for _ in range(12):
    orders = client.my_orders()
    current = next((o for o in orders if o.id == order.id), None)
    if current and current.pub_cluster:
        print(f"Bereit! SSH: ssh root@{current.pub_cluster} -p {current.tcp_ports.get('22', 22)}")
        break
    print("Warten auf Serverstart...")
    time.sleep(10)

# 4. ... erledigen Sie Ihre Arbeit ...

# 5. Stornieren, wenn fertig
client.cancel_order(order_id=order.id)
print("Bestellung storniert, Abrechnung gestoppt.")
```

***

## Was kommt als Nächstes

| Anleitung                                                               | Was Sie lernen werden                                                  |
| ----------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [Python SDK-Anleitung](/guides/guides_v2-de/erweitert/python-sdk.md)    | Asynchrone Operationen, Spot-Markt, Serververwaltung, Fehlerbehandlung |
| [CLI-Automatisierung](/guides/guides_v2-de/erweitert/cli-automation.md) | Bash-Skripte, CI/CD-Integration, Batch-Bereitstellung                  |
| [API-Integration](/guides/guides_v2-de/erweitert/api-integration.md)    | Verbinden Sie AI-Dienste, die auf Clore laufen, mit Ihren Anwendungen  |
| [GPU-Vergleich](/guides/guides_v2-de/erste-schritte/gpu-comparison.md)  | Wählen Sie die richtige GPU für Ihre Arbeitslast                       |

***

**Viel Spaß beim GPU-Mieten! 🚀**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/erste-schritte/python-quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
