# `semantic.ai_output_type`

Type a model is asked to answer as is one no model's answer can be.

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

`ai.generate`'s `as:` names a type a model's answer can be: JSON decoded
as `json.read` decodes it. A reference to a record, a `File`, `Bytes` or
`PresentationText`, anywhere in it, is something no model's JSON can be.




```jadpo
/// A cake a customer described, as the bakers make it.
type CakeDesign = Object {
    /// What the bakers call it.
    title: Text
    /// A picture of it.
    preview: Bytes
}
```




```jadpo
use bakery/types { CakeBrief, CakeDesign }
use bakery/failures { DesignerUnavailable }
use bakery/prompts { DesignCake }

/// Drafts a cake from a customer's brief.
action draft_cake(brief: CakeBrief) fails DesignerUnavailable -> CakeDesign {
    return attempt ai.generate(
        DesignCake {
            brief: brief
        },
        as: CakeDesign
    ) {
        refused: DesignerUnavailable
        malformed: DesignerUnavailable
        timed_out: DesignerUnavailable
        over_budget: DesignerUnavailable
        too_long: DesignerUnavailable
    }
}
```

```text
error: A model can't answer as `CakeDesign`
 --> domains/bakery/actions/draft_cake.jadpo:11:13
   |
11 |         as: CakeDesign
   |             ^^^^^^^^^^ `CakeDesign.preview` is bytes
  reason: A model's answer is JSON decoded into `as:`'s type, and `CakeDesign.preview` is bytes, which a model's JSON can't be. A model answers in text.
  next: Ask for a type without `CakeDesign.preview` (agent)
  rule: semantic.ai_output_type
  help: https://jadpo.dev/docs/errors/semantic.ai_output_type

check failed: 1 error, 7 files
```
