> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trycordage.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Models

> Use models for image generation, enhancement, and more

Cordage integrates with [Replicate](https://replicate.com) to provide access to thousands of AI models. This guide covers how to find, configure, and chain models in your workflows.

## Adding a Model Node

1. Drag a **Model** node from the Node Palette
2. Click the node to open the model selector
3. Browse or search for a model
4. Click to select and configure

## Finding Models

### Search

Type keywords in the search bar:

* Model names: "flux", "sdxl", "stable-diffusion"
* Capabilities: "upscale", "remove background", "face swap"
* Categories: "image generation", "video", "audio"

### Browse by Category

Models are organized into categories:

* **Image Generation**: Create images from text prompts
* **Image-to-Image**: Transform existing images
* **Upscaling**: Increase image resolution
* **Video**: Generate or transform videos
* **Audio**: Speech, music, and sound
* **Text**: Language models for text processing

### Popular Models

<AccordionGroup>
  <Accordion title="Image Generation" icon="wand-magic-sparkles">
    * **Flux Schnell** - Fast, high-quality image generation
    * **Flux Pro** - Premium quality, more detail
    * **SDXL** - Stable Diffusion XL base model
    * **Stable Diffusion 3** - Latest SD version
  </Accordion>

  <Accordion title="Image Enhancement" icon="arrow-up-right-dots">
    * **Real-ESRGAN** - General purpose upscaling
    * **Clarity Upscaler** - Detail-preserving upscale
    * **GFPGAN** - Face enhancement
  </Accordion>

  <Accordion title="Image Editing" icon="pen-to-square">
    * **RemBG** - Background removal
    * **Inpainting Models** - Fill or replace regions
    * **ControlNet** - Guided image generation
  </Accordion>

  <Accordion title="Video" icon="film">
    * **Stable Video Diffusion** - Image to video
    * **AnimateDiff** - Animation generation
    * **Video Upscalers** - Enhance video quality
  </Accordion>
</AccordionGroup>

## Configuring Models

### Model Parameters

Each model has unique parameters. Common ones include:

| Parameter             | Description                        | Typical Values        |
| --------------------- | ---------------------------------- | --------------------- |
| `prompt`              | Text description of desired output | Any text              |
| `negative_prompt`     | What to avoid in the output        | "blurry, low quality" |
| `width` / `height`    | Output dimensions                  | 512-2048 pixels       |
| `num_outputs`         | Number of images to generate       | 1-4                   |
| `guidance_scale`      | How closely to follow prompt       | 1-20 (typically 7.5)  |
| `num_inference_steps` | Generation quality/speed           | 20-100                |
| `seed`                | Random seed for reproducibility    | Any integer           |

### Dynamic Inputs

Model inputs appear automatically based on the selected model:

```mermaid theme={null}
flowchart TB
    subgraph Model["Model: Flux Schnell"]
        I1["prompt (required)"]
        I2["aspect_ratio"]
        I3["num_outputs"]
        I4["output_format"]
        I5["output_quality"]
    end
```

### Connecting to Model Inputs

Instead of typing values directly, connect nodes to model inputs:

```mermaid theme={null}
flowchart LR
    A["Text Input: 'landscape'"] -->|prompt| C[Flux Model]
    B["Image Input: reference.jpg"] -->|image| D[Img2Img Model]
    E["Number: 1024"] -->|width| F[Model]
```

This enables dynamic, reusable workflows.

## Model Execution

### Running Models

Models execute when:

1. All required inputs have data
2. An Export node is run
3. The workflow is triggered via webhook

### Execution Status

Watch the node status indicator:

* **Gray**: Not started
* **Blue spinner**: Running
* **Green check**: Completed
* **Red X**: Failed

### Viewing Results

After execution:

* Preview appears in the node
* Click preview to view full size
* Check inspector for run history
* Access outputs in connected nodes

### Handling Errors

Common model errors:

| Error                  | Cause                                      | Solution                           |
| ---------------------- | ------------------------------------------ | ---------------------------------- |
| "Invalid prompt"       | Prompt too long or contains banned content | Shorten or modify prompt           |
| "Insufficient credits" | Account needs credits                      | Add credits in settings            |
| "Model timeout"        | Generation took too long                   | Try simpler prompt or smaller size |
| "NSFW content"         | Content policy violation                   | Modify prompt content              |

## Chaining Models

### Sequential Processing

Connect models in sequence for multi-stage processing:

```mermaid theme={null}
flowchart LR
    A[Text] --> B[Generate Model]
    B --> C[Upscale Model]
    C --> D[Export]
```

Each model's output becomes the next model's input.

### Parallel Processing

Create variations by branching:

```mermaid theme={null}
flowchart LR
    A[Text Input] --> B[Style A Model]
    A --> C[Style B Model]
    B --> D[Export A]
    C --> E[Export B]
```

Both models process the same prompt simultaneously.

### Image-to-Image Workflows

Use generated images as input for other models:

```mermaid theme={null}
flowchart LR
    A[Text] --> B[Base Model]
    B --> C[Enhancement Model]
    C --> D[Final Model]
    D --> E[Export]
```

### Combining AI + Tools

Mix AI models with tool nodes:

```mermaid theme={null}
flowchart LR
    A[Text] --> B[Model]
    B --> C[Crop]
    C --> D[Resize]
    D --> E[Export]
```

## Advanced Techniques

### ControlNet

Use ControlNet models for guided generation:

```mermaid theme={null}
flowchart LR
    A[Reference Image] -->|control_image| C[ControlNet Model]
    B[Prompt Text] -->|prompt| C
    C --> D[Output]
```

ControlNet types:

* **Canny**: Edge-guided generation
* **Depth**: Depth map-guided
* **Pose**: Human pose-guided
* **Scribble**: Sketch-guided

### Inpainting

Edit specific regions of images:

```mermaid theme={null}
flowchart LR
    A[Source Image] -->|image| D[Inpainting Model]
    B[Mask Image] -->|mask| D
    C[Edit Prompt] -->|prompt| D
    D --> E[Output]
```

### Style Transfer

Apply artistic styles:

```mermaid theme={null}
flowchart LR
    A[Content Image] --> C[Style Model]
    B[Style Image] --> C
    C --> D[Output]
```

## Model Costs

Models consume credits based on:

* Model complexity
* Output size and count
* Processing time

Check the model card for pricing information before running.

<Tip>
  Use faster models like **Flux Schnell** during development, then switch to higher-quality models for final outputs.
</Tip>

## Best Practices

<Tip>
  **Test with small outputs** - Use lower resolution during testing to save credits.
</Tip>

<Tip>
  **Use seeds for reproducibility** - Set a seed when you want consistent results.
</Tip>

<Tip>
  **Chain strategically** - Not every workflow needs multiple models. Start simple.
</Tip>

<Tip>
  **Check model documentation** - Each model has unique capabilities and limitations.
</Tip>
