@ljoukov/llm 5.0.4 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -137,7 +137,7 @@ configureModelConcurrency({
137
137
  fireworks: 8,
138
138
  },
139
139
  modelCaps: {
140
- "gpt-5.2": 24,
140
+ "gpt-5.4-mini": 24,
141
141
  },
142
142
  providerModelCaps: {
143
143
  google: {
@@ -168,7 +168,7 @@ Use OpenAI-style request fields:
168
168
  import { generateText } from "@ljoukov/llm";
169
169
 
170
170
  const result = await generateText({
171
- model: "gpt-5.2",
171
+ model: "gpt-5.4-mini",
172
172
  input: "Write one sentence about TypeScript.",
173
173
  });
174
174
 
@@ -182,7 +182,7 @@ console.log(result.usage, result.costUsd);
182
182
  import { streamText } from "@ljoukov/llm";
183
183
 
184
184
  const call = streamText({
185
- model: "gpt-5.2",
185
+ model: "gpt-5.4-mini",
186
186
  input: "Explain what a hash function is in one paragraph.",
187
187
  });
188
188
 
@@ -228,7 +228,7 @@ const input: LlmInputMessage[] = [
228
228
  },
229
229
  ];
230
230
 
231
- const result = await generateText({ model: "gpt-5.2", input });
231
+ const result = await generateText({ model: "gpt-5.4-mini", input });
232
232
  console.log(result.text);
233
233
  ```
234
234
 
@@ -256,7 +256,7 @@ const input: LlmInputMessage[] = [
256
256
  },
257
257
  ];
258
258
 
259
- const result = await generateText({ model: "gpt-5.2", input });
259
+ const result = await generateText({ model: "gpt-5.4-mini", input });
260
260
  console.log(result.text);
261
261
  ```
262
262
 
@@ -314,7 +314,7 @@ const input: LlmInputMessage[] = [
314
314
  },
315
315
  ];
316
316
 
317
- const result = await generateText({ model: "gpt-5.2", input });
317
+ const result = await generateText({ model: "gpt-5.4-mini", input });
318
318
  console.log(result.text);
319
319
  ```
320
320
 
@@ -323,6 +323,20 @@ canonical files automatically. Tool loops do the same for large tool outputs, an
323
323
  after parallel tool calls so a batch of individually-small images/files still gets upgraded to `file_id` references
324
324
  before the next model request if the aggregate payload is too large.
325
325
 
326
+ You can also control image analysis fidelity with request-level `mediaResolution`:
327
+
328
+ - `low`, `medium`, `high`, `original`, `auto`
329
+ - OpenAI / ChatGPT map this onto image `detail`
330
+ - Gemini maps this onto media resolution/tokenization settings
331
+
332
+ ```ts
333
+ const result = await generateText({
334
+ model: "gpt-5.4",
335
+ mediaResolution: "original",
336
+ input,
337
+ });
338
+ ```
339
+
326
340
  OpenAI-style direct file-id example:
327
341
 
328
342
  ```ts
@@ -364,7 +378,7 @@ const input: LlmInputMessage[] = [
364
378
  },
365
379
  ];
366
380
 
367
- const result = await generateText({ model: "gpt-5.2", input });
381
+ const result = await generateText({ model: "gpt-5.4-mini", input });
368
382
  console.log(result.text);
369
383
  ```
370
384
 
@@ -390,7 +404,7 @@ const input: LlmInputMessage[] = [
390
404
  },
391
405
  ];
392
406
 
393
- const result = await generateText({ model: "gpt-5.2", input });
407
+ const result = await generateText({ model: "gpt-5.4-mini", input });
394
408
  console.log(result.text);
395
409
  ```
396
410
 
@@ -439,6 +453,11 @@ console.log(result.text);
439
453
 
440
454
  `chatgpt-gpt-5.4-fast` is also supported as a convenience alias for ChatGPT-authenticated `gpt-5.4` with priority processing enabled (`service_tier="priority"`), matching Codex `/fast` semantics.
441
455
 
456
+ Supported OpenAI text model ids are fixed literal unions in code, not arbitrary strings:
457
+
458
+ - OpenAI API: `gpt-5.4`, `gpt-5.4-mini`, `gpt-5.4-nano`
459
+ - ChatGPT auth: `chatgpt-gpt-5.4`, `chatgpt-gpt-5.4-fast`, `chatgpt-gpt-5.4-mini`, `chatgpt-gpt-5.3-codex-spark`
460
+
442
461
  ## JSON outputs
443
462
 
444
463
  `generateJson()` validates the output with Zod and returns the parsed value.
@@ -458,7 +477,7 @@ const schema = z.object({
458
477
  });
459
478
 
460
479
  const { value } = await generateJson({
461
- model: "gpt-5.2",
480
+ model: "gpt-5.4-mini",
462
481
  input: "Return a JSON object with ok=true and message='hello'.",
463
482
  schema,
464
483
  });
@@ -481,7 +500,7 @@ const schema = z.object({
481
500
  });
482
501
 
483
502
  const call = streamJson({
484
- model: "gpt-5.2",
503
+ model: "gpt-5.4-mini",
485
504
  input: "Return a JSON object with ok=true and message='hello'.",
486
505
  schema,
487
506
  });
@@ -503,7 +522,7 @@ If you only want thought deltas (no partial JSON), set `streamMode: "final"`.
503
522
 
504
523
  ```ts
505
524
  const call = streamJson({
506
- model: "gpt-5.2",
525
+ model: "gpt-5.4-mini",
507
526
  input: "Return a JSON object with ok=true and message='hello'.",
508
527
  schema,
509
528
  streamMode: "final",
@@ -514,7 +533,7 @@ If you want to keep `generateJson()` but still stream thoughts, pass an `onEvent
514
533
 
515
534
  ```ts
516
535
  const { value } = await generateJson({
517
- model: "gpt-5.2",
536
+ model: "gpt-5.4-mini",
518
537
  input: "Return a JSON object with ok=true and message='hello'.",
519
538
  schema,
520
539
  onEvent: (event) => {
@@ -551,13 +570,13 @@ configureTelemetry({
551
570
  });
552
571
 
553
572
  const { value } = await generateJson({
554
- model: "gpt-5.2",
573
+ model: "gpt-5.4-mini",
555
574
  input: "Return { ok: true }.",
556
575
  schema: z.object({ ok: z.boolean() }),
557
576
  });
558
577
 
559
578
  await runAgentLoop({
560
- model: "gpt-5.2",
579
+ model: "gpt-5.4-mini",
561
580
  input: "Inspect the repo and update the file.",
562
581
  filesystemTool: true,
563
582
  });
@@ -567,7 +586,7 @@ Per-call opt-out:
567
586
 
568
587
  ```ts
569
588
  await generateJson({
570
- model: "gpt-5.2",
589
+ model: "gpt-5.4-mini",
571
590
  input: "Return { ok: true }.",
572
591
  schema: z.object({ ok: z.boolean() }),
573
592
  telemetry: false,
@@ -598,7 +617,7 @@ Use this when the model provider executes the tool remotely (for example search/
598
617
  import { generateText } from "@ljoukov/llm";
599
618
 
600
619
  const result = await generateText({
601
- model: "gpt-5.2",
620
+ model: "gpt-5.4-mini",
602
621
  input: "Find 3 relevant sources about X and summarize them.",
603
622
  tools: [{ type: "web-search", mode: "live" }, { type: "code-execution" }],
604
623
  });
@@ -615,7 +634,7 @@ import { runToolLoop, tool } from "@ljoukov/llm";
615
634
  import { z } from "zod";
616
635
 
617
636
  const result = await runToolLoop({
618
- model: "gpt-5.2",
637
+ model: "gpt-5.4-mini",
619
638
  input: "What is 12 * 9? Use the tool.",
620
639
  tools: {
621
640
  multiply: tool({
@@ -641,7 +660,7 @@ import { streamToolLoop, tool } from "@ljoukov/llm";
641
660
  import { z } from "zod";
642
661
 
643
662
  const call = streamToolLoop({
644
- model: "chatgpt-gpt-5.3-codex",
663
+ model: "chatgpt-gpt-5.3-codex-spark",
645
664
  input: "Start implementing the feature.",
646
665
  tools: {
647
666
  echo: tool({
@@ -665,7 +684,7 @@ import { createToolLoopSteeringChannel, runAgentLoop } from "@ljoukov/llm";
665
684
 
666
685
  const steering = createToolLoopSteeringChannel();
667
686
  const run = runAgentLoop({
668
- model: "chatgpt-gpt-5.3-codex",
687
+ model: "chatgpt-gpt-5.3-codex-spark",
669
688
  input: "Implement the task.",
670
689
  filesystemTool: true,
671
690
  steering,
@@ -683,13 +702,15 @@ const result = await run;
683
702
  - built-in subagent orchestration (delegate work across spawned agents),
684
703
  - your own custom runtime tools.
685
704
 
705
+ Subagents always inherit the parent run model. The subagent control tools do not expose a model override.
706
+
686
707
  For interactive runs where you want to stream events and inject steering mid-run, use `streamAgentLoop()`:
687
708
 
688
709
  ```ts
689
710
  import { streamAgentLoop } from "@ljoukov/llm";
690
711
 
691
712
  const call = streamAgentLoop({
692
- model: "chatgpt-gpt-5.3-codex",
713
+ model: "chatgpt-gpt-5.3-codex-spark",
693
714
  input: "Start implementation.",
694
715
  filesystemTool: true,
695
716
  });
@@ -704,7 +725,7 @@ console.log(result.text);
704
725
  For read/search/write tasks in a workspace, enable `filesystemTool`. The library auto-selects a tool profile by model
705
726
  when `profile: "auto"`:
706
727
 
707
- - Codex-like models (`gpt-5.4`, `chatgpt-gpt-5.4`, `chatgpt-gpt-5.4-fast`, and `*codex*` variants): Codex-compatible filesystem tool shape.
728
+ - Codex-like models (`gpt-5.4`, `chatgpt-gpt-5.4`, `chatgpt-gpt-5.4-fast`, and `chatgpt-gpt-5.3-codex-spark`): Codex-compatible filesystem tool shape.
708
729
  - Gemini models: Gemini-compatible filesystem tool shape.
709
730
  - Other models: model-agnostic profile (currently Gemini-style).
710
731
 
@@ -714,6 +735,7 @@ Confinement/policy is set through `filesystemTool.options`:
714
735
  - `fs`: backend (`createNodeAgentFilesystem()` or `createInMemoryAgentFilesystem()`).
715
736
  - `checkAccess`: hook for allow/deny policy + audit.
716
737
  - `allowOutsideCwd`: opt-out confinement (default is false).
738
+ - `mediaResolution`: default image fidelity for built-in `view_image` outputs.
717
739
 
718
740
  Detailed reference: `docs/agent-filesystem-tools.md`.
719
741
 
@@ -727,7 +749,7 @@ const fs = createInMemoryAgentFilesystem({
727
749
  });
728
750
 
729
751
  const result = await runAgentLoop({
730
- model: "chatgpt-gpt-5.3-codex",
752
+ model: "chatgpt-gpt-5.3-codex-spark",
731
753
  input: "Change value from 1 to 2 using filesystem tools.",
732
754
  filesystemTool: {
733
755
  profile: "auto",
@@ -753,7 +775,7 @@ Enable `subagentTool` to allow delegation via Codex-style control tools:
753
775
  import { runAgentLoop } from "@ljoukov/llm";
754
776
 
755
777
  const result = await runAgentLoop({
756
- model: "chatgpt-gpt-5.3-codex",
778
+ model: "chatgpt-gpt-5.3-codex-spark",
757
779
  input: "Plan the work, delegate in parallel where useful, and return a final merged result.",
758
780
  subagentTool: {
759
781
  enabled: true,
@@ -775,7 +797,7 @@ const fs = createInMemoryAgentFilesystem({
775
797
  });
776
798
 
777
799
  const result = await runAgentLoop({
778
- model: "chatgpt-gpt-5.3-codex",
800
+ model: "chatgpt-gpt-5.3-codex-spark",
779
801
  input: "Change value from 1 to 2 using filesystem tools.",
780
802
  filesystemTool: {
781
803
  profile: "auto",
@@ -819,7 +841,7 @@ import path from "node:path";
819
841
  import { runAgentLoop } from "@ljoukov/llm";
820
842
 
821
843
  await runAgentLoop({
822
- model: "chatgpt-gpt-5.3-codex",
844
+ model: "chatgpt-gpt-5.3-codex-spark",
823
845
  input: "Do the task",
824
846
  filesystemTool: true,
825
847
  logging: {
@@ -848,13 +870,13 @@ import {
848
870
  } from "@ljoukov/llm";
849
871
 
850
872
  const fs = createInMemoryAgentFilesystem({ "/repo/a.ts": "export const n = 1;\n" });
851
- const tools = createFilesystemToolSetForModel("chatgpt-gpt-5.3-codex", {
873
+ const tools = createFilesystemToolSetForModel("chatgpt-gpt-5.3-codex-spark", {
852
874
  cwd: "/repo",
853
875
  fs,
854
876
  });
855
877
 
856
878
  const result = await runToolLoop({
857
- model: "chatgpt-gpt-5.3-codex",
879
+ model: "chatgpt-gpt-5.3-codex-spark",
858
880
  input: "Update n to 2.",
859
881
  tools,
860
882
  });