Skip to content
Discussion options

You must be logged in to vote

Hi @rbadillap 👋

Core idea: experimental_output only guarantees JSON-serializable shapes at runtime. Types like Prompt (from ai) or your own classes aren’t serializable, so you should expose a DTO (plain JSON) for the model, then map ↔︎ your richer types in your app.

**What to do

  1. Define a JSON DTO schema (e.g. Zod)**
import { z } from "zod";

export const ClassificationOutputSchema = z.object({
  prompt: z.object({
    text: z.string(),
    // add only serializable fields you need from Prompt
  }),
  context: z.object({
    userId: z.string().uuid().optional(),
    locale: z.string().optional(),
    // ...
  })
});

export type ClassificationOutputDTO = z.infer<typeof ClassificationOutpu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rbadillap
Comment options

Answer selected by rbadillap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants