# Fal.ai Integration via LowCodeAPI

**Last Updated**: January 27, 2025

## Overview
Platform APIs provide programmatic access to platform resources including model metadata, pricing information, usage tracking, and analytics.

**Categories:**
- {'id': 'inference-cloud', 'name': 'Inference Cloud'}

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

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

## Authentication
**Type:** TOKEN

**Official Documentation:** https://docs.fal.ai/platform-apis

## 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 Models

**Method:** GET
**LowCodeAPI Path:** /v1/models

**New Format URL:**
https://api.lowcodeapi.com/falai/v1/models?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/models?api_token=YOUR_API_TOKEN

**Query Parameters:**

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

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/falai/v1/models?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-models

### Get Model Details

**Method:** GET
**LowCodeAPI Path:** /v1/models/{model_id}

**New Format URL:**
https://api.lowcodeapi.com/falai/v1/models/{model_id}?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/models/model_id?model_id={model_id}&api_token=YOUR_API_TOKEN

**Path Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| model_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/falai/v1/models/{model_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-models

### Get Pricing Information

**Method:** GET
**LowCodeAPI Path:** /v1/pricing

**New Format URL:**
https://api.lowcodeapi.com/falai/v1/pricing?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/pricing?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| model_id | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/falai/v1/pricing?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-models

### Get Usage Statistics

**Method:** GET
**LowCodeAPI Path:** /v1/usage

**New Format URL:**
https://api.lowcodeapi.com/falai/v1/usage?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/usage?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| end_date | string |  |
| model_id | string |  |
| start_date | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/falai/v1/usage?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-models

### Get Analytics Data

**Method:** GET
**LowCodeAPI Path:** /v1/analytics

**New Format URL:**
https://api.lowcodeapi.com/falai/v1/analytics?api_token=YOUR_API_TOKEN

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/analytics?api_token=YOUR_API_TOKEN

**Query Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| end_date | string |  |
| metric | string |  |
| model_id | string |  |
| start_date | string |  |

**Example Request (New Format):**

```bash
curl -X GET 'https://api.lowcodeapi.com/falai/v1/analytics?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-models

### List Compute Instances

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

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

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

**Query Parameters:**

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

**Example Request (New Format):**

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

**Official Documentation:** https://docs.fal.ai/platform-apis/for-compute

### Create Compute Instance

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

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

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

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| config | object |  |
| instance_type | string |  |
| name | string |  |

**Example Request (New Format):**

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

**Official Documentation:** https://docs.fal.ai/platform-apis/for-compute

### Get Compute Instance Details

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

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

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/compute/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/falai/v1/compute/instances/{instance_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-compute

### Update Compute Instance

**Method:** PATCH
**LowCodeAPI Path:** /v1/compute/instances/{instance_id}

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

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

**Path Parameters:**

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

**Request Body:**

| Field | Type | Description |
|-------|------|-------------|
| config | object |  |
| name | string |  |

**Example Request (New Format):**

```bash
curl -X PATCH 'https://api.lowcodeapi.com/falai/v1/compute/instances/{instance_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-compute

### Delete Compute Instance

**Method:** DELETE
**LowCodeAPI Path:** /v1/compute/instances/{instance_id}

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

**Old Format URL:**
https://api.lowcodeapi.com/falai/v1/compute/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 DELETE 'https://api.lowcodeapi.com/falai/v1/compute/instances/{instance_id}?api_token=YOUR_API_TOKEN'
```

**Official Documentation:** https://docs.fal.ai/platform-apis/for-compute


## Usage Examples

### Example 1: Basic Chat Completion

Creating a simple text completion or chat message:

```bash
# Create a chat completion - no path parameters needed
curl -X POST "https://api.lowcodeapi.com/falai/v1/chat/completions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-name",
    "messages": [
      {"role": "user", "content": "Hello, how can you help me?"}
    ]
  }'

# Response includes generated content
```

### Example 2: Text Generation with Path Parameters

Generating text with specific model settings:

```bash
# Generate content using a specific model
curl -X POST "https://api.lowcodeapi.com/falai/v1/models/generate?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Write a short poem about technology",
    "max_tokens": 100
  }'

# Or if the provider uses model in the path:
curl -X POST "https://api.lowcodeapi.com/falai/v1/models/{MODEL_ID}:generateContent?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Write a short story"}]}]
  }'
```

### Example 3: List Available Models

```bash
# Get list of available models
curl -X GET "https://api.lowcodeapi.com/falai/v1/models?api_token=YOUR_API_TOKEN"
```

## 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 Models | GET | Models |
| Get Model Details | GET | Models |
| Get Pricing Information | GET | Pricing |
| Get Usage Statistics | GET | Usage |
| Get Analytics Data | GET | Analytics |
| List Compute Instances | GET | Compute |
| Create Compute Instance | POST | Compute |
| Get Compute Instance Details | GET | Compute |
| Update Compute Instance | PATCH | Compute |
| Delete Compute Instance | DELETE | Compute |
| Start Compute Instance | POST | Compute |
| Stop Compute Instance | POST | Compute |
| Monitor Compute Instance | GET | Compute |
| Batch Requests | POST | Batch |

## API Definition Endpoints

You can fetch the complete API specification for this provider:

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

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

## Response Format

All responses are wrapped in a `data` key:

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