Usage

import Itzam from "itzam";

const itzam = new Itzam("YOUR_API_KEY");

const response = await itzam.generateText({
  input: "What is the capital of France?",
  workflowSlug: "my-workflow",
  threadId: "thread_424242",
});

console.log(response.text); // "The capital of France is Paris"

Parameters

ParameterTypeRequiredDescription
inputstringYesThe input text to generate a response for.
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 generateText method returns the following object:

type GenerateTextResponse = {
  text: string; // The generated text
  metadata: {
    runId: string; // The ID of the run
    cost: number; // 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
  };
};