@oh-my-pi/pi-ai 14.6.4 → 14.6.6

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [14.6.6] - 2026-05-04
6
+
7
+ ### Added
8
+
9
+ - Added always-on OpenRouter response caching (1h TTL) by sending `X-OpenRouter-Cache: true` and `X-OpenRouter-Cache-TTL: 3600` on every OpenRouter request — identical requests replay from OpenRouter's edge cache for free. https://openrouter.ai/docs/features/response-caching
10
+
5
11
  ## [14.6.4] - 2026-05-03
6
12
 
7
13
  ### Fixed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-ai",
4
- "version": "14.6.4",
4
+ "version": "14.6.6",
5
5
  "description": "Unified LLM API with automatic model discovery and provider configuration",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -46,8 +46,8 @@
46
46
  "@aws-sdk/credential-provider-node": "^3.972.36",
47
47
  "@bufbuild/protobuf": "^2.12.0",
48
48
  "@google/genai": "^1.50.1",
49
- "@oh-my-pi/pi-natives": "14.6.4",
50
- "@oh-my-pi/pi-utils": "14.6.4",
49
+ "@oh-my-pi/pi-natives": "14.6.6",
50
+ "@oh-my-pi/pi-utils": "14.6.6",
51
51
  "@sinclair/typebox": "^0.34.49",
52
52
  "@smithy/node-http-handler": "^4.6.1",
53
53
  "ajv": "^8.20.0",
@@ -764,9 +764,6 @@ export function openrouterModelManagerOptions(
764
764
  provider: "openrouter",
765
765
  baseUrl,
766
766
  apiKey,
767
- headers: {
768
- "X-Title": "Oh-My-Pi",
769
- },
770
767
  filterModel: (entry: OpenAICompatibleModelRecord) => {
771
768
  const params = entry.supported_parameters;
772
769
  return Array.isArray(params) && params.includes("tools");
@@ -9,6 +9,7 @@ import type {
9
9
  ChatCompletionMessageParam,
10
10
  ChatCompletionToolMessageParam,
11
11
  } from "openai/resources/chat/completions";
12
+ import packageJson from "../../package.json" with { type: "json" };
12
13
  import type { Effort } from "../model-thinking";
13
14
  import { calculateCost } from "../models";
14
15
  import { getEnvApiKey } from "../stream";
@@ -781,10 +782,26 @@ async function createClient(
781
782
  }
782
783
  const rawApiKey = apiKey;
783
784
 
784
- let headers = { ...(model.headers ?? {}), ...(extraHeaders ?? {}) };
785
+ let headers = { ...model.headers };
785
786
  if (model.provider === "openrouter") {
786
- headers["X-Title"] = "Oh-My-Pi";
787
+ // App attribution — opts the agent into OpenRouter's public rankings and per-app
788
+ // analytics. `HTTP-Referer` is the unique app identifier; without it nothing is
789
+ // tracked. `X-OpenRouter-Title` is the display name (`X-Title` is the legacy
790
+ // alias kept for back-compat). `X-OpenRouter-Categories` slots us into the
791
+ // `cli-agent` marketplace category. `User-Agent` overrides the default OpenAI
792
+ // SDK UA so traffic is identifiable in upstream provider logs.
793
+ // https://openrouter.ai/docs/app-attribution
794
+ headers["User-Agent"] = `Oh-My-Pi/${packageJson.version}`;
795
+ headers["HTTP-Referer"] = "https://github.com/can1357/oh-my-pi";
796
+ headers["X-OpenRouter-Title"] = "Oh-My-Pi";
797
+ headers["X-OpenRouter-Categories"] = "cli-agent";
798
+ // Always-on response caching: identical requests return cached responses for free.
799
+ // TTL 1h; first call hits the provider, every identical call within the window
800
+ // replays from OpenRouter's edge cache. https://openrouter.ai/docs/features/response-caching
801
+ headers["X-OpenRouter-Cache"] = "true";
802
+ headers["X-OpenRouter-Cache-TTL"] = "3600";
787
803
  }
804
+ Object.assign(headers, extraHeaders);
788
805
  if (model.provider === "kimi-code") {
789
806
  headers = { ...getKimiCommonHeaders(), ...headers };
790
807
  }