Signal · guides

How to do things with Signal.

Each guide is a file you can run. Most of these ask a model, so this site checks their types and does not run them, and their pages say what comes back. Those that need no model are run, and their pages show what they printed.

First steps.

A model reads a booking out of one line of an email, and what comes back is an object the Zod schema has checked.

Install it
pnpm add @niscorp/signal zod openai
Run it
GROQ_API_KEY=your-key npx tsx first.mts
Write first.mts
import { createSignal } from '@niscorp/signal';
import { z } from 'zod';

const signal = createSignal('groq');

const { response: booking } = await signal
  .schema(z.object({ show: z.string(), seats: z.number() }))
  .complete('Two for The Tempest on Saturday, please. Grace');
console.log(booking);

This one needs a model: it asks Groq, with the key it reads from GROQ_API_KEY. No page on this site calls a model, so nothing is printed here. What comes back is an object with a show and a number of seats, checked against the schema before you see it.

Then, one at a time.

Each is a file of its own and adds one thing. Read them in order, or go to the one you need.