Your booking prompt now holds up across all twelve notes in data/notes.json, and every one of those calls went to your provider’s capable model. The model/ module has a second role, fast, that you haven’t tried on the notes yet. Its model costs less per token, but is it good enough to read a booking note?
In this lesson, you’ll answer that the way you tested the prompt: with the whole set of notes, the records side by side, and the cost of each run in cents. You’ll also choose the settings that go with each model and see why the same request can still return different text. Start by pointing the notes at the other role.
Run the Notes on the Fast Model
A model’s place in its provider’s lineup won’t tell you whether it can read your notes. To find out, run it on your own inputs: the twelve notes. You already have the script that reads them all. To compare the roles, run that script once per role and add up the cost.
To price a call, you multiply each token count in its usage by the model’s price and add the two costs. Your project already does this with costInCents(usage, role) in cost.js. It takes a reply’s usage and a role, looks up that role’s prices per million tokens in model/config.js, and returns the cost in cents.
First, let read-notes.js take the role from the command line. Add the costInCents() import below the other imports, and add one line under today:
read-notes.js
import { costInCents } from "./cost.js";
// ...
const role = process.argv[2] ?? "capable";
process.argv holds the words of the command that started the script, so index 2 is the first word after the script’s name. With no word there, nullish coalescing falls back to "capable".
Then replace the loop with one that passes the role to ask(), adds up the cost of every call, and prints each note’s usage:
read-notes.js
let totalCents = 0;
for (const note of notes) {
const prompt = bookingPrompt(note, today, clinic);
const reply = await ask({ ...prompt, role });
totalCents += costInCents(reply.usage, role);
console.log(`#${note.id}`, reply.usage);
console.log(reply.cutOff ? "Held back: cut off" : reply.text);
}
console.log(`${role}: ${totalCents.toFixed(3)} cents`);
The spread syntax in { ...prompt, role } copies instructions and input from the template’s object into a new one and adds role.
Run the set once per role, first with node --env-file=.env read-notes.js capable and then with node --env-file=.env read-notes.js fast. Keep both outputs so you can read them side by side. The runs in this lesson all went to OpenAI. Here’s the end of each run, starting with capable. The other eleven records are cut, and your wording, token counts, and costs will differ:
...
#12 { inputTokens: 596, outputTokens: 96 }
kind: booking
species: ferret
pet name: Ziggy
problem: Frequent scratching and fur loss on his back
urgency: soon
preferred date: 2026-12-07
preferred time: morning
capable: 2.259 cents
The fast run cost less, but its record for Ziggy the ferret has no date:
...
#12 { inputTokens: 596, outputTokens: 143 }
kind: booking
species: ferret
pet name: Ziggy
problem: Excessive scratching and fur loss on his back
urgency: soon
preferred date: null
preferred time: morning
fast: 1.284 cents
Read every record from both runs, as you did when you tested the prompt. One run of each can’t tell you how often a difference happens, so run each role a few times and collect what you find in a table. Here are four runs of each role with OpenAI, on the same twelve notes, with the module as it is now:
| Role | Cents per set | Output tokens per set | Ziggy’s date | Juniper’s date |
|---|---|---|---|---|
capable |
2.259, 2.119, 2.296, 2.204 | 811, 671, 848, 756 | Monday, December 7, in 4 of 4 runs | Wednesday, December 2, in 4 of 4 runs |
fast |
1.284, 1.283, 1.262, 1.302 | 1,120, 1,119, 1,077, 1,156 | Monday, December 7, in 3 of 4 runs | null in 4 of 4 runs |
In all eight runs, the two roles agreed on the kind, species, pet name, and urgency of every note, Miso’s urgent included. The dates are where they differed.
Ziggy’s owner asked for “next Monday or Tuesday morning,” and the fast model missed it once. Juniper’s owner works from home on Wednesdays and Fridays. The capable model picked Wednesday and dropped Friday, while the fast model left the date null and wrote “any time on Wednesday or Friday” as the time.
Neither breaks a rule in the prompt. A record with room for one date can’t hold two. That’s a limit of this record’s shape, not of either model, and it’s one you could extend in your own version, with a list of dates, for example.
So, in these runs, the fast model came close for under three-fifths of the cost, but not all the way. A missing date is a phone call to an owner, so whether the saving is worth it depends on how often that happens. Four runs are a start, and that’s why you’ll rerun the set as you change the settings below.
Look at the output tokens, too. With OpenAI’s prices, the fast model costs half as much per token, yet it generated more output tokens for records that were no longer, so its sets cost more than half as much.
Most of those extra tokens are reasoning, generated before the visible text and billed as output though they never appear in it. A lower price per token doesn’t mean the same drop in cost. The gap between the two roles’ PRICES in model/config.js isn’t the same for both providers, so read your own totals.
The button above opens the mentor with that question, if you’d like to talk through what “good enough” should mean for the clinic before you pick a role.
Keep Each Role’s Settings in Its Provider File
Your request can control how much a model generates. Many current models take an effort setting: a level such as "low", "medium", or "high" that mostly changes how much they reason before they answer and, with Anthropic, also shapes the answer itself.
Higher effort generally trades more output tokens and a slower reply for better answers, most of all on problems that take several steps. That’s a tendency, so a single call can still go the other way.
Effort is a generation setting, a field sent with the request that changes what comes back, like the output limit you already set in .env. Not every model accepts every setting, and each provider names them differently, so they belong in the provider files, one settings object per role.
Open the version for your provider, and add the settings below CUT_OFF. The values are the ones each model already used when your request said nothing, so every call keeps the settings it had. The records themselves can still vary from run to run, as you’ll see at the end of this lesson:
OpenAI’s Responses API takes effort in a reasoning object. Both of the module’s OpenAI models, gpt-6.2-sol and gpt-6.1-terra, reported effort: "medium" in their responses when the request didn’t set one:
model/openai.js
// Settings for each role's model. Check a model's page for
// the settings it accepts before you add one here.
export const ROLE_SETTINGS = {
capable: { reasoning: { effort: "medium" } },
fast: { reasoning: { effort: "medium" } },
};
Then let send() add the role’s settings to the request body. It reads them from the request as roleSettings, next to the fields it already reads, and spreads them into the body after max_output_tokens:
model/openai.js
export async function send(request) {
const {
model, instructions, input, maxOutputTokens, roleSettings,
} = request;
const response = await fetch(ENDPOINT, {
// ...
body: JSON.stringify({
model,
instructions,
input,
max_output_tokens: maxOutputTokens,
...roleSettings,
}),
signal: request.signal,
});
Check that value against the documentation before you trust it. Open OpenAI’s page for gpt-6.1-terra, the fast model, and find the line on reasoning.effort. It lists the levels the model accepts, "none" up to "max", and marks "medium" as the default.
The values differ even within one provider: the capable model rejects "none" with a 400 error whose message lists the values it supports. So look up a role’s model on OpenAI’s models page before you change its settings.
Anthropic’s Messages API takes effort in an output_config object. When the request doesn’t set one, claude-sonnet-5-5 uses "high" and claude-haiku-5-5 uses "medium":
model/anthropic.js
// Settings for each role's model. Check a model's page for
// the settings it accepts before you add one here.
export const ROLE_SETTINGS = {
capable: { output_config: { effort: "high" } },
fast: { output_config: { effort: "medium" } },
};
Then let send() add the role’s settings to the request body. It reads them from the request as roleSettings, next to the fields it already reads, and spreads them into the body after max_tokens:
model/anthropic.js
export async function send(request) {
const {
model, instructions, input, maxOutputTokens, roleSettings,
} = request;
const response = await fetch(ENDPOINT, {
// ...
body: JSON.stringify({
model,
system: instructions,
messages: [{ role: "user", content: input }],
max_tokens: maxOutputTokens,
...roleSettings,
}),
signal: request.signal,
});
Check those values against the documentation before you trust them. Open Anthropic’s page on effort and find the levels it lists, from "low" to "max", along with the models that accept each one. Also find the line on default levels: "medium" for Claude Haiku 5.5 and "high" for most other models, Claude Sonnet 5.5 included.
Anthropic’s effort shapes the whole reply, not only the reasoning before it: it also changes how much text the model generates, and it applies even when the model doesn’t reason first. The two models start from different defaults, which is one reason to write the level down: a model change can’t quietly change the effort.
Both files now export ROLE_SETTINGS using their provider’s own field names, so ask() can pick the role’s settings the same way it picks the stop word in CUT_OFF. In model/index.js, find the object ask() passes to sendWithRetries() and add one property:
model/index.js
const reply = await sendWithRetries(adapter, {
model,
instructions,
input,
maxOutputTokens,
roleSettings: adapter.ROLE_SETTINGS[role],
});
That’s the whole change to model/. model/config.js keeps only the model IDs and their prices, and your scripts still ask for a role and nothing else.
The settings you copy from other code need the same check. Many older examples add temperature: 0 to every request “for consistent output,” but current models don’t all take it. Open the version for your provider to see why it stays out of ROLE_SETTINGS:
Neither of the module’s OpenAI models accepts temperature, because both reason before they answer. In one run with temperature: 0 added to the fast role’s settings, the first call failed and the script stopped. The error’s message is wrapped for display:
file:///.../model/http-error.js:6
const error = new Error(`${status}: ${message}`);
^
Error: 400: Unsupported parameter: 'temperature' is not supported
with this model.
...
status: 400,
retryable: false,
retryAfter: undefined
}
A 400 error isn’t retryable, so ask() rethrows it at once, and the uncaught error ends the script. Older OpenAI models accept temperature, which is why the examples have it.
Your module sends anthropic-version: 2026-10-21, and that version of the Messages API has no temperature field at all, on any model. Older API versions accepted it on older models, which is why the examples have it.
So a setting goes into ROLE_SETTINGS only after the model’s page says the model takes it. The promise those examples make doesn’t hold either. Even on a model that accepts it, temperature 0 doesn’t guarantee the same text twice.
Try a Lower Effort on the Fast Model
With the settings in one place, you can test whether a cheaper setting still gets the clinic’s fields right. Change one thing at a time. In your provider file, set the fast role’s effort to "low", and rerun node --env-file=.env read-notes.js fast. Here’s the end of one run with OpenAI:
...
#12 { inputTokens: 596, outputTokens: 70 }
kind: booking
species: ferret
pet name: Ziggy
problem: Excessive scratching and fur loss on his back
urgency: soon
preferred date: null
preferred time: morning
fast: 1.096 cents
Ziggy’s preferred date is null again. Four runs at low effort with OpenAI cost 1.096, 1.161, 1.123, and 1.101 cents, about an eighth less than the fast row in the table, and returned Monday, December 7, in only one of those runs. At medium effort, the fast model found it in three runs out of four.
Most of the output tokens you saved were reasoning the model skipped. Reasoning tokens count against MAX_OUTPUT_TOKENS too, because the limit covers the reasoning and the visible text together. The largest reply in these runs used 238 of the 400 tokens, but at a higher effort, a reply can hit the limit before the record is complete, or even before the model generates any visible text.
Your loop already prints “Held back: cut off” for such a reply. However little it cost, that reply is a failed call, so raise the limit before you rerun.
Working out a date from “next Monday” and the sent date takes several steps, and that’s the kind of work effort pays for. Saving under a fifth of a cent per twelve notes isn’t worth extra phone calls to owners, so on OpenAI’s fast model, put the effort back to "medium".
These runs were all on OpenAI, so they don’t show what low effort does on Anthropic’s model. If you use Anthropic, run your set a few times at each level you’re considering, add the results to a table like the one above, and choose from your own records.
Expect Different Text From the Same Request
Code that uses a model’s answer has to cope with how much that answer can change. When you send the same model, the same settings, and the same prompt more than once, how different can two answers be? Find out with Dana’s note, the first one in the set. Create repeat-note.js, which reads and parses the data files the way read-notes.js does and builds one prompt:
repeat-note.js
import { readFile } from "node:fs/promises";
import { ask } from "./model/index.js";
import { bookingPrompt } from "./booking-prompt.js";
const notesText = await readFile("data/notes.json", "utf8");
const clinicText = await readFile("data/clinic.json", "utf8");
const notes = JSON.parse(notesText);
const clinic = JSON.parse(clinicText);
const today = new Date().toISOString().slice(0, 10);
const prompt = bookingPrompt(notes[0], today, clinic);
The rest sends that prompt to the fast role five times. A Set keeps one copy of each distinct value, so records collects every different record, and dates collects every different preferred-date line:
repeat-note.js
const records = new Set();
const dates = new Set();
let failed = 0;
for (let run = 1; run <= 5; run += 1) {
const reply = await ask({ ...prompt, role: "fast" });
const lines = reply.text.split("\n");
const dateLine = lines.find((line) =>
line.startsWith("preferred date:")
);
if (reply.cutOff || dateLine === undefined) {
failed += 1;
continue;
}
records.add(reply.text);
dates.add(dateLine);
}
console.log("Failed replies:", failed);
console.log("Different records:", records.size);
console.log("Different dates:", dates.size, [...dates]);
Before the loop counts a reply, it screens out two kinds of incomplete replies. A reply that was cut off, or that has no preferred-date line, adds one to failed, and continue skips to the next call. Without that check, a broken reply would count as a record, and the missing line would add undefined to the dates.
Before you run it, predict the record and date counts. Five calls with the same model, settings, and prompt: How many different records come back, and how many different dates? Then run node --env-file=.env repeat-note.js.
Here’s one real run with OpenAI:
Failed replies: 0
Different records: 2
Different dates: 1 [ 'preferred date: 2026-12-08' ]
In five runs of the script with OpenAI, no reply failed, the record count was 1, 2, 1, 3, and 2, and the date was December 8 every time. When two records differed, it was in the wording of the problem, such as “won’t put weight on it” versus “won’t bear weight on it”.
Nothing in the request changed. A model generates its reply one token at a time, each picked from several likely ones, so wording drifts between calls even when the facts hold. Your counts can be anything from 1 to 5, so your code shouldn’t need identical text.
So check the parts that matter instead of the whole text. A test that compares a record with a saved string fails on “bear”. A test that compares the preferred date with the date Dana asked for checks what the clinic books, and it would have passed in every one of these runs.
That check can still fail on a live model, as Ziggy’s missing date showed. When a field check fails, the record itself is wrong, whatever its wording, and that’s the failure you want to hear about.
Right now, finding that field means searching the lines with .startsWith(). Later in the course, the model returns records as data with named fields, and your code checks each field directly. Consistency comes from the prompt, the checks, and the shape of the answer, not from a setting.
The button above opens the mentor with that question, if you’d like to work out what a test for the booking records should check.
Check Your Understanding
These questions use the runs and the module from this lesson. Answer them before you open the answers:
- The
fastmodel’s price per token is lower than thecapablemodel’s, yet in the OpenAI runs, the set cost more than that price ratio suggests. Where did the rest go? - A teammate wants to save more by lowering the
capablerole’s effort. What do you check before the change, and what do you run after it? - A teammate’s test calls
ask()with Dana’s note and fails whenreply.textisn’t exactly the record saved from last week’s run. Will it pass tomorrow? What should it check instead? - A code sample online sets
temperature: 0. You add it to your provider file anyway, and the call goes through on that model. Does that make the records identical between runs?
- Mostly into reasoning. In the OpenAI runs, the
fastmodel generated more output tokens than thecapablemodel for records that were no longer, such as 1,120 against 811 in the first runs, and reasoning is billed as output. Compare models by what real runs on your inputs cost. - Check the model’s page for the effort levels it accepts: a level one model takes, another can reject with a 400. With OpenAI, the
capablemodel rejects"none", which thefastmodel accepts. After the change, rerun the whole set a few times and read every record, the dates most of all: in the OpenAI runs, low effort cost thefastmodel Ziggy’s date in three runs out of four. - Not reliably. The same request can return different wording on any run, as the five runs of
repeat-note.jsshowed. The test should check the fields that matter, such as the kind, the urgency, and the preferred date, not the whole text. Those checks can still fail when the model gets a field wrong, and then they’ve caught a real problem. - No. Temperature 0 makes the wording less varied on the models that accept it, but providers don’t promise identical output. The code still checks fields, not whole strings.
You’ve now run the booking notes on both roles, priced each run in cents, and pinned each role’s settings in your provider file. Next, in Exercise: Write the Booking Prompt, you’ll write your own prompt that turns an owner’s note into an appointment record, from the instructions to the note in its tags.
This is the course’s first coding exercise, and it works differently from the lessons. You write and run the code in your browser, not in your terminal, and the tests check the prompt your code builds without calling a model, so the exercise needs no key and costs nothing.
When you click Run Tests, automated tests check what your code produces and show which passed and which failed. Run them early and often. When a test fails, read its message. It says what the test expected, and that’s your best clue to what to change. The exercise’s Contents tab, below the editor, explains the rest, such as working in Full screen.