llm.rb 11.3.1 → 12.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +242 -1
  3. data/LICENSE +92 -17
  4. data/README.md +204 -623
  5. data/data/anthropic.json +433 -249
  6. data/data/bedrock.json +2097 -1055
  7. data/data/deepinfra.json +993 -0
  8. data/data/deepseek.json +53 -28
  9. data/data/google.json +389 -771
  10. data/data/openai.json +1053 -771
  11. data/data/xai.json +133 -292
  12. data/data/zai.json +249 -141
  13. data/lib/llm/active_record/acts_as_agent.rb +3 -41
  14. data/lib/llm/active_record/acts_as_llm.rb +18 -0
  15. data/lib/llm/active_record.rb +3 -3
  16. data/lib/llm/context.rb +9 -5
  17. data/lib/llm/contract/completion.rb +2 -2
  18. data/lib/llm/provider.rb +2 -2
  19. data/lib/llm/providers/deepinfra/audio.rb +66 -0
  20. data/lib/llm/providers/deepinfra/images.rb +90 -0
  21. data/lib/llm/providers/deepinfra/response_adapter.rb +36 -0
  22. data/lib/llm/providers/deepinfra.rb +100 -0
  23. data/lib/llm/providers/deepseek/images.rb +109 -0
  24. data/lib/llm/providers/deepseek/request_adapter.rb +32 -0
  25. data/lib/llm/providers/deepseek/response_adapter/image.rb +9 -0
  26. data/lib/llm/providers/deepseek/response_adapter.rb +29 -0
  27. data/lib/llm/providers/deepseek.rb +4 -2
  28. data/lib/llm/providers/google/request_adapter.rb +22 -5
  29. data/lib/llm/providers/google.rb +4 -4
  30. data/lib/llm/providers/openai/audio.rb +6 -2
  31. data/lib/llm/providers/openai/images.rb +9 -50
  32. data/lib/llm/providers/openai/request_adapter/respond.rb +38 -4
  33. data/lib/llm/providers/openai/response_adapter/audio.rb +5 -1
  34. data/lib/llm/providers/openai/response_adapter/completion.rb +1 -1
  35. data/lib/llm/providers/openai/response_adapter/image.rb +0 -4
  36. data/lib/llm/providers/openai/responses.rb +1 -0
  37. data/lib/llm/providers/openai/stream_parser.rb +5 -6
  38. data/lib/llm/providers/openai.rb +2 -2
  39. data/lib/llm/providers/xai/images.rb +49 -26
  40. data/lib/llm/providers/xai.rb +2 -2
  41. data/lib/llm/response.rb +10 -0
  42. data/lib/llm/schema/leaf.rb +7 -1
  43. data/lib/llm/schema/renderer.rb +121 -0
  44. data/lib/llm/schema.rb +30 -0
  45. data/lib/llm/sequel/agent.rb +2 -43
  46. data/lib/llm/sequel/plugin.rb +25 -7
  47. data/lib/llm/tracer/telemetry.rb +4 -6
  48. data/lib/llm/tracer.rb +9 -21
  49. data/lib/llm/transport/execution.rb +16 -1
  50. data/lib/llm/transport/net_http_adapter.rb +1 -1
  51. data/lib/llm/uridata.rb +16 -0
  52. data/lib/llm/version.rb +1 -1
  53. data/lib/llm.rb +9 -0
  54. data/llm.gemspec +5 -18
  55. data/resources/deepdive.md +798 -264
  56. metadata +15 -18
  57. data/lib/llm/tracer/langsmith.rb +0 -144
data/data/xai.json CHANGED
@@ -7,20 +7,33 @@
7
7
  "name": "xAI",
8
8
  "doc": "https://docs.x.ai/docs/models",
9
9
  "models": {
10
- "grok-4.20-0309-non-reasoning": {
11
- "id": "grok-4.20-0309-non-reasoning",
12
- "name": "Grok 4.20 (Non-Reasoning)",
10
+ "grok-4.20-multi-agent-0309": {
11
+ "id": "grok-4.20-multi-agent-0309",
12
+ "name": "Grok 4.20 Multi-Agent",
13
13
  "family": "grok",
14
14
  "attachment": true,
15
- "reasoning": false,
16
- "tool_call": true,
15
+ "reasoning": true,
16
+ "reasoning_options": [
17
+ {
18
+ "type": "effort",
19
+ "values": [
20
+ "low",
21
+ "medium",
22
+ "high",
23
+ "xhigh"
24
+ ]
25
+ }
26
+ ],
27
+ "tool_call": false,
28
+ "structured_output": true,
17
29
  "temperature": true,
18
30
  "release_date": "2026-03-09",
19
31
  "last_updated": "2026-03-09",
20
32
  "modalities": {
21
33
  "input": [
22
34
  "text",
23
- "image"
35
+ "image",
36
+ "pdf"
24
37
  ],
25
38
  "output": [
26
39
  "text"
@@ -28,17 +41,17 @@
28
41
  },
29
42
  "open_weights": false,
30
43
  "limit": {
31
- "context": 2000000,
44
+ "context": 1000000,
32
45
  "output": 30000
33
46
  },
34
47
  "cost": {
35
- "input": 2,
36
- "output": 6,
48
+ "input": 1.25,
49
+ "output": 2.5,
37
50
  "cache_read": 0.2,
38
51
  "tiers": [
39
52
  {
40
- "input": 4,
41
- "output": 12,
53
+ "input": 2.5,
54
+ "output": 5,
42
55
  "cache_read": 0.4,
43
56
  "tier": {
44
57
  "type": "context",
@@ -47,26 +60,28 @@
47
60
  }
48
61
  ],
49
62
  "context_over_200k": {
50
- "input": 4,
51
- "output": 12,
63
+ "input": 2.5,
64
+ "output": 5,
52
65
  "cache_read": 0.4
53
66
  }
54
67
  }
55
68
  },
56
- "grok-4.20-0309-reasoning": {
57
- "id": "grok-4.20-0309-reasoning",
58
- "name": "Grok 4.20 (Reasoning)",
69
+ "grok-4.20-0309-non-reasoning": {
70
+ "id": "grok-4.20-0309-non-reasoning",
71
+ "name": "Grok 4.20 (Non-Reasoning)",
59
72
  "family": "grok",
60
73
  "attachment": true,
61
- "reasoning": true,
74
+ "reasoning": false,
62
75
  "tool_call": true,
76
+ "structured_output": true,
63
77
  "temperature": true,
64
78
  "release_date": "2026-03-09",
65
79
  "last_updated": "2026-03-09",
66
80
  "modalities": {
67
81
  "input": [
68
82
  "text",
69
- "image"
83
+ "image",
84
+ "pdf"
70
85
  ],
71
86
  "output": [
72
87
  "text"
@@ -74,17 +89,17 @@
74
89
  },
75
90
  "open_weights": false,
76
91
  "limit": {
77
- "context": 2000000,
92
+ "context": 1000000,
78
93
  "output": 30000
79
94
  },
80
95
  "cost": {
81
- "input": 2,
82
- "output": 6,
96
+ "input": 1.25,
97
+ "output": 2.5,
83
98
  "cache_read": 0.2,
84
99
  "tiers": [
85
100
  {
86
- "input": 4,
87
- "output": 12,
101
+ "input": 2.5,
102
+ "output": 5,
88
103
  "cache_read": 0.4,
89
104
  "tier": {
90
105
  "type": "context",
@@ -93,58 +108,39 @@
93
108
  }
94
109
  ],
95
110
  "context_over_200k": {
96
- "input": 4,
97
- "output": 12,
111
+ "input": 2.5,
112
+ "output": 5,
98
113
  "cache_read": 0.4
99
114
  }
100
115
  }
101
116
  },
102
- "grok-vision-beta": {
103
- "id": "grok-vision-beta",
104
- "name": "Grok Vision Beta",
105
- "family": "grok-vision",
106
- "attachment": true,
107
- "reasoning": false,
108
- "tool_call": true,
109
- "temperature": true,
110
- "knowledge": "2024-08",
111
- "release_date": "2024-11-01",
112
- "last_updated": "2024-11-01",
113
- "modalities": {
114
- "input": [
115
- "text",
116
- "image"
117
- ],
118
- "output": [
119
- "text"
120
- ]
121
- },
122
- "open_weights": false,
123
- "limit": {
124
- "context": 8192,
125
- "output": 4096
126
- },
127
- "cost": {
128
- "input": 5,
129
- "output": 15,
130
- "cache_read": 5
131
- }
132
- },
133
- "grok-2-vision-1212": {
134
- "id": "grok-2-vision-1212",
135
- "name": "Grok 2 Vision (1212)",
117
+ "grok-4.3": {
118
+ "id": "grok-4.3",
119
+ "name": "Grok 4.3",
136
120
  "family": "grok",
137
121
  "attachment": true,
138
- "reasoning": false,
122
+ "reasoning": true,
123
+ "reasoning_options": [
124
+ {
125
+ "type": "effort",
126
+ "values": [
127
+ "none",
128
+ "low",
129
+ "medium",
130
+ "high"
131
+ ]
132
+ }
133
+ ],
139
134
  "tool_call": true,
135
+ "structured_output": true,
140
136
  "temperature": true,
141
- "knowledge": "2024-08",
142
- "release_date": "2024-08-20",
143
- "last_updated": "2024-12-12",
137
+ "release_date": "2026-04-17",
138
+ "last_updated": "2026-04-17",
144
139
  "modalities": {
145
140
  "input": [
146
141
  "text",
147
- "image"
142
+ "image",
143
+ "pdf"
148
144
  ],
149
145
  "output": [
150
146
  "text"
@@ -152,13 +148,29 @@
152
148
  },
153
149
  "open_weights": false,
154
150
  "limit": {
155
- "context": 8192,
156
- "output": 4096
151
+ "context": 1000000,
152
+ "output": 30000
157
153
  },
158
154
  "cost": {
159
- "input": 2,
160
- "output": 10,
161
- "cache_read": 2
155
+ "input": 1.25,
156
+ "output": 2.5,
157
+ "cache_read": 0.2,
158
+ "tiers": [
159
+ {
160
+ "input": 2.5,
161
+ "output": 5,
162
+ "cache_read": 0.4,
163
+ "tier": {
164
+ "type": "context",
165
+ "size": 200000
166
+ }
167
+ }
168
+ ],
169
+ "context_over_200k": {
170
+ "input": 2.5,
171
+ "output": 5,
172
+ "cache_read": 0.4
173
+ }
162
174
  }
163
175
  },
164
176
  "grok-imagine-image-quality": {
@@ -169,83 +181,25 @@
169
181
  "reasoning": false,
170
182
  "tool_call": false,
171
183
  "temperature": false,
172
- "release_date": "2026-04",
173
- "last_updated": "2026-05-16",
184
+ "release_date": "2026-04-03",
185
+ "last_updated": "2026-04-03",
174
186
  "modalities": {
175
187
  "input": [
176
188
  "text",
177
- "image"
189
+ "image",
190
+ "pdf"
178
191
  ],
179
192
  "output": [
180
- "image"
193
+ "image",
194
+ "pdf"
181
195
  ]
182
196
  },
183
197
  "open_weights": false,
184
198
  "limit": {
185
- "context": 1024,
199
+ "context": 8000,
186
200
  "output": 0
187
201
  }
188
202
  },
189
- "grok-2-1212": {
190
- "id": "grok-2-1212",
191
- "name": "Grok 2 (1212)",
192
- "family": "grok",
193
- "attachment": false,
194
- "reasoning": false,
195
- "tool_call": true,
196
- "temperature": true,
197
- "knowledge": "2024-08",
198
- "release_date": "2024-12-12",
199
- "last_updated": "2024-12-12",
200
- "modalities": {
201
- "input": [
202
- "text"
203
- ],
204
- "output": [
205
- "text"
206
- ]
207
- },
208
- "open_weights": false,
209
- "limit": {
210
- "context": 131072,
211
- "output": 8192
212
- },
213
- "cost": {
214
- "input": 2,
215
- "output": 10,
216
- "cache_read": 2
217
- }
218
- },
219
- "grok-beta": {
220
- "id": "grok-beta",
221
- "name": "Grok Beta",
222
- "family": "grok-beta",
223
- "attachment": false,
224
- "reasoning": false,
225
- "tool_call": true,
226
- "temperature": true,
227
- "knowledge": "2024-08",
228
- "release_date": "2024-11-01",
229
- "last_updated": "2024-11-01",
230
- "modalities": {
231
- "input": [
232
- "text"
233
- ],
234
- "output": [
235
- "text"
236
- ]
237
- },
238
- "open_weights": false,
239
- "limit": {
240
- "context": 131072,
241
- "output": 4096
242
- },
243
- "cost": {
244
- "input": 5,
245
- "output": 15,
246
- "cache_read": 5
247
- }
248
- },
249
203
  "grok-imagine-video": {
250
204
  "id": "grok-imagine-video",
251
205
  "name": "Grok Imagine Video",
@@ -254,13 +208,14 @@
254
208
  "reasoning": false,
255
209
  "tool_call": false,
256
210
  "temperature": false,
257
- "release_date": "2026-03",
258
- "last_updated": "2026-05-16",
211
+ "release_date": "2026-01-28",
212
+ "last_updated": "2026-01-28",
259
213
  "modalities": {
260
214
  "input": [
261
215
  "text",
262
216
  "image",
263
- "video"
217
+ "video",
218
+ "pdf"
264
219
  ],
265
220
  "output": [
266
221
  "video"
@@ -272,106 +227,23 @@
272
227
  "output": 0
273
228
  }
274
229
  },
275
- "grok-2": {
276
- "id": "grok-2",
277
- "name": "Grok 2",
278
- "family": "grok",
279
- "attachment": false,
280
- "reasoning": false,
281
- "tool_call": true,
282
- "temperature": true,
283
- "knowledge": "2024-08",
284
- "release_date": "2024-08-20",
285
- "last_updated": "2024-08-20",
286
- "modalities": {
287
- "input": [
288
- "text"
289
- ],
290
- "output": [
291
- "text"
292
- ]
293
- },
294
- "open_weights": false,
295
- "limit": {
296
- "context": 131072,
297
- "output": 8192
298
- },
299
- "cost": {
300
- "input": 2,
301
- "output": 10,
302
- "cache_read": 2
303
- }
304
- },
305
- "grok-2-vision-latest": {
306
- "id": "grok-2-vision-latest",
307
- "name": "Grok 2 Vision Latest",
308
- "family": "grok",
309
- "attachment": true,
310
- "reasoning": false,
311
- "tool_call": true,
312
- "temperature": true,
313
- "knowledge": "2024-08",
314
- "release_date": "2024-08-20",
315
- "last_updated": "2024-12-12",
316
- "modalities": {
317
- "input": [
318
- "text",
319
- "image"
320
- ],
321
- "output": [
322
- "text"
323
- ]
324
- },
325
- "open_weights": false,
326
- "limit": {
327
- "context": 8192,
328
- "output": 4096
329
- },
330
- "cost": {
331
- "input": 2,
332
- "output": 10,
333
- "cache_read": 2
334
- }
335
- },
336
- "grok-imagine-image": {
337
- "id": "grok-imagine-image",
338
- "name": "Grok Imagine Image",
339
- "family": "grok",
340
- "attachment": true,
341
- "reasoning": false,
342
- "tool_call": false,
343
- "temperature": false,
344
- "release_date": "2026-03",
345
- "last_updated": "2026-05-16",
346
- "modalities": {
347
- "input": [
348
- "text",
349
- "image"
350
- ],
351
- "output": [
352
- "image"
353
- ]
354
- },
355
- "open_weights": false,
356
- "limit": {
357
- "context": 1024,
358
- "output": 0
359
- }
360
- },
361
- "grok-4.3": {
362
- "id": "grok-4.3",
363
- "name": "Grok 4.3",
230
+ "grok-4.20-0309-reasoning": {
231
+ "id": "grok-4.20-0309-reasoning",
232
+ "name": "Grok 4.20 (Reasoning)",
364
233
  "family": "grok",
365
234
  "attachment": true,
366
235
  "reasoning": true,
236
+ "reasoning_options": [],
367
237
  "tool_call": true,
238
+ "structured_output": true,
368
239
  "temperature": true,
369
- "release_date": "2026-05-01",
370
- "last_updated": "2026-05-01",
240
+ "release_date": "2026-03-09",
241
+ "last_updated": "2026-03-09",
371
242
  "modalities": {
372
243
  "input": [
373
244
  "text",
374
- "image"
245
+ "image",
246
+ "pdf"
375
247
  ],
376
248
  "output": [
377
249
  "text"
@@ -404,81 +276,50 @@
404
276
  }
405
277
  }
406
278
  },
407
- "grok-2-vision": {
408
- "id": "grok-2-vision",
409
- "name": "Grok 2 Vision",
279
+ "grok-imagine-image": {
280
+ "id": "grok-imagine-image",
281
+ "name": "Grok Imagine Image",
410
282
  "family": "grok",
411
283
  "attachment": true,
412
284
  "reasoning": false,
413
- "tool_call": true,
414
- "temperature": true,
415
- "knowledge": "2024-08",
416
- "release_date": "2024-08-20",
417
- "last_updated": "2024-08-20",
285
+ "tool_call": false,
286
+ "temperature": false,
287
+ "release_date": "2026-01-28",
288
+ "last_updated": "2026-01-28",
418
289
  "modalities": {
419
290
  "input": [
420
291
  "text",
421
- "image"
422
- ],
423
- "output": [
424
- "text"
425
- ]
426
- },
427
- "open_weights": false,
428
- "limit": {
429
- "context": 8192,
430
- "output": 4096
431
- },
432
- "cost": {
433
- "input": 2,
434
- "output": 10,
435
- "cache_read": 2
436
- }
437
- },
438
- "grok-2-latest": {
439
- "id": "grok-2-latest",
440
- "name": "Grok 2 Latest",
441
- "family": "grok",
442
- "attachment": false,
443
- "reasoning": false,
444
- "tool_call": true,
445
- "temperature": true,
446
- "knowledge": "2024-08",
447
- "release_date": "2024-08-20",
448
- "last_updated": "2024-12-12",
449
- "modalities": {
450
- "input": [
451
- "text"
292
+ "image",
293
+ "pdf"
452
294
  ],
453
295
  "output": [
454
- "text"
296
+ "image",
297
+ "pdf"
455
298
  ]
456
299
  },
457
300
  "open_weights": false,
458
301
  "limit": {
459
- "context": 131072,
460
- "output": 8192
461
- },
462
- "cost": {
463
- "input": 2,
464
- "output": 10,
465
- "cache_read": 2
302
+ "context": 8000,
303
+ "output": 0
466
304
  }
467
305
  },
468
- "grok-4.20-multi-agent-0309": {
469
- "id": "grok-4.20-multi-agent-0309",
470
- "name": "Grok 4.20 Multi-Agent",
471
- "family": "grok",
306
+ "grok-build-0.1": {
307
+ "id": "grok-build-0.1",
308
+ "name": "Grok Build 0.1",
309
+ "family": "grok-build",
472
310
  "attachment": true,
473
311
  "reasoning": true,
474
- "tool_call": false,
312
+ "reasoning_options": [],
313
+ "tool_call": true,
314
+ "structured_output": true,
475
315
  "temperature": true,
476
- "release_date": "2026-03-09",
477
- "last_updated": "2026-03-09",
316
+ "release_date": "2026-04-16",
317
+ "last_updated": "2026-04-16",
478
318
  "modalities": {
479
319
  "input": [
480
320
  "text",
481
- "image"
321
+ "image",
322
+ "pdf"
482
323
  ],
483
324
  "output": [
484
325
  "text"
@@ -486,17 +327,17 @@
486
327
  },
487
328
  "open_weights": false,
488
329
  "limit": {
489
- "context": 2000000,
490
- "output": 30000
330
+ "context": 256000,
331
+ "output": 256000
491
332
  },
492
333
  "cost": {
493
- "input": 2,
494
- "output": 6,
334
+ "input": 1,
335
+ "output": 2,
495
336
  "cache_read": 0.2,
496
337
  "tiers": [
497
338
  {
498
- "input": 4,
499
- "output": 12,
339
+ "input": 2,
340
+ "output": 4,
500
341
  "cache_read": 0.4,
501
342
  "tier": {
502
343
  "type": "context",
@@ -505,8 +346,8 @@
505
346
  }
506
347
  ],
507
348
  "context_over_200k": {
508
- "input": 4,
509
- "output": 12,
349
+ "input": 2,
350
+ "output": 4,
510
351
  "cache_read": 0.4
511
352
  }
512
353
  }