JavaScript & TypeScript
Generate Object
Learn how to generate structured objects using the JavaScript SDK.
Overview
The generateObject
method allows you to generate structured objects from your workflows using a Zod or JSON schema. This is useful when you want to generate structured data such as lists, entities, or custom objects.
Usage
Parameters
Parameter | Type | Description |
---|---|---|
input | string | The input text to generate a response for. |
workflowSlug | string | The slug of the Workflow to use for generation. |
groupId | string | Optional. Identifier for grouping related runs. |
schema | ZodType /JsonSchema | The Zod or JSON schema describing the expected object structure. |
Return Value
The generateObject
method returns the following object:
Error Handling
All errors thrown by the SDK extend from the base ItzamError
class. See Error Handling for details.
Inspecting Runs
You can use the runId
from the response metadata to fetch more details about the run using getRunById
.