Usage

import Itzam from "itzam";
import { z } from "zod";

const itzam = new Itzam("YOUR_API_KEY");

const schema = z.array(
  z.object({
    name: z.string(),
    description: z.string(),
  })
);

const response = await itzam.generateObject({
  input: "List the characters in Atlas Shrugged",
  workflowSlug: "atlas-shrugged",
  schema,
});

console.log(response.object); // The generated object
console.log(response.metadata); // Metadata about the run

Parameters

ParameterTypeRequiredDescription
inputstringYesThe input text to generate a response for.
schemaobjectYesThe JSON schema that defines the structure of the expected response.
workflowSlugstringNoThe slug of the workflow to use for generation (not required if you’re using a threadId).
threadIdstringNoIdentifier for associating runs with a conversation thread.
attachmentsAttachment[]NoArray of attachments to include in the generation.

Return Value

The generateObject method returns the following object:

type GenerateObjectResponse<T> = {
  object: T; // The generated object based on your schema
  metadata: {
    runId: string; // The ID of the run
    cost: string; // The cost of the run in USD
    model: {
      name: string; // The name of the model
      tag: string; // The tag of the model
    };
    durationInMs: number; // The duration of the run in milliseconds
    inputTokens: number; // The number of input tokens used for this generation
    outputTokens: number; // The number of output tokens used for this generation
  };
};