Talking to LLMs from Jennifer

Jennifer

Claude™, GPT and Gemini™ side by side, with the @deckyard/anthropic, @deckyard/openai and @deckyard/gemini decks: messages, tools, errors, and tests that need no key.

November 2026, by @mplx.
Based on Jennifer 0.27.0

Powered by Jennifer's Cantrip - Markdown into slide decks, https://github.com/jennifer-language/cantrip
1 / 19

Three decks, one shape

@deckyard/anthropic@deckyard/openai@deckyard/gemini
APIClaude MessagesChat CompletionsGemini generateContent
Key in the examplesANTHROPIC_API_KEYOPENAI_API_KEYGEMINI_API_KEY
Model in the docsclaude-opus-5-5gpt-5.4-minigemini-3.8-flash
Error structAnthropicErrorOpenaiErrorGeminiError
Alsobatches, cachingOllama™, vLLM™, Azure™files, caches

Requests and replies are json.Value documents in each API's own shape.

2 / 19

Setup: the key comes from the environment

jvc add "@deckyard/anthropic" "^0.1.0"   # likewise openai, gemini
jvc install                              # into vendor/deckyard/...
export ANTHROPIC_API_KEY=...             # from a secret store
3 / 19

A first message: Claude

use io; use json; use os;
import "@deckyard/anthropic/" as anthropic;

def key as string init os.getEnv("ANTHROPIC_API_KEY");
def c as anthropic.Client init anthropic.client($key);
def req as json.Value init anthropic.newRequest("claude-opus-5-5");
$req = anthropic.withSystem($req, "Answer in one sentence.");
$req = anthropic.addUserText($req, "Why is the sky blue?");
def reply as json.Value init anthropic.chat($c, $req);
io.printf("%s\n", anthropic.text($reply));
Blue light is scattered most by the air (Rayleigh scattering).
4 / 19

The same in GPT and Gemini

def c as openai.Client init openai.client($key);   # OPENAI_API_KEY
def req as json.Value init openai.newRequest("gpt-5.4-mini");
$req = openai.withSystem($req, "Answer in one sentence.");
$req = openai.addUserText($req, "Why is the sky blue?");
io.printf("%s\n", openai.text(openai.chat($c, $req)));
def c as gemini.Client init gemini.client($key);   # GEMINI_API_KEY
def req as json.Value init gemini.newRequest("gemini-3.8-flash");
$req = gemini.withSystem($req, "Answer in one sentence.");
$req = gemini.addUserText($req, "Why is the sky blue?");
io.printf("%s\n", gemini.text(gemini.chat($c, $req)));
5 / 19

What actually goes on the wire

AnthropicOpenAIGemini
Path/v1/messages/v1/chat/completions/v1beta/models/<id>:generateContent
Modelin the bodyin the bodyin the path
System prompttop-level systema system messagesystemInstruction
max_tokensrequired, 16000 setnot setnot set
Key headerx-api-keyAuthorization: Bearerx-goog-api-key
6 / 19

Reading a reply

AnthropicOpenAIGemini
Texttext(reply)text(reply)text(reply)
Why it stoppedstopReason: end_turnfinishReason: stopfinishReason: STOP
No answerstop reason refusalrefusal(reply)blockReason(reply)

usage(reply) returns a Usage struct in all three: inputTokens (cache included), outputTokens, totalTokens, cachedTokens, reasoningTokens.

[end_turn, 21 in, 17 out]    [stop, 24 in, 15 out]    [STOP, 9 in, 14 out]
7 / 19

A conversation: addReply

def reply as json.Value init gemini.chat($c, $req);
io.printf("%s\n\n", gemini.text($reply));
$req = gemini.addReply($req, $reply);
$req = gemini.addUserText($req, "Now explain it to a five-year-old.");
$reply = gemini.chat($c, $req);
8 / 19

Streaming: not yet

Deadline of one attemptanthropicopenaigemini
default10 min10 min5 min
changewithTimeout(c, ms)withTimeout(c, ms)withTimeout(c, ms)
9 / 19

Tools: declare them

def schema as json.Value init json.decode(
    '{"type":"object","required":["item"],' +
    '"properties":{"item":{"type":"string"}},' +
    '"additionalProperties":false}');
def t as json.Value init anthropic.tool(
    "stock_level", "How many of an item are in stock.", $schema);
$req = anthropic.addTool($req, anthropic.withStrict($t));
10 / 19

Tools: the loop

func level(name as string, input as json.Value, stock as json.Value) {
    if ($name != "stock_level") {
        return anthropic.toolError("no tool " + $name);
    }
    def item as string init json.asString($input, "/item");
    if (json.typeOf($stock, "/" + $item) != "int") {
        return anthropic.toolError("unknown item " + $item);
    }
    def n as int init json.asInt($stock, "/" + $item);
    return json.decode('{"count":' + convert.toString($n) + '}');
}

anthropic.runToolsWith($c, $req, level, $stock, 10), also in openai and gemini

11 / 19

Tools: what happened

fake: POST /v1/messages (x-api-key) -> 200, 381 bytes in
fake: POST /v1/messages (x-api-key) -> 200, 915 bytes in
Reorder nuts (80) and washers (0); bolts are fine (1200).
[3 tool calls in 2 requests, stopped ""]
ToolRun fieldHolds
reply / requestthe last reply / the whole conversation
turns / callsrequests sent / tool calls run
usagethe Usage of every reply, summed
stopped"": the model finished; "maxTurns": the limit
12 / 19

Errors: one struct per deck

FieldAnthropicErrorOpenaiErrorGeminiError
kind"anthropic""openai""gemini", "gemini.blocked"
statusHTTP status, 0 if nonesamesame
retryAfterMsthe wait asked forsamesame
limitsrate-limit headerssamesame
vendor's owntype, requestIdtype, code, param, requestIdgoogleStatus, reason, blockReason
13 / 19

Errors: match the kind, then read fields

try {
    $reply = anthropic.chat($c, $req);
} catch (e) {
    if ($e.kind != "anthropic") {
        throw $e;
    }
    def err as anthropic.AnthropicError init $e;
    io.printf("HTTP %d %s, wait %d ms\n",
        $err.status, $err.type, $err.retryAfterMs);
}
HTTP 429 rate_limit_error, wait 30000 ms
14 / 19

Generic kinds and built-in retries

15 / 19

OpenAI-compatible servers

def local as openai.Client init openai.withBaseUrl(
    openai.client(""), "http://127.0.0.1:11434/v1");
def az as openai.Client init openai.azure($endpoint, $azureKey);
16 / 19

Testing without a key

def c as anthropic.Client init anthropic.client($key);
if (os.hasEnv("ANTHROPIC_BASE_URL")) {
    $c = anthropic.withBaseUrl($c, os.getEnv("ANTHROPIC_BASE_URL"));
}
17 / 19

A fake of your own

def srv as httpd.Server init httpd.listen("127.0.0.1:" + $port);
while (true) { # lint-disable: L105
    def req as httpd.Request init httpd.accept($srv);
    def path as string init httpd.path($req);
    # ... pick the next scripted answer for this path ...
    httpd.setHeader($req, "Content-Type", "application/json");
    httpd.respond($req, 200, $answer);
}
fake: POST /v1/messages (x-api-key) -> 429, retry-after 30
fake: POST /v1/chat/completions (Authorization) -> 200, 140 bytes in
fake: POST /v1beta/models/gemini-3.8-flash:generateContent ...
18 / 19

Read more

Based on Jennifer 0.27.0, November 2026.

19 / 19