L'API di Trooper.AI offre un accesso completo alla gestione dei GPU Server, inclusi la configurazione, il monitoraggio, la migrazione e le funzioni amministrative. Questa API RESTful Le consente di gestire in modo programmatico la Sua infrastruttura GPU, creare e monitorare ordini per server, gestire modelli e svolgere compiti amministrativi.
Gli endpoint API e la documentazione dell'API sono attualmente in fase Beta. Contattaci per qualsiasi problema: Contatti di Assistenza.
Trova la Sua chiave API nella Console API.
Consiglio pratico: Basta fornire questa documentazione al Suo agente LLM di Sviluppo e lo integrerà automaticamente nel codice.
Ottenga una panoramica rapida sui concetti base dell'API come URL, autenticazione e altro:
https://james.trooper.ai
La maggior parte degli endpoint richiede autenticazione con Bearer token utilizzando la Sua chiave Trooper API:
Authorization: Bearer YOUR_API_KEY
Ottenga la Sua chiave API dalla API Console.
Tutte le risposte dell'API sono in formato JSON. Le risposte di successo includono tipicamente:
success: Boolean indicating operation successError responses include:
error: String describing the errornext: Optional field suggesting next action (e.g., “login”)GET /api/test
Simple test endpoint to verify API connectivity.
GET /api/test
{
"test": "meinstring5"
}
GET /api/blibs
Retrieve all publicly available GPU server configurations.
GET /api/blibs
Authorization: Bearer YOUR_API_KEY # Optional - includes your private networks if provided
[
{
"id": 1,
"name": "powerai.example",
"gpu_type": "RTX 4090",
"gpu_num": 1,
"gpu_ram": 24,
"cpu_cores": 8,
"cpu_ram": 32,
"hdd": 500,
"price_h": 0.85,
"is_public": 1,
"country_code": "DE",
"is_available": true,
"available_hosts": ["ai18", "ai89"],
"fitCount": 2,
"maxPossibleInstances": 5
}
]
{
"error": "Error fetching Blibs"
}
GET /api/blibs-private
Retrieve GPU servers accessible to your account, including private configurations.
GET /api/blibs-private
Authorization: Bearer YOUR_API_KEY
[
{
"id": 2,
"name": "RTX 4090 Dual Private",
"gpu_type": "RTX 4090",
"gpu_num": 2,
"gpu_ram": 24,
"cpu_cores": 16,
"cpu_ram": 64,
"hdd": 1000,
"price_h": 1.65,
"is_public": 1,
"country_code": "DE"
}
]
{
"error": "Missing or invalid Authorization header"
}
POST /api/order
Create a new GPU server order. You must submit the price provided, otherwise the order will not be accepted. This makes sure the current price matches your expectations!
POST /api/order
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"blib_id": 1,
"price_h": 0.85,
"total_price": 0.85,
"terms_accepted": true,
"contract_interval": "HOUR",
"second_partition_percentage": 20,
"templates": [
{
"id": 1,
"name": "PyTorch Environment"
}
]
}
{
"success": true,
"orderId": 123
}
{
"error": "You must accept the terms and conditions."
}
{
"error": "Invalid or missing contract interval."
}
OTTENI /api/ordini
Retrieve all your server orders with detailed information.
When handling server statuses, consider the interplay between desired_status and current_status. For example, a server might have a desired_status of “stopped”, but its current_status could still be “running” if the stop process is in progress. Your application should account for these transitions and handle them accordingly.
GET /api/orders
Authorization: Bearer YOUR_API_KEY
machine_name (optional): Filter by specific machine name[
{
"order_id": 123,
"serverId": 123,
"title": "My PyTorch Server",
"status": "running",
"status_user": "running",
"server_name": "gpu-server-01",
"machine_name": "ai99_trooperai_000123",
"ip": "192.168.1.100",
"ssh_port": 22001,
"price_h": 0.85,
"paid_until": "2025-09-26T14:30:00.000Z",
"contract_interval": "HOUR",
"is_locked": false,
"is_low_priority": false,
"blib_name": "RTX 4090 Single",
"blib_gpu_type": "RTX 4090",
"blib_gpu_num": 1,
"country_code": "DE",
"template_installs": [
{
"id": 1,
"template_name": "PyTorch Environment",
"status": 1,
"status_readable": "Completed"
}
]
}
]
{
"error": "Missing or invalid Authorization header",
"next": "login"
}
POST /api/order-status
Update your server order status (running, stopped, restarted, frozen, terminated).
Set "migration_allowed": true if you approve host migration when transitioning from a frozen to running state. This process may take 10–90 minutes and will change the Ports Range and potentially the CPU model/speed.
POST /api/order-status
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"serverId": 123,
"desired_status": "running",
"migration_allowed": false
}
{
"success": true,
"updated": 1
}
{
"success": false,
"error": "Server is locked and cannot be modified"
}
POST /api/order-title
Update the display title of your server.
POST /api/order-title
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"serverId": 123,
"title": "My New Server Title"
}
{
"success": true,
"message": "Title updated successfully"
}
POST /api/order-lock
Lock or unlock a server to prevent/allow status changes.
POST /api/order-lock
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"serverId": 123,
"is_locked": true
}
{
"success": true,
"updated": 1
}
POST /api/credentials
Retrieve SSH credentials and connection details for your server.
POST /api/credentials
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"serverId": 123
}
{
"success": true,
"ssh_password": "generated-password"
}
{
"error": "Access denied or server not found"
}
GET /api/storia-stato-ordine
Get the last 5 status changes for a server order.
GET /api/order-status-history?order_id=123
Authorization: Bearer YOUR_API_KEY
{
"success": true,
"history": [
{
"id": 1,
"status_user": "running",
"status_txt": "Server started successfully",
"status_since": "2025-09-25T10:30:00.000Z"
},
{
"id": 2,
"status_user": "stopped",
"status_txt": "Server stopped by user",
"status_since": "2025-09-25T08:15:00.000Z"
}
]
}
Migration is used to bring your GPU server to a different configuration. We don’t recommend to use this for production. But you can try if you like!
GET /api/migration-options
Get available server configurations for migration.
GET /api/migration-options?order_id=123
Authorization: Bearer YOUR_API_KEY
{
"success": true,
"currentOrder": {
"id": 123,
"title": "My Server",
"status": "running",
"contract_interval": "HOUR",
"paid_until": "2025-09-26T14:30:00.000Z"
},
"currentBlib": {
"id": 1,
"name": "RTX 4090 Single",
"gpu_type": "RTX 4090",
"gpu_num": 1,
"price_h": 0.85
},
"availableBlibs": [
{
"id": 2,
"name": "RTX 4090 Dual",
"gpu_type": "RTX 4090",
"gpu_num": 2,
"price_h": 1.65,
"is_available": true,
"additionalCostPerCycle": 0.80
}
]
}
POST /api/migration-cost
Calculate the cost for migrating to a different server configuration.
POST /api/migration-cost
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"order_id": 123,
"target_blib_id": 2
}
{
"success": true,
"upgradeCost": 15.50,
"remainingValue": 12.30,
"totalDue": 3.20,
"additionalCostPerCycle": 0.80,
"nextBillingDate": "2025-09-26T14:30:00.000Z",
"currentRate": {
"amount": 0.85,
"display": "€0.85/hour"
},
"newRate": {
"amount": 1.65,
"display": "€1.65/hour"
}
}
POST /api/buy-migration
Execute the migration to a new server configuration.
IMPORTANTE Se invia dati non validi qui, nulla è garantito. Il team di supporto non può ripristinare il Suo ordine se Lei utilizza impropriamente questa endpoint per l'acquisto di migrazioni. Le raccomandiamo di utilizzare l’UI Dashboard.
POST /api/buy-migration
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"order_id": 123,
"target_blib_id": 2,
"keep_data": true
}
{
"success": true,
"message": "Migration initiated successfully",
"new_order_id": 124
}
{
"error": "Insufficient budget for migration"
}
GET /api/templates
Get all available software templates.
GET /api/templates
Authorization: Bearer YOUR_API_KEY # Optional
[
{
"id": 1,
"name": "PyTorch Environment",
"description": "Pre-configured PyTorch environment with CUDA support",
"category": "Machine Learning",
"is_public": true,
"options": [
{
"id": 1,
"name": "Python Version",
"type": "select",
"default_value": "3.9",
"possible_values": "3.8,3.9,3.10"
}
]
}
]
GET /api/configurazione-template
Get template installation configuration for a specific order.
GET /api/template-config?order_id=123
Authorization: Bearer YOUR_API_KEY
{
"success": true,
"templates": [
{
"install_id": 1,
"template_id": 1,
"template_name": "PyTorch Environment",
"status": 1,
"status_readable": "Completed",
"config": {
"python_version": "3.9"
}
}
]
}
POST /api/installazione-template-add
Install a new template on your server.
POST /api/template-install-add
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"order_id": 123,
"template_id": 1,
"config": {
"python_version": "3.9"
}
}
{
"success": true,
"install_id": 5,
"message": "Template installation queued"
}
POST /api/template-install-elimina
Remove a template installation from your server.
POST /api/template-install-delete
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"install_id": 5
}
{
"success": true,
"message": "Template removal initiated"
}
POST /api/template-install-retry
Retry a failed template installation.
POST /api/template-install-retry
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"install_id": 5
}
{
"success": true,
"message": "Template installation retry initiated"
}
"Missing or invalid Authorization header": Authentication required"Invalid Trooper key": API key is invalid"Unauthorized access": Insufficient permissions"You must accept the terms and conditions": Terms not accepted in order creation"Invalid or missing contract interval": Contract interval must be HOUR, WEEK, or MONTH"Insufficient budget": Not enough budget for the operation"Server is locked and cannot be modified": Server is locked for modificationsAPI endpoints may be rate-limited to prevent abuse. If you exceed the rate limit, you’ll receive a 429 status code. Implement appropriate retry logic with exponential backoff.
Per il supporto dell'API e domande, contatti: [email protected]
Per qualsiasi domanda relativa all'API, contatti pure Support Contacts