@providerprotocol/ai 0.0.29 → 0.0.32

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.
Files changed (42) hide show
  1. package/dist/anthropic/index.d.ts +12 -1
  2. package/dist/anthropic/index.js +15 -10
  3. package/dist/anthropic/index.js.map +1 -1
  4. package/dist/{chunk-Z6DKC37J.js → chunk-3C7O2RNO.js} +2 -2
  5. package/dist/{chunk-55X3W2MN.js → chunk-3D6XGGVG.js} +9 -2
  6. package/dist/{chunk-55X3W2MN.js.map → chunk-3D6XGGVG.js.map} +1 -1
  7. package/dist/{chunk-QNJO7DSD.js → chunk-4J6OFUKX.js} +10 -1
  8. package/dist/chunk-4J6OFUKX.js.map +1 -0
  9. package/dist/{chunk-73IIE3QT.js → chunk-6S222DHN.js} +11 -1
  10. package/dist/chunk-6S222DHN.js.map +1 -0
  11. package/dist/{chunk-SBCATNHA.js → chunk-KUPF5KHT.js} +2 -2
  12. package/dist/{embedding-DtyOFIsS.d.ts → embedding-D2BYIehX.d.ts} +22 -2
  13. package/dist/google/index.d.ts +5 -1
  14. package/dist/google/index.js +22 -13
  15. package/dist/google/index.js.map +1 -1
  16. package/dist/http/index.d.ts +8 -3
  17. package/dist/http/index.js +9 -5
  18. package/dist/index.d.ts +118 -6
  19. package/dist/index.js +641 -86
  20. package/dist/index.js.map +1 -1
  21. package/dist/{llm-DgDEy9il.d.ts → llm-BQJZj3cD.d.ts} +277 -10
  22. package/dist/ollama/index.d.ts +1 -1
  23. package/dist/ollama/index.js +32 -21
  24. package/dist/ollama/index.js.map +1 -1
  25. package/dist/openai/index.d.ts +1 -1
  26. package/dist/openai/index.js +21 -15
  27. package/dist/openai/index.js.map +1 -1
  28. package/dist/openrouter/index.d.ts +2 -2
  29. package/dist/openrouter/index.js +19 -8
  30. package/dist/openrouter/index.js.map +1 -1
  31. package/dist/proxy/index.d.ts +2 -2
  32. package/dist/proxy/index.js +9 -6
  33. package/dist/proxy/index.js.map +1 -1
  34. package/dist/{retry-DXLQnTuU.d.ts → retry-8Ch-WWgX.d.ts} +16 -2
  35. package/dist/xai/index.d.ts +16 -36
  36. package/dist/xai/index.js +29 -19
  37. package/dist/xai/index.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-73IIE3QT.js.map +0 -1
  40. package/dist/chunk-QNJO7DSD.js.map +0 -1
  41. /package/dist/{chunk-Z6DKC37J.js.map → chunk-3C7O2RNO.js.map} +0 -0
  42. /package/dist/{chunk-SBCATNHA.js.map → chunk-KUPF5KHT.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { P as Provider } from '../llm-DgDEy9il.js';
1
+ import { P as Provider } from '../llm-BQJZj3cD.js';
2
2
 
3
3
  /**
4
4
  * OpenRouter-specific types for the Unified Provider Protocol.
@@ -201,7 +201,7 @@ interface OpenRouterResponsesParams {
201
201
  * Reasoning configuration
202
202
  */
203
203
  reasoning?: {
204
- effort?: 'low' | 'medium' | 'high';
204
+ effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'minimal' | 'none';
205
205
  };
206
206
  /**
207
207
  * Output modalities for multimodal generation.
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  parseJsonResponse
3
- } from "../chunk-Z6DKC37J.js";
3
+ } from "../chunk-3C7O2RNO.js";
4
4
  import {
5
- StreamEventType
6
- } from "../chunk-73IIE3QT.js";
5
+ StreamEventType,
6
+ objectDelta
7
+ } from "../chunk-6S222DHN.js";
7
8
  import {
8
9
  AssistantMessage,
9
10
  createProvider,
@@ -17,7 +18,7 @@ import {
17
18
  } from "../chunk-TOJCZMVU.js";
18
19
  import {
19
20
  resolveApiKey
20
- } from "../chunk-55X3W2MN.js";
21
+ } from "../chunk-3D6XGGVG.js";
21
22
  import {
22
23
  ErrorCode,
23
24
  ModalityType,
@@ -26,7 +27,7 @@ import {
26
27
  doStreamFetch,
27
28
  normalizeHttpError,
28
29
  toError
29
- } from "../chunk-QNJO7DSD.js";
30
+ } from "../chunk-4J6OFUKX.js";
30
31
 
31
32
  // src/providers/openrouter/transform.completions.ts
32
33
  function transformRequest(request, modelId) {
@@ -758,7 +759,11 @@ function createCompletionsLLMHandler() {
758
759
  }
759
760
  const uppEvents = transformStreamEvent(chunk, state);
760
761
  for (const event of uppEvents) {
761
- yield event;
762
+ if (request.structure && event.type === StreamEventType.TextDelta) {
763
+ yield objectDelta(event.delta.text ?? "", event.index);
764
+ } else {
765
+ yield event;
766
+ }
762
767
  }
763
768
  }
764
769
  }
@@ -1608,6 +1613,7 @@ function createResponsesLLMHandler() {
1608
1613
  const baseUrl = request.config.baseUrl ?? OPENROUTER_RESPONSES_API_URL;
1609
1614
  const body = transformRequest2(request, modelId);
1610
1615
  body.stream = true;
1616
+ body.stream_options = { include_usage: true };
1611
1617
  const headers = {
1612
1618
  "Content-Type": "application/json",
1613
1619
  Authorization: `Bearer ${apiKey}`,
@@ -1666,7 +1672,11 @@ function createResponsesLLMHandler() {
1666
1672
  }
1667
1673
  const uppEvents = transformStreamEvent2(event, state);
1668
1674
  for (const uppEvent of uppEvents) {
1669
- yield uppEvent;
1675
+ if (request.structure && uppEvent.type === StreamEventType.TextDelta) {
1676
+ yield objectDelta(uppEvent.delta.text ?? "", uppEvent.index);
1677
+ } else {
1678
+ yield uppEvent;
1679
+ }
1670
1680
  }
1671
1681
  }
1672
1682
  }
@@ -1790,7 +1800,8 @@ function createEmbeddingHandler() {
1790
1800
  index: d.index
1791
1801
  })),
1792
1802
  usage: { totalTokens: data.usage.total_tokens },
1793
- metadata: data.usage.cost !== void 0 ? { cost: data.usage.cost } : void 0
1803
+ // Response metadata namespaced under provider (Spec 15.4)
1804
+ metadata: data.usage.cost !== void 0 ? { openrouter: { cost: data.usage.cost } } : void 0
1794
1805
  };
1795
1806
  }
1796
1807
  };