@ljoukov/llm 4.0.2 → 4.0.3

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
@@ -333,13 +333,15 @@ Use a `chatgpt-` prefix:
333
333
  import { generateText } from "@ljoukov/llm";
334
334
 
335
335
  const result = await generateText({
336
- model: "chatgpt-gpt-5.1-codex-mini",
336
+ model: "chatgpt-gpt-5.4",
337
337
  input: "Return exactly: OK",
338
338
  });
339
339
 
340
340
  console.log(result.text);
341
341
  ```
342
342
 
343
+ `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.
344
+
343
345
  ## JSON outputs
344
346
 
345
347
  `generateJson()` validates the output with Zod and returns the parsed value.
package/dist/index.cjs CHANGED
@@ -317,6 +317,16 @@ var OPENAI_GPT_52_PRICING = {
317
317
  cachedRate: 0.175 / 1e6,
318
318
  outputRate: 14 / 1e6
319
319
  };
320
+ var OPENAI_GPT_54_PRICING = {
321
+ inputRate: 2.5 / 1e6,
322
+ cachedRate: 0.25 / 1e6,
323
+ outputRate: 15 / 1e6
324
+ };
325
+ var OPENAI_GPT_54_PRIORITY_PRICING = {
326
+ inputRate: 5 / 1e6,
327
+ cachedRate: 0.5 / 1e6,
328
+ outputRate: 30 / 1e6
329
+ };
320
330
  var OPENAI_GPT_53_CODEX_PRICING = {
321
331
  inputRate: 1.25 / 1e6,
322
332
  cachedRate: 0.125 / 1e6,
@@ -328,6 +338,12 @@ var OPENAI_GPT_5_MINI_PRICING = {
328
338
  outputRate: 2 / 1e6
329
339
  };
330
340
  function getOpenAiPricing(modelId) {
341
+ if (modelId.includes("gpt-5.4-fast")) {
342
+ return OPENAI_GPT_54_PRIORITY_PRICING;
343
+ }
344
+ if (modelId.includes("gpt-5.4")) {
345
+ return OPENAI_GPT_54_PRICING;
346
+ }
331
347
  if (modelId.includes("gpt-5.3-codex-spark")) {
332
348
  return OPENAI_GPT_5_MINI_PRICING;
333
349
  }
@@ -2738,11 +2754,18 @@ async function runOpenAiCall(fn, modelId, runOptions) {
2738
2754
  }
2739
2755
 
2740
2756
  // src/openai/models.ts
2741
- var OPENAI_MODEL_IDS = ["gpt-5.3-codex", "gpt-5.2", "gpt-5.1-codex-mini"];
2757
+ var OPENAI_MODEL_IDS = [
2758
+ "gpt-5.4",
2759
+ "gpt-5.3-codex",
2760
+ "gpt-5.2",
2761
+ "gpt-5.1-codex-mini"
2762
+ ];
2742
2763
  function isOpenAiModelId(value) {
2743
2764
  return OPENAI_MODEL_IDS.includes(value);
2744
2765
  }
2745
2766
  var CHATGPT_MODEL_IDS = [
2767
+ "chatgpt-gpt-5.4",
2768
+ "chatgpt-gpt-5.4-fast",
2746
2769
  "chatgpt-gpt-5.3-codex",
2747
2770
  "chatgpt-gpt-5.3-codex-spark",
2748
2771
  "chatgpt-gpt-5.2",
@@ -2754,6 +2777,17 @@ function isChatGptModelId(value) {
2754
2777
  function stripChatGptPrefix(model) {
2755
2778
  return model.slice("chatgpt-".length);
2756
2779
  }
2780
+ function resolveChatGptProviderModel(model) {
2781
+ switch (model) {
2782
+ case "chatgpt-gpt-5.4-fast":
2783
+ return "gpt-5.4";
2784
+ default:
2785
+ return stripChatGptPrefix(model);
2786
+ }
2787
+ }
2788
+ function resolveChatGptServiceTier(model) {
2789
+ return model === "chatgpt-gpt-5.4-fast" ? "priority" : void 0;
2790
+ }
2757
2791
 
2758
2792
  // src/agentLogging.ts
2759
2793
  var import_node_async_hooks = require("async_hooks");
@@ -3502,7 +3536,11 @@ function convertLlmContentToGeminiContent(content) {
3502
3536
  }
3503
3537
  function resolveProvider(model) {
3504
3538
  if (isChatGptModelId(model)) {
3505
- return { provider: "chatgpt", model: stripChatGptPrefix(model) };
3539
+ return {
3540
+ provider: "chatgpt",
3541
+ model: resolveChatGptProviderModel(model),
3542
+ serviceTier: resolveChatGptServiceTier(model)
3543
+ };
3506
3544
  }
3507
3545
  if (isGeminiTextModelId(model) || isGeminiImageModelId(model)) {
3508
3546
  return { provider: "gemini", model };
@@ -5213,6 +5251,7 @@ async function runTextCall(params) {
5213
5251
  model: modelForProvider,
5214
5252
  store: false,
5215
5253
  stream: true,
5254
+ ...providerInfo.serviceTier ? { service_tier: providerInfo.serviceTier } : {},
5216
5255
  instructions: chatGptInput.instructions ?? "You are a helpful assistant.",
5217
5256
  input: chatGptInput.input,
5218
5257
  include: ["reasoning.encrypted_content"],
@@ -5247,7 +5286,7 @@ async function runTextCall(params) {
5247
5286
  queue.push({ type: "blocked" });
5248
5287
  }
5249
5288
  if (result.model) {
5250
- modelVersion = `chatgpt-${result.model}`;
5289
+ modelVersion = providerInfo.serviceTier ? request.model : `chatgpt-${result.model}`;
5251
5290
  queue.push({ type: "model", modelVersion });
5252
5291
  }
5253
5292
  latestUsage = extractChatGptUsageTokens(result.usage);
@@ -6209,6 +6248,7 @@ async function runToolLoop(request) {
6209
6248
  model: providerInfo.model,
6210
6249
  store: false,
6211
6250
  stream: true,
6251
+ ...providerInfo.serviceTier ? { service_tier: providerInfo.serviceTier } : {},
6212
6252
  instructions: toolLoopInput.instructions ?? "You are a helpful assistant.",
6213
6253
  input,
6214
6254
  prompt_cache_key: promptCacheKey,
@@ -6249,7 +6289,7 @@ async function runToolLoop(request) {
6249
6289
  }
6250
6290
  });
6251
6291
  const modelCompletedAtMs = Date.now();
6252
- modelVersion = response.model ? `chatgpt-${response.model}` : request.model;
6292
+ modelVersion = response.model && !providerInfo.serviceTier ? `chatgpt-${response.model}` : request.model;
6253
6293
  usageTokens = extractChatGptUsageTokens(response.usage);
6254
6294
  const stepCostUsd = estimateCallCostUsd({
6255
6295
  modelId: modelVersion,