# Morph Model Router

Classifies prompt difficulty or intent with Morph, then returns routing data for workflow branching or model selection. Use it before expensive AI calls when the workflow needs a low-cost decision about where a prompt should go.

## Configuration

**Connection** - Morph connection **id**. Use `list_connections`; pass the returned ULID `id`, not the connection name.

**Mode** - `classify` or `multimodel`.

**Classes** - Intent classes for `classify` mode. Each item has:

```json
{
  "label": "coding",
  "description": "Requests involving code edits or repository analysis",
  "threshold": 0.8
}
```

**Policy** - Multimodel routing policy: `balanced` or `cost_efficient`.

**Default model** - Fallback model for `multimodel` mode:

```json
{
  "provider_name": "openai",
  "model_id": "gpt-4.1-mini"
}
```

**Allowed providers / allowed models** - Limits the model choices Morph can return in `multimodel` mode.

## Inputs & Outputs

**Input:** canonical `input`.

Accepted shapes:

```json
"Prompt text"
```

```json
{ "prompt": "Prompt text" }
```

**Output:** canonical `output`.

## Classify Output

```json
{
  "mode": "classify",
  "classifications": [
    { "label": "coding", "score": 0.91 }
  ]
}
```

- `label`: one of the configured class labels.
- `score`: Morph confidence for that class.

Use `classify` when the workflow branches by intent, task type, or difficulty bucket.

## Multimodel Output

```json
{
  "mode": "multimodel",
  "provider_name": "openai",
  "model_id": "gpt-4.1-mini",
  "difficulty": "easy",
  "confidence": 0.9
}
```

- `provider_name`: model provider to use.
- `model_id`: model identifier to call.
- `difficulty`: Morph's prompt difficulty classification.
- `confidence`: confidence in the selected route.

Use `multimodel` when the next AI node should choose between cheaper and stronger model tiers.

## Example

```
[Prompt]
    ↓
[Morph Model Router: multimodel]
    ↓ output.provider_name / output.model_id
[AI Agent]
```
