# `ai.connection_required`

Action asks a model but the application names no `ai:` connection.

Area 21, [AI](../topics/ai.md); not declinable; the next step is usually the agent's.

Every `ai` call goes through the connection `application { ai: }` names,
so an action that asks a model in an application that names none has
nothing to ask through.







```jadpo
use support/types { CustomerQuestion, SupportAnswer }
use support/failures { AssistantUnavailable }
use support/prompts { AnswerQuestion }

/// Answers a customer's question.
action answer_customer(
    customer_question: CustomerQuestion
) fails AssistantUnavailable -> SupportAnswer {
    return attempt ai.generate(
        AnswerQuestion {
            question: customer_question
        },
        as: SupportAnswer
    ) {
        refused: AssistantUnavailable
        malformed: AssistantUnavailable
        timed_out: AssistantUnavailable
        over_budget: AssistantUnavailable
        too_long: AssistantUnavailable
    }
}
```

```text
error: `ai.generate` asks a model, and the application names none
 --> domains/support/actions/answer_customer.jadpo:9:20
  |
9 |     return attempt ai.generate(
  |                    ^^^^^^^^^^^ no `ai:` to ask through
  reason: Every `ai` call goes through the connection `application { ai: { connection: } }` names, asking a model `models:` lists, each a `ModelId` setting, so changing a model or a provider changes `app.jadpo` and nothing else.
  next: Add `ai: { connection: <name>  models: { default: config.<name> } }` to `application { }` in `app.jadpo`, naming a connection with `driver: Driver.openai_compatible` (agent)
  rule: ai.connection_required
  help: https://jadpo.dev/docs/errors/ai.connection_required

check failed: 1 error, 6 files
```
