# Vast.ai Integration via LowCodeAPI

**Last Updated**: January 27, 2025

## Overview
Decentralized GPU marketplace for AI model training and inference, offering cost-effective GPU rental solutions.

**Categories:**
- {'id': 'ai-cloud', 'name': 'AI Cloud'}

## Base Endpoint
https://api.lowcodeapi.com/vastai

**Important**: Always include the provider name in the URL path after `api.lowcodeapi.com/`

## Authentication
**Type:** TOKEN

**Official Documentation:** https://vast.ai/docs

## URL Format (Important)

LowCodeAPI supports two URL formats. **Always try the New Format first**, then fall back to Old Format if needed.

### New Format (Priority)
- Path parameters stay in the URL path
- Do NOT include path parameters as query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/{id}?api_token=XXX`

### Old Format (Fallback)
- Path parameters become query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/id?id={id}&api_token=XXX`

### Decision Flow for AI Agents
1. Always use **New Format** first - keep path parameters in the URL path
2. If you get a 404 or error, try **Old Format** with sanitized path
3. Log which format worked for future requests to this provider

## API Categories

## Common Endpoints

### List available GPU offers

**Method:** GET
**LowCodeAPI Path:** /offers

**New Format URL:**
https://api.lowcodeapi.com/vastai/offers?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/offers?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| type | string |  |
| limit | number |  |
| offset | number |  |
| order | string |  |
| q | string |  |
| sort_option | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/offers?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/offers

### Get specific offer details

**Method:** GET
**LowCodeAPI Path:** /offers/{offer_id}

**New Format URL:**
https://api.lowcodeapi.com/vastai/offers/{offer_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/offers/offer_id?offer_id={offer_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| offer_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/offers/{offer_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/offers

### List your machines

**Method:** GET
**LowCodeAPI Path:** /machines

**New Format URL:**
https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| limit | number |  |
| offset | number |  |
| owner_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/machines

### Get machine details

**Method:** GET
**LowCodeAPI Path:** /machines/{machine_id}

**New Format URL:**
https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/machines/machine_id?machine_id={machine_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| machine_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/machines

### Create a new machine offer

**Method:** POST
**LowCodeAPI Path:** /machines

**New Format URL:**
https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| discount | number |  |
| machine_id | string |  |
| min_bid | number |  |
| price | number |  |
| verified | boolean |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/vastai/machines?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/machines

### Update machine offer

**Method:** PUT
**LowCodeAPI Path:** /machines/{machine_id}

**New Format URL:**
https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/machines/machine_id?machine_id={machine_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| machine_id | string |  |

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| discount | number |  |
| min_bid | number |  |
| price | number |  |
| verified | boolean |  |

**Example Request (New Format):**

```bash
curl -X PUT 'https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/machines

### Delete machine offer

**Method:** DELETE
**LowCodeAPI Path:** /machines/{machine_id}

**New Format URL:**
https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/machines/machine_id?machine_id={machine_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| machine_id | string |  |

**Example Request (New Format):**

```bash
curl -X DELETE 'https://api.lowcodeapi.com/vastai/machines/{machine_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/machines

### List instances

**Method:** GET
**LowCodeAPI Path:** /instances

**New Format URL:**
https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| limit | number |  |
| offset | number |  |
| owner_id | string |  |
| state | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/instances

### Get instance details

**Method:** GET
**LowCodeAPI Path:** /instances/{instance_id}

**New Format URL:**
https://api.lowcodeapi.com/vastai/instances/{instance_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/instances/instance_id?instance_id={instance_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| instance_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/vastai/instances/{instance_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/instances

### Create new instance

**Method:** POST
**LowCodeAPI Path:** /instances

**New Format URL:**
https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| args | array |  |
| disk | number |  |
| env | object |  |
| image | string |  |
| label | string |  |
| offer_id | string |  |
| onstart | string |  |

**Example Request (New Format):**

```bash
curl -X POST 'https://api.lowcodeapi.com/vastai/instances?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://vast.ai/docs/api-reference/instances


## Usage Examples

### Example 1: Basic API Request (New Format)

Making a simple GET request to retrieve resources:

```bash
# Get a list of resources - no path parameters needed
curl -X GET "https://api.lowcodeapi.com/vastai/endpoint?api_token=YOUR_API_TOKEN"
```

### Example 2: Request with Path Parameters (New Format)

Retrieving a specific resource using its ID:

```bash
# Get specific resource by ID - replace RESOURCE_ID with actual ID from previous response
curl -X GET "https://api.lowcodeapi.com/vastai/endpoint/{RESOURCE_ID}?api_token=YOUR_API_TOKEN"
# Note: RESOURCE_ID typically comes from a previous list request or from the provider dashboard
```

### Example 3: POST Request with Body (New Format)

Creating a new resource:

```bash
# Create a new resource
curl -X POST "https://api.lowcodeapi.com/vastai/endpoint?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"field": "value", "another_field": "another_value"}'
```

## Error Handling

LowCodeAPI returns standard HTTP status codes. Common errors:

| Status Code | Description |
|-------------|-------------|
| 200 | Success - Request completed successfully |
| 400 | Bad Request - Invalid parameters or request body |
| 401 | Unauthorized - Invalid or missing API token |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Endpoint or resource doesn't exist |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Provider API error |

All error responses include error details:

```json
{
  "data": {
    "error": {
      "message": "Error description",
      "code": "ERROR_CODE"
    }
  }
}
```

## Complete Endpoint Reference

| Endpoint | Method | Category |
|----------|--------|----------|
| List available GPU offers | GET | Offers |
| Get specific offer details | GET | Offers |
| List your machines | GET | Machines |
| Get machine details | GET | Machines |
| Create a new machine offer | POST | Machines |
| Update machine offer | PUT | Machines |
| Delete machine offer | DELETE | Machines |
| List instances | GET | Instances |
| Get instance details | GET | Instances |
| Create new instance | POST | Instances |
| Update instance | PUT | Instances |
| Stop instance | POST | Instances |
| Start instance | POST | Instances |
| Delete instance | DELETE | Instances |
| List bids | GET | Bids |
| Get bid details | GET | Bids |
| Create new bid | POST | Bids |
| Update bid | PUT | Bids |
| Delete bid | DELETE | Bids |
| Get current user information | GET | Users |
| Get user information | GET | Users |
| Update current user | PUT | Users |
| List templates | GET | Templates |
| Get template details | GET | Templates |
| Create template | POST | Templates |
| Update template | PUT | Templates |
| Delete template | DELETE | Templates |
| List SSH keys | GET | SSH Keys |
| Add SSH key | POST | SSH Keys |
| Delete SSH key | DELETE | SSH Keys |
| List invoices | GET | Invoices |
| Get invoice details | GET | Invoices |
| Get account balance | GET | Account |

## API Definition Endpoints

You can fetch the complete API specification for this provider:

**New Format (OpenAPI spec):**
```bash
curl 'https://backend.lowcodeapi.com/vastai/openapi'
```

**Old Format (API definition):**
```bash
curl 'https://backend.lowcodeapi.com/vastai/definition'
```

## Response Format

All responses are wrapped in a `data` key:

```json
{
  "data": {
    // Actual response from provider (object or array)
  }
}
```