@providerprotocol/ai 0.0.33 → 0.0.35

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 (133) hide show
  1. package/README.md +542 -3
  2. package/dist/anthropic/index.d.ts +2 -1
  3. package/dist/anthropic/index.js +151 -145
  4. package/dist/anthropic/index.js.map +1 -1
  5. package/dist/cerebras/index.d.ts +392 -0
  6. package/dist/cerebras/index.js +648 -0
  7. package/dist/cerebras/index.js.map +1 -0
  8. package/dist/chunk-3GWM5GR3.js +153 -0
  9. package/dist/chunk-3GWM5GR3.js.map +1 -0
  10. package/dist/chunk-4OGB7JZA.js +157 -0
  11. package/dist/chunk-4OGB7JZA.js.map +1 -0
  12. package/dist/chunk-7DXVRILR.js +49 -0
  13. package/dist/chunk-7DXVRILR.js.map +1 -0
  14. package/dist/{chunk-3C7O2RNO.js → chunk-A2IM7PGT.js} +6 -4
  15. package/dist/{chunk-3C7O2RNO.js.map → chunk-A2IM7PGT.js.map} +1 -1
  16. package/dist/{chunk-3D6XGGVG.js → chunk-ARVM24K2.js} +2 -2
  17. package/dist/{chunk-4J6OFUKX.js → chunk-AY55T37A.js} +70 -162
  18. package/dist/chunk-AY55T37A.js.map +1 -0
  19. package/dist/{chunk-ILR2D5PN.js → chunk-BRP5XJ6Q.js} +2 -86
  20. package/dist/chunk-BRP5XJ6Q.js.map +1 -0
  21. package/dist/chunk-C4JP64VW.js +298 -0
  22. package/dist/chunk-C4JP64VW.js.map +1 -0
  23. package/dist/chunk-COS4ON4G.js +111 -0
  24. package/dist/chunk-COS4ON4G.js.map +1 -0
  25. package/dist/chunk-ETBFOLQN.js +34 -0
  26. package/dist/chunk-ETBFOLQN.js.map +1 -0
  27. package/dist/chunk-HB4ZIH3T.js +31 -0
  28. package/dist/chunk-HB4ZIH3T.js.map +1 -0
  29. package/dist/chunk-I53CI6ZZ.js +142 -0
  30. package/dist/chunk-I53CI6ZZ.js.map +1 -0
  31. package/dist/chunk-IDZOVWP3.js +29 -0
  32. package/dist/chunk-IDZOVWP3.js.map +1 -0
  33. package/dist/chunk-JA3UZALR.js +88 -0
  34. package/dist/chunk-JA3UZALR.js.map +1 -0
  35. package/dist/{chunk-WAKD3OO5.js → chunk-N5DX5JW3.js} +31 -31
  36. package/dist/chunk-N5DX5JW3.js.map +1 -0
  37. package/dist/chunk-OIEWDFQU.js +97 -0
  38. package/dist/chunk-OIEWDFQU.js.map +1 -0
  39. package/dist/{chunk-TOJCZMVU.js → chunk-PMK5LZ5Z.js} +40 -40
  40. package/dist/chunk-PMK5LZ5Z.js.map +1 -0
  41. package/dist/chunk-UFFJDYCE.js +94 -0
  42. package/dist/chunk-UFFJDYCE.js.map +1 -0
  43. package/dist/chunk-VGKZIGVI.js +222 -0
  44. package/dist/chunk-VGKZIGVI.js.map +1 -0
  45. package/dist/chunk-VOEWHQUB.js +31 -0
  46. package/dist/chunk-VOEWHQUB.js.map +1 -0
  47. package/dist/{chunk-KUPF5KHT.js → chunk-Y5H7C5J4.js} +2 -2
  48. package/dist/chunk-ZI67WIQS.js +30 -0
  49. package/dist/chunk-ZI67WIQS.js.map +1 -0
  50. package/dist/{embedding-D2BYIehX.d.ts → embedding-CW6SaOOz.d.ts} +1 -1
  51. package/dist/google/index.d.ts +2 -1
  52. package/dist/google/index.js +202 -199
  53. package/dist/google/index.js.map +1 -1
  54. package/dist/groq/index.d.ts +410 -0
  55. package/dist/groq/index.js +649 -0
  56. package/dist/groq/index.js.map +1 -0
  57. package/dist/http/index.d.ts +3 -2
  58. package/dist/http/index.js +5 -4
  59. package/dist/image-stream-C0ciACM2.d.ts +11 -0
  60. package/dist/index.d.ts +8 -118
  61. package/dist/index.js +518 -767
  62. package/dist/index.js.map +1 -1
  63. package/dist/{llm-BQJZj3cD.d.ts → llm-DwbUK7un.d.ts} +12 -1632
  64. package/dist/middleware/logging/index.d.ts +76 -0
  65. package/dist/middleware/logging/index.js +74 -0
  66. package/dist/middleware/logging/index.js.map +1 -0
  67. package/dist/middleware/parsed-object/index.d.ts +45 -0
  68. package/dist/middleware/parsed-object/index.js +73 -0
  69. package/dist/middleware/parsed-object/index.js.map +1 -0
  70. package/dist/middleware/pubsub/index.d.ts +104 -0
  71. package/dist/middleware/pubsub/index.js +230 -0
  72. package/dist/middleware/pubsub/index.js.map +1 -0
  73. package/dist/middleware/pubsub/server/express/index.d.ts +52 -0
  74. package/dist/middleware/pubsub/server/express/index.js +11 -0
  75. package/dist/middleware/pubsub/server/express/index.js.map +1 -0
  76. package/dist/middleware/pubsub/server/fastify/index.d.ts +53 -0
  77. package/dist/middleware/pubsub/server/fastify/index.js +11 -0
  78. package/dist/middleware/pubsub/server/fastify/index.js.map +1 -0
  79. package/dist/middleware/pubsub/server/h3/index.d.ts +56 -0
  80. package/dist/middleware/pubsub/server/h3/index.js +11 -0
  81. package/dist/middleware/pubsub/server/h3/index.js.map +1 -0
  82. package/dist/middleware/pubsub/server/index.d.ts +78 -0
  83. package/dist/middleware/pubsub/server/index.js +34 -0
  84. package/dist/middleware/pubsub/server/index.js.map +1 -0
  85. package/dist/middleware/pubsub/server/webapi/index.d.ts +53 -0
  86. package/dist/middleware/pubsub/server/webapi/index.js +11 -0
  87. package/dist/middleware/pubsub/server/webapi/index.js.map +1 -0
  88. package/dist/ollama/index.d.ts +2 -1
  89. package/dist/ollama/index.js +48 -45
  90. package/dist/ollama/index.js.map +1 -1
  91. package/dist/openai/index.d.ts +2 -1
  92. package/dist/openai/index.js +319 -313
  93. package/dist/openai/index.js.map +1 -1
  94. package/dist/openrouter/index.d.ts +2 -1
  95. package/dist/openrouter/index.js +379 -383
  96. package/dist/openrouter/index.js.map +1 -1
  97. package/dist/proxy/index.d.ts +10 -914
  98. package/dist/proxy/index.js +275 -1007
  99. package/dist/proxy/index.js.map +1 -1
  100. package/dist/proxy/server/express/index.d.ts +161 -0
  101. package/dist/proxy/server/express/index.js +24 -0
  102. package/dist/proxy/server/express/index.js.map +1 -0
  103. package/dist/proxy/server/fastify/index.d.ts +162 -0
  104. package/dist/proxy/server/fastify/index.js +24 -0
  105. package/dist/proxy/server/fastify/index.js.map +1 -0
  106. package/dist/proxy/server/h3/index.d.ts +189 -0
  107. package/dist/proxy/server/h3/index.js +28 -0
  108. package/dist/proxy/server/h3/index.js.map +1 -0
  109. package/dist/proxy/server/index.d.ts +151 -0
  110. package/dist/proxy/server/index.js +48 -0
  111. package/dist/proxy/server/index.js.map +1 -0
  112. package/dist/proxy/server/webapi/index.d.ts +278 -0
  113. package/dist/proxy/server/webapi/index.js +32 -0
  114. package/dist/proxy/server/webapi/index.js.map +1 -0
  115. package/dist/responses/index.d.ts +650 -0
  116. package/dist/responses/index.js +930 -0
  117. package/dist/responses/index.js.map +1 -0
  118. package/dist/{retry-8Ch-WWgX.d.ts → retry-YayV42GV.d.ts} +1 -1
  119. package/dist/stream-CecfVCPO.d.ts +1632 -0
  120. package/dist/types-C8Gciizr.d.ts +168 -0
  121. package/dist/utils/index.d.ts +53 -0
  122. package/dist/utils/index.js +7 -0
  123. package/dist/utils/index.js.map +1 -0
  124. package/dist/xai/index.d.ts +2 -1
  125. package/dist/xai/index.js +310 -310
  126. package/dist/xai/index.js.map +1 -1
  127. package/package.json +94 -4
  128. package/dist/chunk-4J6OFUKX.js.map +0 -1
  129. package/dist/chunk-ILR2D5PN.js.map +0 -1
  130. package/dist/chunk-TOJCZMVU.js.map +0 -1
  131. package/dist/chunk-WAKD3OO5.js.map +0 -1
  132. /package/dist/{chunk-3D6XGGVG.js.map → chunk-ARVM24K2.js.map} +0 -0
  133. /package/dist/{chunk-KUPF5KHT.js.map → chunk-Y5H7C5J4.js.map} +0 -0
@@ -0,0 +1,410 @@
1
+ import { d as Provider } from '../llm-DwbUK7un.js';
2
+ import '../stream-CecfVCPO.js';
3
+
4
+ /**
5
+ * @fileoverview Groq Provider Type Definitions
6
+ *
7
+ * This module contains all TypeScript type definitions for the Groq provider,
8
+ * including types for the Chat Completions API (OpenAI-compatible).
9
+ *
10
+ * @module providers/groq/types
11
+ */
12
+ /**
13
+ * Parameters for the Groq Chat Completions API.
14
+ *
15
+ * These parameters are passed directly to the `/openai/v1/chat/completions` endpoint.
16
+ * Groq's API is largely OpenAI-compatible with some differences noted below.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const params: GroqLLMParams = {
21
+ * temperature: 0.7,
22
+ * max_tokens: 1000,
23
+ * top_p: 0.9
24
+ * };
25
+ * ```
26
+ */
27
+ interface GroqLLMParams {
28
+ /** Maximum number of tokens to generate */
29
+ max_tokens?: number;
30
+ /** Maximum completion tokens (alias for max_tokens) */
31
+ max_completion_tokens?: number;
32
+ /** Temperature for randomness (0.0 to 2.0). Note: Groq's API converts 0 to 1e-8 internally. */
33
+ temperature?: number;
34
+ /** Top-p (nucleus) sampling (0.0 - 1.0) */
35
+ top_p?: number;
36
+ /** Custom stop sequences */
37
+ stop?: string | string[];
38
+ /** Frequency penalty (-2.0 - 2.0) */
39
+ frequency_penalty?: number;
40
+ /** Presence penalty (-2.0 - 2.0) */
41
+ presence_penalty?: number;
42
+ /** Whether to enable parallel tool calls */
43
+ parallel_tool_calls?: boolean;
44
+ /** Seed for deterministic sampling */
45
+ seed?: number;
46
+ /** User identifier for rate limit tracking */
47
+ user?: string;
48
+ /** Response format for structured output */
49
+ response_format?: GroqResponseFormat;
50
+ /** Service tier selection */
51
+ service_tier?: 'on_demand' | 'flex';
52
+ /** Enable log probabilities output */
53
+ logprobs?: boolean;
54
+ /** Number of top log probabilities to return (0-20) */
55
+ top_logprobs?: number;
56
+ /** Reasoning effort for reasoning-capable models */
57
+ reasoning_effort?: 'none' | 'low' | 'medium' | 'high';
58
+ /** Reasoning format for reasoning-capable models */
59
+ reasoning_format?: 'parsed' | 'raw' | 'hidden';
60
+ /** Web search settings for search-enabled models */
61
+ search_settings?: GroqSearchSettings;
62
+ /** Documents for RAG (retrieval-augmented generation) */
63
+ documents?: GroqDocument[];
64
+ /** Citation options for document-based responses */
65
+ citation_options?: GroqCitationOptions;
66
+ }
67
+ /**
68
+ * Web search configuration for Groq's search-enabled models.
69
+ */
70
+ interface GroqSearchSettings {
71
+ /** Search mode: 'auto' lets the model decide, 'on' forces search, 'off' disables */
72
+ mode?: 'auto' | 'on' | 'off';
73
+ }
74
+ /**
75
+ * Document for RAG (retrieval-augmented generation).
76
+ */
77
+ interface GroqDocument {
78
+ /** Document content */
79
+ content: string;
80
+ /** Optional document ID for citation */
81
+ id?: string;
82
+ /** Optional document title */
83
+ title?: string;
84
+ }
85
+ /**
86
+ * Citation options for document-based responses.
87
+ */
88
+ interface GroqCitationOptions {
89
+ /** Enable inline citations in the response */
90
+ enabled?: boolean;
91
+ }
92
+ /**
93
+ * Response format options for structured output.
94
+ */
95
+ type GroqResponseFormat = {
96
+ type: 'text';
97
+ } | {
98
+ type: 'json_object';
99
+ } | {
100
+ type: 'json_schema';
101
+ json_schema: {
102
+ name: string;
103
+ description?: string;
104
+ schema: Record<string, unknown>;
105
+ strict?: boolean;
106
+ };
107
+ };
108
+ /**
109
+ * Request body for the Groq Chat Completions API.
110
+ */
111
+ interface GroqRequest {
112
+ model: string;
113
+ messages: GroqMessage[];
114
+ temperature?: number;
115
+ top_p?: number;
116
+ stream?: boolean;
117
+ stream_options?: {
118
+ include_usage?: boolean;
119
+ };
120
+ stop?: string | string[];
121
+ max_tokens?: number;
122
+ max_completion_tokens?: number;
123
+ presence_penalty?: number;
124
+ frequency_penalty?: number;
125
+ user?: string;
126
+ seed?: number;
127
+ tools?: GroqTool[];
128
+ tool_choice?: GroqToolChoice;
129
+ parallel_tool_calls?: boolean;
130
+ response_format?: GroqResponseFormat;
131
+ service_tier?: string;
132
+ logprobs?: boolean;
133
+ top_logprobs?: number;
134
+ reasoning_effort?: string;
135
+ reasoning_format?: string;
136
+ search_settings?: GroqSearchSettings;
137
+ documents?: GroqDocument[];
138
+ citation_options?: GroqCitationOptions;
139
+ }
140
+ /**
141
+ * Union type for all message types in the Groq API.
142
+ */
143
+ type GroqMessage = GroqSystemMessage | GroqUserMessage | GroqAssistantMessage | GroqToolMessage;
144
+ /** System message for setting context and instructions */
145
+ interface GroqSystemMessage {
146
+ role: 'system';
147
+ content: string;
148
+ }
149
+ /** User message with text or multimodal content */
150
+ interface GroqUserMessage {
151
+ role: 'user';
152
+ content: string | GroqUserContent[];
153
+ }
154
+ /** Assistant message containing the model's response */
155
+ interface GroqAssistantMessage {
156
+ role: 'assistant';
157
+ content?: string | null;
158
+ tool_calls?: GroqToolCall[];
159
+ }
160
+ /** Tool result message providing output from a function call */
161
+ interface GroqToolMessage {
162
+ role: 'tool';
163
+ content: string;
164
+ tool_call_id: string;
165
+ }
166
+ /**
167
+ * Union type for user content parts (text or image).
168
+ */
169
+ type GroqUserContent = GroqTextContent | GroqImageContent;
170
+ /** Text content part */
171
+ interface GroqTextContent {
172
+ type: 'text';
173
+ text: string;
174
+ }
175
+ /** Image content part with URL reference (for vision models only) */
176
+ interface GroqImageContent {
177
+ type: 'image_url';
178
+ image_url: {
179
+ url: string;
180
+ detail?: 'auto' | 'low' | 'high';
181
+ };
182
+ }
183
+ /**
184
+ * Tool call structure in assistant messages.
185
+ */
186
+ interface GroqToolCall {
187
+ id: string;
188
+ type: 'function';
189
+ function: {
190
+ name: string;
191
+ arguments: string;
192
+ };
193
+ }
194
+ /**
195
+ * Tool definition for the Groq API.
196
+ */
197
+ interface GroqTool {
198
+ type: 'function';
199
+ function: {
200
+ name: string;
201
+ description: string;
202
+ parameters: {
203
+ type: 'object';
204
+ properties: Record<string, unknown>;
205
+ required?: string[];
206
+ additionalProperties?: boolean;
207
+ };
208
+ strict?: boolean;
209
+ };
210
+ }
211
+ /**
212
+ * Tool choice options for controlling function calling behavior.
213
+ */
214
+ type GroqToolChoice = 'none' | 'auto' | 'required' | {
215
+ type: 'function';
216
+ function: {
217
+ name: string;
218
+ };
219
+ };
220
+ /**
221
+ * Response structure from the Groq Chat Completions API.
222
+ */
223
+ interface GroqResponse {
224
+ id: string;
225
+ object: 'chat.completion';
226
+ created: number;
227
+ model: string;
228
+ choices: GroqChoice[];
229
+ usage: GroqUsage;
230
+ system_fingerprint?: string;
231
+ x_groq?: {
232
+ id?: string;
233
+ };
234
+ }
235
+ /** A single choice from a completion response */
236
+ interface GroqChoice {
237
+ index: number;
238
+ message: GroqAssistantMessage;
239
+ finish_reason: 'stop' | 'length' | 'tool_calls' | 'content_filter' | null;
240
+ logprobs?: GroqLogprobs | null;
241
+ }
242
+ /** Log probability information for tokens */
243
+ interface GroqLogprobs {
244
+ content?: Array<{
245
+ token: string;
246
+ logprob: number;
247
+ bytes?: number[];
248
+ top_logprobs?: Array<{
249
+ token: string;
250
+ logprob: number;
251
+ bytes?: number[];
252
+ }>;
253
+ }>;
254
+ }
255
+ /** Token usage statistics from the API response */
256
+ interface GroqUsage {
257
+ prompt_tokens: number;
258
+ completion_tokens: number;
259
+ total_tokens: number;
260
+ queue_time?: number;
261
+ prompt_time?: number;
262
+ completion_time?: number;
263
+ prompt_tokens_details?: {
264
+ cached_tokens?: number;
265
+ };
266
+ }
267
+ /**
268
+ * Streaming chunk structure from the Groq API.
269
+ */
270
+ interface GroqStreamChunk {
271
+ id: string;
272
+ object: 'chat.completion.chunk';
273
+ created: number;
274
+ model: string;
275
+ choices: GroqStreamChoice[];
276
+ usage?: GroqUsage | null;
277
+ system_fingerprint?: string;
278
+ x_groq?: {
279
+ id?: string;
280
+ usage?: GroqUsage;
281
+ };
282
+ }
283
+ /** A streaming choice containing incremental content */
284
+ interface GroqStreamChoice {
285
+ index: number;
286
+ delta: GroqStreamDelta;
287
+ finish_reason: 'stop' | 'length' | 'tool_calls' | 'content_filter' | null;
288
+ logprobs?: GroqLogprobs | null;
289
+ }
290
+ /** Incremental content delta in a streaming chunk */
291
+ interface GroqStreamDelta {
292
+ role?: 'assistant';
293
+ content?: string | null;
294
+ tool_calls?: GroqStreamToolCall[];
295
+ }
296
+ /** Incremental tool call data in a streaming chunk */
297
+ interface GroqStreamToolCall {
298
+ index: number;
299
+ id?: string;
300
+ type?: 'function';
301
+ function?: {
302
+ name?: string;
303
+ arguments?: string;
304
+ };
305
+ }
306
+ /**
307
+ * Groq-specific HTTP headers for API requests.
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const headers: GroqHeaders = {
312
+ * 'X-Request-Id': 'my-request-id',
313
+ * };
314
+ * ```
315
+ */
316
+ interface GroqHeaders {
317
+ /** Client-generated request ID for tracing */
318
+ 'X-Request-Id'?: string;
319
+ [key: string]: string | undefined;
320
+ }
321
+
322
+ /**
323
+ * @fileoverview Groq Provider Factory
324
+ *
325
+ * This module provides the main Groq provider implementation for the
326
+ * OpenAI-compatible Chat Completions API.
327
+ *
328
+ * @module providers/groq
329
+ */
330
+ /**
331
+ * Configuration options for the Groq provider.
332
+ *
333
+ * Currently Groq only supports one API endpoint (Chat Completions),
334
+ * so no additional options are needed.
335
+ */
336
+ interface GroqProviderOptions {
337
+ }
338
+ /**
339
+ * The Groq provider instance.
340
+ *
341
+ * Use this provider to create model references for Groq models like
342
+ * Llama 3.3, Llama 3.1, Gemma 2, and other models available on Groq.
343
+ *
344
+ * @example Basic usage
345
+ * ```typescript
346
+ * import { groq } from './providers/groq';
347
+ * import { llm } from './core/llm';
348
+ *
349
+ * const model = llm({
350
+ * model: groq('llama-3.3-70b-versatile'),
351
+ * params: { max_tokens: 1000 }
352
+ * });
353
+ *
354
+ * const turn = await model.generate('Hello!');
355
+ * console.log(turn.response.text);
356
+ * ```
357
+ *
358
+ * @example With streaming
359
+ * ```typescript
360
+ * const stream = model.stream('Tell me a story');
361
+ *
362
+ * for await (const event of stream) {
363
+ * if (event.type === StreamEventType.TextDelta) {
364
+ * process.stdout.write(event.delta.text ?? '');
365
+ * }
366
+ * }
367
+ *
368
+ * const turn = await stream.turn;
369
+ * console.log('Tokens used:', turn.usage.totalTokens);
370
+ * ```
371
+ *
372
+ * @example With tools
373
+ * ```typescript
374
+ * const calculator = {
375
+ * name: 'calculate',
376
+ * description: 'Calculate a math expression',
377
+ * parameters: {
378
+ * type: 'object',
379
+ * properties: {
380
+ * expression: { type: 'string' }
381
+ * },
382
+ * required: ['expression']
383
+ * },
384
+ * run: async (params: { expression: string }) => {
385
+ * return eval(params.expression);
386
+ * }
387
+ * };
388
+ *
389
+ * const model = llm({
390
+ * model: groq('llama-3.3-70b-versatile'),
391
+ * tools: [calculator]
392
+ * });
393
+ *
394
+ * const turn = await model.generate('What is 15 + 27?');
395
+ * ```
396
+ *
397
+ * @example Available models
398
+ * Production models:
399
+ * - `llama-3.3-70b-versatile` - Versatile model with tool use support
400
+ * - `llama-3.1-8b-instant` - Fast, efficient model
401
+ * - `llama-guard-4-12b` - Content moderation model
402
+ * - `gemma2-9b-it` - Google's Gemma 2 model
403
+ *
404
+ * Preview models:
405
+ * - `meta-llama/llama-4-scout-17b-16e-instruct` - Vision + tool use
406
+ * - `qwen/qwen3-32b` - Qwen 3 model
407
+ */
408
+ declare const groq: Provider<GroqProviderOptions>;
409
+
410
+ export { type GroqCitationOptions, type GroqDocument, type GroqHeaders, type GroqLLMParams, type GroqMessage, type GroqProviderOptions, type GroqRequest, type GroqResponse, type GroqResponseFormat, type GroqSearchSettings, type GroqStreamChunk, type GroqTool, type GroqToolCall, type GroqToolChoice, type GroqUsage, groq };