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.
contextSlugsstring[]NoThe slugs of the contexts that the AI model can access.
typestringNoUsed to indicate the response type (only “event” is supported for now).
callbackCallbackNoThe callback object to receive the webhook.

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
  };
};
If you use the type and callback parameters, this will return the following object:
type WebhookResponse = {
  message: string; // A message to indicate that the webhook was queued
  runId: string; // The ID of the run
};