> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/cheahjs/free-llm-api-resources/llms.txt
> Use this file to discover all available pages before exploring further.

# Modal

> Get $5/month free credits on sign up, or $30/month with payment method added

## Overview

Modal provides flexible trial credits: $5 per month upon sign up, which increases to $30 per month when you add a payment method. Modal is a serverless platform where you pay by compute time for any supported model.

<CardGroup cols={2}>
  <Card title="Free Tier" icon="dollar-sign">
    \$5/month (no payment method)
  </Card>

  <Card title="Enhanced Free Tier" icon="credit-card">
    \$30/month (with payment method)
  </Card>
</CardGroup>

## Pricing Model

<Note>
  Modal charges by **compute time** rather than tokens. You pay for the actual CPU/GPU time your code uses, making it cost-effective for batch processing and custom workloads.
</Note>

### Credits Structure

| Tier         | Monthly Credits | Requirements       |
| ------------ | --------------- | ------------------ |
| **Basic**    | \$5/month       | Just sign up       |
| **Enhanced** | \$30/month      | Add payment method |

## Available Models

Modal supports any model you can deploy. Unlike traditional API providers, Modal lets you:

* **Deploy any open-source model** from Hugging Face
* **Run custom inference code** with your own optimizations
* **Use any framework**: PyTorch, JAX, TensorFlow, etc.
* **Scale automatically** based on demand

<Info>
  Modal is ideal for developers who want **full control** over their model deployment and inference pipeline.
</Info>

## Getting Started

### 1. Sign Up

Visit [modal.com](https://modal.com) and create a free account to receive \$5/month in credits.

### 2. Add Payment Method (Optional)

Add a payment method to increase your free monthly credits to \$30.

### 3. Install Modal CLI

```bash theme={null}
pip install modal
```

### 4. Authenticate

```bash theme={null}
modal token new
```

### 5. Deploy Your First Function

```python theme={null}
import modal

stub = modal.Stub("example-app")

@stub.function(
    gpu="A10G",
    image=modal.Image.debian_slim().pip_install(
        "transformers",
        "torch",
        "accelerate"
    )
)
def generate_text(prompt: str):
    from transformers import pipeline
    
    generator = pipeline(
        "text-generation",
        model="meta-llama/Llama-3.1-8B-Instruct",
        device="cuda"
    )
    
    return generator(prompt, max_length=100)[0]["generated_text"]

@stub.local_entrypoint()
def main():
    result = generate_text.remote("What is the capital of France?")
    print(result)
```

### 6. Run Your Function

```bash theme={null}
modal run app.py
```

## Key Features

### Serverless Infrastructure

* **Automatic scaling**: Scale to zero when idle
* **GPU access**: Use A10G, A100, or other GPUs
* **Fast cold starts**: Optimized container loading

### Flexible Deployment

<CardGroup cols={2}>
  <Card title="Any Model" icon="brain">
    Deploy any model from Hugging Face or custom weights
  </Card>

  <Card title="Custom Code" icon="code">
    Full control over inference pipeline
  </Card>

  <Card title="Multiple Frameworks" icon="layer-group">
    PyTorch, JAX, TensorFlow, ONNX, etc.
  </Card>

  <Card title="Auto Scaling" icon="arrows-maximize">
    Scale from zero to thousands of GPUs
  </Card>
</CardGroup>

## Use Cases

* **Custom Models**: Deploy proprietary or fine-tuned models
* **Batch Processing**: Process large datasets efficiently
* **Research**: Experiment with different model architectures
* **API Services**: Build production-grade inference APIs
* **Data Processing**: Run GPU-accelerated data pipelines

## Cost Optimization

<Note>
  Since Modal charges by compute time:

  * Use **smaller GPUs** for testing
  * Implement **caching** to avoid redundant computation
  * **Batch requests** when possible
  * Scale to **zero** when idle (automatic)
</Note>

## Resources

<CardGroup cols={2}>
  <Card title="Modal Platform" icon="link" href="https://modal.com">
    Access the platform
  </Card>

  <Card title="Documentation" icon="book" href="https://modal.com/docs">
    View documentation
  </Card>

  <Card title="Examples" icon="code" href="https://modal.com/docs/examples">
    Browse example apps
  </Card>

  <Card title="Pricing" icon="dollar-sign" href="https://modal.com/pricing">
    View pricing details
  </Card>
</CardGroup>

<Warning>
  Free credits are provided **monthly**. They reset each month and do not roll over.
</Warning>
