@nemesis-oss/ollama-sdk 1.6.0 → 1.8.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 (56) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +31 -0
  3. package/dist/anthropic-B_UXplNF.d.ts +1647 -0
  4. package/dist/anthropic-CVDFy_a0.d.cts +1647 -0
  5. package/dist/generated-api.cjs +74 -6
  6. package/dist/generated-api.cjs.map +1 -1
  7. package/dist/generated-api.d.cts +230 -629
  8. package/dist/generated-api.d.ts +230 -629
  9. package/dist/generated-api.js +72 -7
  10. package/dist/generated-api.js.map +1 -1
  11. package/dist/generated-models-schemas.cjs +89 -1
  12. package/dist/generated-models-schemas.cjs.map +1 -1
  13. package/dist/generated-models-schemas.d.cts +121 -1
  14. package/dist/generated-models-schemas.d.ts +121 -1
  15. package/dist/generated-models-schemas.js +79 -2
  16. package/dist/generated-models-schemas.js.map +1 -1
  17. package/dist/generated-runtime.cjs +576 -57
  18. package/dist/generated-runtime.cjs.map +1 -1
  19. package/dist/generated-runtime.d.cts +21 -23
  20. package/dist/generated-runtime.d.ts +21 -23
  21. package/dist/generated-runtime.js +575 -58
  22. package/dist/generated-runtime.js.map +1 -1
  23. package/dist/index.cjs +1210 -81
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +395 -876
  26. package/dist/index.d.ts +395 -876
  27. package/dist/index.js +1207 -82
  28. package/dist/index.js.map +1 -1
  29. package/dist/mcp/tools.json +287 -73
  30. package/dist/mcp-generated.cjs +96 -7
  31. package/dist/mcp-generated.cjs.map +1 -1
  32. package/dist/mcp-generated.d.cts +3 -3
  33. package/dist/mcp-generated.d.ts +3 -3
  34. package/dist/mcp-generated.js +96 -7
  35. package/dist/mcp-generated.js.map +1 -1
  36. package/dist/mcp-http.cjs +43 -4
  37. package/dist/mcp-http.cjs.map +1 -1
  38. package/dist/mcp-http.d.cts +5 -1
  39. package/dist/mcp-http.d.ts +5 -1
  40. package/dist/mcp-http.js +43 -4
  41. package/dist/mcp-http.js.map +1 -1
  42. package/dist/mcp-stdio.cjs +43 -4
  43. package/dist/mcp-stdio.cjs.map +1 -1
  44. package/dist/mcp-stdio.d.cts +5 -1
  45. package/dist/mcp-stdio.d.ts +5 -1
  46. package/dist/mcp-stdio.js +43 -4
  47. package/dist/mcp-stdio.js.map +1 -1
  48. package/dist/{runtime-CVQkbYgF.d.ts → runtime-C6UYtBRB.d.ts} +222 -6
  49. package/dist/{runtime-IxRpUBjN.d.cts → runtime-DTmUeU6K.d.cts} +222 -6
  50. package/dist/skills.cjs.map +1 -1
  51. package/dist/skills.js.map +1 -1
  52. package/dist/types-CI-gM2u5.d.cts +139 -0
  53. package/dist/types-CI-gM2u5.d.ts +139 -0
  54. package/package.json +4 -2
  55. package/dist/types-MOsWXEE7.d.cts +0 -66
  56. package/dist/types-MOsWXEE7.d.ts +0 -66
@@ -0,0 +1,1647 @@
1
+ import { O as OllamaRuntime, H as HttpClient, A as AbortableAsyncIterable, ab as SseEvent, w as OllamaClientError } from './runtime-C6UYtBRB.js';
2
+
3
+ /**
4
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
5
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
6
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
7
+ */
8
+
9
+ interface ChatMessage {
10
+ /** Author of the message. */
11
+ readonly role: 'system' | 'user' | 'assistant' | 'tool';
12
+ /** Message text content */
13
+ readonly content: string;
14
+ /** Optional list of inline images for multimodal models */
15
+ readonly images?: readonly string[] | undefined;
16
+ /** Tool call requests produced by the model */
17
+ readonly tool_calls?: readonly ToolCall[] | undefined;
18
+ }
19
+
20
+ /**
21
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
22
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
23
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
24
+ */
25
+
26
+ interface ChatRequest {
27
+ /** Model name */
28
+ readonly model: string;
29
+ /** Chat history as an array of message objects (each with a role and content) */
30
+ readonly messages: readonly ChatMessage[];
31
+ /** Optional list of function tools the model may call during the chat */
32
+ readonly tools?: readonly ToolDefinition[] | undefined;
33
+ /** Format to return a response in. Can be `json` or a JSON schema */
34
+ readonly format?: 'json' | Record<string, unknown> | undefined;
35
+ readonly options?: ModelOptions | undefined;
36
+ readonly stream?: boolean | undefined;
37
+ readonly think?: ThinkValue | undefined;
38
+ /** Model keep-alive duration (for example `5m` or `0` to unload immediately) */
39
+ readonly keep_alive?: string | number | undefined;
40
+ /** Whether to return log probabilities of the output tokens */
41
+ readonly logprobs?: boolean | undefined;
42
+ /** Number of most likely tokens to return at each token position when logprobs are enabled */
43
+ readonly top_logprobs?: number | undefined;
44
+ }
45
+
46
+ /**
47
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
48
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
49
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
50
+ */
51
+
52
+ interface ChatResponse {
53
+ /** Model name used to generate this message */
54
+ readonly model?: string | undefined;
55
+ /** Timestamp of response creation (ISO 8601) */
56
+ readonly created_at?: string | undefined;
57
+ readonly message?: {
58
+ /** Always `assistant` for model responses */
59
+ readonly role?: 'assistant' | undefined;
60
+ /** Assistant message text */
61
+ readonly content?: string | undefined;
62
+ /** Optional deliberate thinking trace when `think` is enabled */
63
+ readonly thinking?: string | undefined;
64
+ /** Tool calls requested by the assistant */
65
+ readonly tool_calls?: readonly ToolCall[] | undefined;
66
+ /** Optional base64-encoded images in the response */
67
+ readonly images?: readonly string[] | undefined;
68
+ } | undefined;
69
+ /** Indicates whether the chat response has finished */
70
+ readonly done?: boolean | undefined;
71
+ /** Reason the response finished */
72
+ readonly done_reason?: string | undefined;
73
+ /** Total time spent generating in nanoseconds */
74
+ readonly total_duration?: number | undefined;
75
+ /** Time spent loading the model in nanoseconds */
76
+ readonly load_duration?: number | undefined;
77
+ /** Number of tokens in the prompt */
78
+ readonly prompt_eval_count?: number | undefined;
79
+ /** Number of prompt tokens read from the cache */
80
+ readonly prompt_eval_cached_count?: number | undefined;
81
+ /** Time spent evaluating uncached prompt tokens in nanoseconds */
82
+ readonly prompt_eval_duration?: number | undefined;
83
+ /** Number of tokens generated in the response */
84
+ readonly eval_count?: number | undefined;
85
+ /** Time spent generating tokens in nanoseconds */
86
+ readonly eval_duration?: number | undefined;
87
+ /** Log probability information for the generated tokens when logprobs are enabled */
88
+ readonly logprobs?: readonly Logprob[] | undefined;
89
+ }
90
+
91
+ /**
92
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
93
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
94
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
95
+ */
96
+ interface CopyRequest {
97
+ /** Existing model name to copy from */
98
+ readonly source: string;
99
+ /** New model name to create */
100
+ readonly destination: string;
101
+ }
102
+
103
+ /**
104
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
105
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
106
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
107
+ */
108
+
109
+ interface CreateRequest {
110
+ /** Name for the model to create */
111
+ readonly model: string;
112
+ /** Existing model to create from */
113
+ readonly from?: string | undefined;
114
+ /** Prompt template to use for the model */
115
+ readonly template?: string | undefined;
116
+ /** Name of the renderer for the model */
117
+ readonly renderer?: string | undefined;
118
+ /** Name of the parser for the model */
119
+ readonly parser?: string | undefined;
120
+ /** Source file names mapped to their SHA-256 digests. Split GGUF models must include each shard under its original split filename. */
121
+ readonly files?: {
122
+ [key: string]: string;
123
+ } | undefined;
124
+ /** Draft source file names mapped to their SHA-256 digests */
125
+ readonly draft_files?: {
126
+ [key: string]: string;
127
+ } | undefined;
128
+ /** License string or list of licenses for the model */
129
+ readonly license?: string | string[] | undefined;
130
+ /** System prompt to embed in the model */
131
+ readonly system?: string | undefined;
132
+ /** Key-value parameters for the model */
133
+ readonly parameters?: Record<string, unknown> | undefined;
134
+ /** Message history to use for the model */
135
+ readonly messages?: readonly ChatMessage[] | undefined;
136
+ /** Quantization level to apply during import (e.g. `nvfp4`) */
137
+ readonly quantize?: string | undefined;
138
+ /** Quantization level to apply to draft weights during import */
139
+ readonly draft_quantize?: string | undefined;
140
+ /** Minimum Ollama version required by the model */
141
+ readonly requires?: string | undefined;
142
+ /** Stream status updates */
143
+ readonly stream?: boolean | undefined;
144
+ }
145
+
146
+ /**
147
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
148
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
149
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
150
+ */
151
+ interface DeleteRequest {
152
+ /** Model name to delete */
153
+ readonly model: string;
154
+ }
155
+
156
+ /**
157
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
158
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
159
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
160
+ */
161
+
162
+ interface EmbedRequest {
163
+ /** Model name */
164
+ readonly model: string;
165
+ /** Text or array of texts to generate embeddings for */
166
+ readonly input: string | string[];
167
+ /** If true, truncate inputs that exceed the context window. If false, returns an error. */
168
+ readonly truncate?: boolean | undefined;
169
+ /** Number of dimensions to generate embeddings for */
170
+ readonly dimensions?: number | undefined;
171
+ /** Model keep-alive duration */
172
+ readonly keep_alive?: string | undefined;
173
+ readonly options?: ModelOptions | undefined;
174
+ }
175
+
176
+ /**
177
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
178
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
179
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
180
+ */
181
+ interface EmbedResponse {
182
+ /** Model that produced the embeddings */
183
+ readonly model?: string | undefined;
184
+ /** Array of vector embeddings */
185
+ readonly embeddings?: readonly number[][] | undefined;
186
+ /** Total time spent generating in nanoseconds */
187
+ readonly total_duration?: number | undefined;
188
+ /** Load time in nanoseconds */
189
+ readonly load_duration?: number | undefined;
190
+ /** Number of input tokens processed to generate embeddings */
191
+ readonly prompt_eval_count?: number | undefined;
192
+ }
193
+
194
+ /**
195
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
196
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
197
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
198
+ */
199
+
200
+ interface GenerateRequest {
201
+ /** Model name */
202
+ readonly model: string;
203
+ /** Text for the model to generate a response from */
204
+ readonly prompt?: string | undefined;
205
+ /** Used for fill-in-the-middle models, text that appears after the user prompt and before the model response */
206
+ readonly suffix?: string | undefined;
207
+ readonly images?: readonly string[] | undefined;
208
+ /** Structured output format for the model to generate a response from. Supports either the string `"json"` or a JSON schema object. */
209
+ readonly format?: string | Record<string, unknown> | undefined;
210
+ /** System prompt for the model to generate a response from */
211
+ readonly system?: string | undefined;
212
+ /** When true, returns a stream of partial responses */
213
+ readonly stream?: boolean | undefined;
214
+ readonly think?: ThinkValue | undefined;
215
+ /** When true, returns the raw response from the model without any prompt templating */
216
+ readonly raw?: boolean | undefined;
217
+ /** Model keep-alive duration (for example `5m` or `0` to unload immediately) */
218
+ readonly keep_alive?: string | number | undefined;
219
+ readonly options?: ModelOptions | undefined;
220
+ /** Whether to return log probabilities of the output tokens */
221
+ readonly logprobs?: boolean | undefined;
222
+ /** Number of most likely tokens to return at each token position when logprobs are enabled */
223
+ readonly top_logprobs?: number | undefined;
224
+ }
225
+
226
+ /**
227
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
228
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
229
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
230
+ */
231
+
232
+ interface GenerateResponse {
233
+ /** Model name */
234
+ readonly model?: string | undefined;
235
+ /** ISO 8601 timestamp of response creation */
236
+ readonly created_at?: string | undefined;
237
+ /** The model's generated text response */
238
+ readonly response?: string | undefined;
239
+ /** The model's generated thinking output */
240
+ readonly thinking?: string | undefined;
241
+ /** Indicates whether generation has finished */
242
+ readonly done?: boolean | undefined;
243
+ /** Reason the generation stopped */
244
+ readonly done_reason?: string | undefined;
245
+ /** Time spent generating the response in nanoseconds */
246
+ readonly total_duration?: number | undefined;
247
+ /** Time spent loading the model in nanoseconds */
248
+ readonly load_duration?: number | undefined;
249
+ /** Number of input tokens in the prompt */
250
+ readonly prompt_eval_count?: number | undefined;
251
+ /** Number of prompt tokens read from the cache */
252
+ readonly prompt_eval_cached_count?: number | undefined;
253
+ /** Time spent evaluating uncached prompt tokens in nanoseconds */
254
+ readonly prompt_eval_duration?: number | undefined;
255
+ /** Number of output tokens generated in the response */
256
+ readonly eval_count?: number | undefined;
257
+ /** Time spent generating tokens in nanoseconds */
258
+ readonly eval_duration?: number | undefined;
259
+ /** Log probability information for the generated tokens when logprobs are enabled */
260
+ readonly logprobs?: readonly Logprob[] | undefined;
261
+ }
262
+
263
+ /**
264
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
265
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
266
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
267
+ */
268
+
269
+ interface ListResponse {
270
+ readonly models?: readonly ModelSummary[] | undefined;
271
+ }
272
+
273
+ /**
274
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
275
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
276
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
277
+ */
278
+
279
+ /** Log probability information for a generated token */
280
+ interface Logprob {
281
+ /** The text representation of the token */
282
+ readonly token?: string | undefined;
283
+ /** The log probability of this token */
284
+ readonly logprob?: number | undefined;
285
+ /** The raw byte representation of the token */
286
+ readonly bytes?: readonly number[] | undefined;
287
+ /** Most likely tokens and their log probabilities at this position */
288
+ readonly top_logprobs?: readonly TokenLogprob[] | undefined;
289
+ }
290
+
291
+ /**
292
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
293
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
294
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
295
+ */
296
+ /** Runtime options that control text generation */
297
+ interface ModelOptions {
298
+ /** Random seed used for reproducible outputs */
299
+ readonly seed?: number | undefined;
300
+ /** Controls randomness in generation (higher = more random) */
301
+ readonly temperature?: number | undefined;
302
+ /** Limits next token selection to the K most likely */
303
+ readonly top_k?: number | undefined;
304
+ /** Cumulative probability threshold for nucleus sampling */
305
+ readonly top_p?: number | undefined;
306
+ /** Minimum probability threshold for token selection */
307
+ readonly min_p?: number | undefined;
308
+ /** Stop sequences that will halt generation */
309
+ readonly stop?: string | string[] | undefined;
310
+ /** Context length size (number of tokens) */
311
+ readonly num_ctx?: number | undefined;
312
+ /** Maximum number of tokens to generate */
313
+ readonly num_predict?: number | undefined;
314
+ [key: string]: unknown;
315
+ }
316
+
317
+ /**
318
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
319
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
320
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
321
+ */
322
+ /** Summary information for a locally available model */
323
+ interface ModelSummary {
324
+ /** Model name */
325
+ readonly name?: string | undefined;
326
+ /** Model name */
327
+ readonly model?: string | undefined;
328
+ /** Name of the upstream model, if the model is remote */
329
+ readonly remote_model?: string | undefined;
330
+ /** URL of the upstream Ollama host, if the model is remote */
331
+ readonly remote_host?: string | undefined;
332
+ /** Last modified timestamp in ISO 8601 format */
333
+ readonly modified_at?: string | undefined;
334
+ /** Total size of the model on disk in bytes */
335
+ readonly size?: number | undefined;
336
+ /** SHA256 digest identifier of the model contents */
337
+ readonly digest?: string | undefined;
338
+ /** Additional information about the model's format and family */
339
+ readonly details?: {
340
+ /** Model file format (for example `gguf`) */
341
+ readonly format?: string | undefined;
342
+ /** Primary model family (for example `llama`) */
343
+ readonly family?: string | undefined;
344
+ /** All families the model belongs to, when applicable */
345
+ readonly families?: readonly string[] | undefined;
346
+ /** Approximate parameter count label (for example `7B`, `13B`) */
347
+ readonly parameter_size?: string | undefined;
348
+ /** Quantization level used (for example `Q4_0`) */
349
+ readonly quantization_level?: string | undefined;
350
+ } | undefined;
351
+ }
352
+
353
+ /**
354
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
355
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
356
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
357
+ */
358
+ interface Ps {
359
+ /** Name of the running model */
360
+ readonly name?: string | undefined;
361
+ /** Name of the running model */
362
+ readonly model?: string | undefined;
363
+ /** Size of the model in bytes */
364
+ readonly size?: number | undefined;
365
+ /** SHA256 digest of the model */
366
+ readonly digest?: string | undefined;
367
+ /** Model details such as format and family */
368
+ readonly details?: Record<string, unknown> | undefined;
369
+ /** Time when the model will be unloaded */
370
+ readonly expires_at?: string | undefined;
371
+ /** VRAM usage in bytes */
372
+ readonly size_vram?: number | undefined;
373
+ /** Context length for the running model */
374
+ readonly context_length?: number | undefined;
375
+ }
376
+
377
+ /**
378
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
379
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
380
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
381
+ */
382
+
383
+ interface PsResponse {
384
+ /** Currently running models */
385
+ readonly models?: readonly Ps[] | undefined;
386
+ }
387
+
388
+ /**
389
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
390
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
391
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
392
+ */
393
+ interface PullRequest {
394
+ /** Name of the model to download */
395
+ readonly model: string;
396
+ /** Allow downloading over insecure connections */
397
+ readonly insecure?: boolean | undefined;
398
+ /** Stream progress updates */
399
+ readonly stream?: boolean | undefined;
400
+ }
401
+
402
+ /**
403
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
404
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
405
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
406
+ */
407
+ interface PushRequest {
408
+ /** Name of the model to publish */
409
+ readonly model: string;
410
+ /** Allow publishing over insecure connections */
411
+ readonly insecure?: boolean | undefined;
412
+ /** Stream progress updates */
413
+ readonly stream?: boolean | undefined;
414
+ }
415
+
416
+ /**
417
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
418
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
419
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
420
+ */
421
+ interface ShowRequest {
422
+ /** Model name to show */
423
+ readonly model: string;
424
+ /** If true, includes large verbose fields in the response. */
425
+ readonly verbose?: boolean | undefined;
426
+ }
427
+
428
+ /**
429
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
430
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
431
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
432
+ */
433
+
434
+ interface ShowResponse {
435
+ readonly thinking?: Thinking | undefined;
436
+ /** Model parameter settings serialized as text */
437
+ readonly parameters?: string | undefined;
438
+ /** The license of the model */
439
+ readonly license?: string | undefined;
440
+ /** Last modified timestamp in ISO 8601 format */
441
+ readonly modified_at?: string | undefined;
442
+ /** High-level model details */
443
+ readonly details?: Record<string, unknown> | undefined;
444
+ /** The template used by the model to render prompts */
445
+ readonly template?: string | undefined;
446
+ /** List of supported features */
447
+ readonly capabilities?: readonly string[] | undefined;
448
+ /** Additional model metadata */
449
+ readonly model_info?: Record<string, unknown> | undefined;
450
+ }
451
+
452
+ /**
453
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
454
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
455
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
456
+ */
457
+ interface StatusResponse {
458
+ /** Current status message */
459
+ readonly status?: string | undefined;
460
+ }
461
+
462
+ /**
463
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
464
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
465
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
466
+ */
467
+
468
+ interface SystemOneChoiceAnswer {
469
+ readonly type: 'choice';
470
+ /** Option key with the highest probability. Ties follow the model's option order. */
471
+ readonly choice: string;
472
+ readonly probabilities: SystemOneProbabilities;
473
+ readonly confidence: SystemOneConfidence;
474
+ }
475
+
476
+ /**
477
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
478
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
479
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
480
+ */
481
+
482
+ interface SystemOneChoiceQuestion {
483
+ readonly type: 'choice';
484
+ readonly instructions: SystemOneContent;
485
+ /** Option keys mapped to descriptions. A null description uses the key itself. Keys must not be blank; ties follow the model's option order. */
486
+ readonly criteria: {
487
+ [key: string]: string | null;
488
+ };
489
+ }
490
+
491
+ /**
492
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
493
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
494
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
495
+ */
496
+ /** Distribution concentration, calculated as 1 - H(p) / ln(N), where H(p) is entropy and N is the candidate count. Zero means uniform probabilities; values near 1 mean one candidate dominates. Not calibrated correctness. */
497
+ type SystemOneConfidence = number;
498
+
499
+ /**
500
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
501
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
502
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
503
+ */
504
+ /** A nonempty string, or an object or array serialized as JSON text. Not interpreted as chat messages or multimodal input. */
505
+ type SystemOneContent = string | {
506
+ [key: string]: unknown;
507
+ } | unknown[];
508
+
509
+ /**
510
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
511
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
512
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
513
+ */
514
+ interface SystemOneNoulAnswer {
515
+ readonly type: 'noul';
516
+ /** Probability of true among the false and true candidates. This is a number, not a Boolean. */
517
+ readonly noul: number;
518
+ }
519
+
520
+ /**
521
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
522
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
523
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
524
+ */
525
+
526
+ interface SystemOneNoulQuestion {
527
+ readonly type: 'noul';
528
+ readonly instructions: SystemOneContent;
529
+ /** Optional descriptions for the two outcomes. Omitted entries use No and Yes. */
530
+ readonly criteria?: {
531
+ readonly false?: string | undefined;
532
+ readonly true?: string | undefined;
533
+ } | undefined;
534
+ }
535
+
536
+ /**
537
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
538
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
539
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
540
+ */
541
+ /** Probabilities normalized over the supplied candidates, summing to 1 subject to floating-point precision. */
542
+ type SystemOneProbabilities = {
543
+ [key: string]: number;
544
+ };
545
+
546
+ /**
547
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
548
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
549
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
550
+ */
551
+
552
+ interface SystemOneRequest {
553
+ /** Local model trained for System One, such as nimble. Requires compatible GGUF weights and a scoring-capable runner; cloud and MLX/Safetensors models are not supported. */
554
+ readonly model: string;
555
+ readonly state: SystemOneContent;
556
+ /** Base64-encoded images shared by all questions, in request order. Requires Clef or Clef Flash with vision weights. URLs and data URLs are not supported. */
557
+ readonly images?: readonly string[] | undefined;
558
+ /** Named questions about the shared state. Answers are not passed to later questions. */
559
+ readonly questions: {
560
+ [key: string]: SystemOneChoiceQuestion | SystemOneNoulQuestion | SystemOneScoreQuestion;
561
+ };
562
+ /** How long to keep the model loaded after the request, as a duration string (such as 5m) or seconds. Zero unloads after the request; a negative value keeps it loaded. Defaults to the server's keep-alive setting (5m unless configured otherwise). */
563
+ readonly keep_alive?: string | number | undefined;
564
+ }
565
+
566
+ /**
567
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
568
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
569
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
570
+ */
571
+
572
+ interface SystemOneResponse {
573
+ /** Model name from the request. */
574
+ readonly model: string;
575
+ /** Answers keyed by the question names in the request. */
576
+ readonly answers: {
577
+ [key: string]: SystemOneChoiceAnswer | SystemOneNoulAnswer | SystemOneScoreAnswer;
578
+ };
579
+ readonly usage: {
580
+ /** Total evaluated input tokens, including image positions. Shared context is counted again when the model scores questions separately. */
581
+ readonly input_tokens: number;
582
+ /** Tokens generated internally for scoring, including prefix preparation and retries. May exceed the question count; not the length of the JSON response. */
583
+ readonly output_tokens: number;
584
+ };
585
+ }
586
+
587
+ /**
588
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
589
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
590
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
591
+ */
592
+
593
+ interface SystemOneScoreAnswer {
594
+ readonly type: 'score';
595
+ /** Probability-weighted average of the zero-based criterion indices, from 0 to the number of criteria minus 1. Not rounded to a level or normalized to 0–1. */
596
+ readonly score: number;
597
+ /** Zero-based indices as string keys mapped to the criterion descriptions. */
598
+ readonly legend: {
599
+ [key: string]: string;
600
+ };
601
+ /** Probabilities keyed by zero-based criterion indices as strings. */
602
+ readonly probabilities: SystemOneProbabilities;
603
+ readonly confidence: SystemOneConfidence;
604
+ }
605
+
606
+ /**
607
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
608
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
609
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
610
+ */
611
+
612
+ interface SystemOneScoreQuestion {
613
+ readonly type: 'score';
614
+ readonly instructions: SystemOneContent;
615
+ /** Descriptions ordered from the lowest score (index 0) to the highest. Defines a scale from 0 to the number of criteria minus 1. */
616
+ readonly criteria: readonly string[];
617
+ }
618
+
619
+ /**
620
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
621
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
622
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
623
+ */
624
+ /** Controls a model's thinking output. Use `/api/show` to discover the supported values and default for the selected model. `true` requests thinking, `false` requests no thinking output, and `null` uses the model default. String values are model-defined; supported names must match `/api/show` exactly. Numbers are not supported. */
625
+ type ThinkValue = boolean | string | null;
626
+
627
+ /**
628
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
629
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
630
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
631
+ */
632
+ /** Thinking controls advertised by a model. Models without thinking metadata omit this field. */
633
+ interface Thinking {
634
+ /** Values explicitly supported by the model's `think` request field. Booleans represent on/off controls and strings represent model-defined levels. An array containing only `false` identifies a model without thinking support. */
635
+ readonly values: readonly (boolean | string)[];
636
+ /** Value used when `think` is not set. For models that use this metadata for named thinking levels, unsupported names resolve to this default. */
637
+ readonly default: boolean | string;
638
+ }
639
+
640
+ /**
641
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
642
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
643
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
644
+ */
645
+ /** Log probability information for a single token alternative */
646
+ interface TokenLogprob {
647
+ /** The text representation of the token */
648
+ readonly token?: string | undefined;
649
+ /** The log probability of this token */
650
+ readonly logprob?: number | undefined;
651
+ /** The raw byte representation of the token */
652
+ readonly bytes?: readonly number[] | undefined;
653
+ }
654
+
655
+ /**
656
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
657
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
658
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
659
+ */
660
+ interface ToolCall {
661
+ readonly function?: {
662
+ /** Name of the function to call */
663
+ readonly name: string;
664
+ /** What the function does */
665
+ readonly description?: string | undefined;
666
+ /** JSON object of arguments to pass to the function */
667
+ readonly arguments?: Record<string, unknown> | undefined;
668
+ } | undefined;
669
+ }
670
+
671
+ /**
672
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
673
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
674
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
675
+ */
676
+ interface ToolDefinition {
677
+ /** Type of tool (always `function`) */
678
+ readonly type: 'function';
679
+ readonly function: {
680
+ /** Function name exposed to the model */
681
+ readonly name: string;
682
+ /** Human-readable description of the function */
683
+ readonly description?: string | undefined;
684
+ /** JSON Schema for the function parameters */
685
+ readonly parameters: Record<string, unknown>;
686
+ };
687
+ }
688
+
689
+ /**
690
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
691
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
692
+ * See ADR 0013 and ADR 0014 for the contract-first architecture.
693
+ */
694
+ interface VersionResponse {
695
+ /** Version of Ollama */
696
+ readonly version?: string | undefined;
697
+ }
698
+
699
+ /**
700
+ * AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
701
+ * Source: contracts/ir/ollama.ir.json (canonical Ollama IR).
702
+ * Each generated class delegates to OllamaRuntime — the runtime owns
703
+ * transport, retry, streaming, telemetry, and error handling.
704
+ */
705
+
706
+ /**
707
+ * Generated API surface for Ollama's native domain.
708
+ * Each method delegates to {@link OllamaRuntime.invoke}.
709
+ */
710
+ declare class NativeApi {
711
+ private readonly runtime;
712
+ constructor(runtime: OllamaRuntime);
713
+ blobs(digest: string, options?: {
714
+ signal?: AbortSignal;
715
+ }): Promise<unknown>;
716
+ chat(request: ChatRequest & {
717
+ stream?: false;
718
+ }): Promise<ChatResponse>;
719
+ chat(request: ChatRequest & {
720
+ stream: true;
721
+ }): Promise<AsyncGenerator<ChatResponse, void, undefined>>;
722
+ copy(request: CopyRequest): Promise<unknown>;
723
+ create(request: CreateRequest & {
724
+ stream?: false;
725
+ }): Promise<StatusResponse>;
726
+ create(request: CreateRequest & {
727
+ stream: true;
728
+ }): Promise<AsyncGenerator<StatusResponse, void, undefined>>;
729
+ delete(request: DeleteRequest): Promise<unknown>;
730
+ embed(request: EmbedRequest): Promise<EmbedResponse>;
731
+ generate(request: GenerateRequest & {
732
+ stream?: false;
733
+ }): Promise<GenerateResponse>;
734
+ generate(request: GenerateRequest & {
735
+ stream: true;
736
+ }): Promise<AsyncGenerator<GenerateResponse, void, undefined>>;
737
+ ps(options?: {
738
+ signal?: AbortSignal;
739
+ }): Promise<PsResponse>;
740
+ pull(request: PullRequest & {
741
+ stream?: false;
742
+ }): Promise<StatusResponse>;
743
+ pull(request: PullRequest & {
744
+ stream: true;
745
+ }): Promise<AsyncGenerator<StatusResponse, void, undefined>>;
746
+ push(request: PushRequest & {
747
+ stream?: false;
748
+ }): Promise<StatusResponse>;
749
+ push(request: PushRequest & {
750
+ stream: true;
751
+ }): Promise<AsyncGenerator<StatusResponse, void, undefined>>;
752
+ show(request: ShowRequest): Promise<ShowResponse>;
753
+ systemOne(request: SystemOneRequest): Promise<SystemOneResponse>;
754
+ tags(options?: {
755
+ signal?: AbortSignal;
756
+ }): Promise<ListResponse>;
757
+ version(options?: {
758
+ signal?: AbortSignal;
759
+ }): Promise<VersionResponse>;
760
+ }
761
+
762
+ /**
763
+ * Shared request-runner contract used by native and compatibility clients.
764
+ */
765
+
766
+ type RequestRunner = <T>(op: (http: HttpClient, signal: AbortSignal) => Promise<T>, opts?: {
767
+ readonly signal?: AbortSignal | undefined;
768
+ readonly timeoutMs?: number | undefined;
769
+ readonly singleEndpoint?: boolean | undefined;
770
+ readonly model?: string | undefined;
771
+ /** Defers endpoint capacity release until the returned promise settles. */
772
+ readonly holdUntil?: ((result: T) => Promise<unknown>) | undefined;
773
+ }) => Promise<T>;
774
+
775
+ /**
776
+ * OpenAI Compatibility interfaces and client helpers for Ollama.
777
+ * Ollama exposes OpenAI-compatible /v1 endpoints.
778
+ *
779
+ * @remarks
780
+ * This is a typed pass-through to Ollama's own OpenAI-compatible `/v1` endpoints — it
781
+ * implements the subset of the OpenAI API surface that Ollama documents as supported
782
+ * (https://docs.ollama.com/api/openai-compatibility), not the full OpenAI surface (hosted
783
+ * tools like web/file search, computer use, code interpreter, or stateful server-side
784
+ * conversation state). Notably, `tools` is supported by Ollama's compat layer but
785
+ * `tool_choice` and `parallel_tool_calls` are not — both are still typed on
786
+ * {@link OpenAIChatCompletionRequest} (accepted-but-ignored) so consumers passing a
787
+ * standard OpenAI request object don't get spurious type errors; see the `@remarks` on
788
+ * each field. `/v1/responses` is supported non-statefully — see
789
+ * {@link OpenAIResponsesRequest}.
790
+ */
791
+
792
+ interface OpenAIToolCall {
793
+ readonly id: string;
794
+ readonly type: 'function';
795
+ readonly function: {
796
+ readonly name: string;
797
+ /** JSON-encoded arguments string, matching OpenAI's wire format (not a parsed object). */
798
+ readonly arguments: string;
799
+ };
800
+ }
801
+ interface OpenAITextContentPart {
802
+ readonly type: 'text';
803
+ readonly text: string;
804
+ }
805
+ interface OpenAIImageUrlContentPart {
806
+ readonly type: 'image_url';
807
+ /** Ollama accepts a data/image URL string or the standard OpenAI URL object. */
808
+ readonly image_url: string | {
809
+ readonly url: string;
810
+ readonly detail?: 'auto' | 'low' | 'high' | 'original' | undefined;
811
+ };
812
+ }
813
+ type OpenAIContentPart = OpenAITextContentPart | OpenAIImageUrlContentPart;
814
+ interface OpenAIMessage {
815
+ readonly role: 'system' | 'user' | 'assistant' | 'tool';
816
+ readonly content: string | readonly OpenAIContentPart[];
817
+ readonly name?: string | undefined;
818
+ readonly tool_calls?: readonly OpenAIToolCall[] | undefined;
819
+ /** Ollama may emit model reasoning alongside assistant content. */
820
+ readonly reasoning?: string | undefined;
821
+ /** Set on a `role: 'tool'` message to identify which call this is a result for. */
822
+ readonly tool_call_id?: string | undefined;
823
+ }
824
+ interface OpenAIStreamOptions {
825
+ /** Emit a final SSE chunk carrying `usage` (prompt/completion/total tokens) before `[DONE]`. */
826
+ readonly include_usage?: boolean | undefined;
827
+ }
828
+ interface OpenAIFunctionDefinition {
829
+ readonly name: string;
830
+ readonly description?: string | undefined;
831
+ readonly parameters?: Record<string, unknown> | undefined;
832
+ }
833
+ interface OpenAITool {
834
+ readonly type: 'function';
835
+ readonly function: OpenAIFunctionDefinition;
836
+ }
837
+ type OpenAIReasoningEffort = 'high' | 'medium' | 'low' | 'max' | 'none' | 'minimal' | 'xhigh' | 'ultra' | (string & {});
838
+ type OpenAIResponseFormat = {
839
+ readonly type: 'text';
840
+ } | {
841
+ readonly type: 'json_object';
842
+ } | {
843
+ readonly type: 'json_schema';
844
+ readonly json_schema: Record<string, unknown>;
845
+ };
846
+ interface OpenAIChatCompletionRequest {
847
+ readonly model: string;
848
+ readonly messages: readonly OpenAIMessage[];
849
+ readonly temperature?: number | undefined;
850
+ readonly top_p?: number | undefined;
851
+ readonly stream?: boolean | undefined;
852
+ /** Only meaningful when `stream: true`; ignored otherwise. */
853
+ readonly stream_options?: OpenAIStreamOptions | undefined;
854
+ readonly max_tokens?: number | undefined;
855
+ readonly stop?: readonly string[] | undefined;
856
+ readonly response_format?: OpenAIResponseFormat | undefined;
857
+ readonly seed?: number | undefined;
858
+ readonly presence_penalty?: number | undefined;
859
+ readonly frequency_penalty?: number | undefined;
860
+ readonly user?: string | undefined;
861
+ readonly logit_bias?: Record<string, number> | undefined;
862
+ readonly n?: number | undefined;
863
+ /** Ollama exposes log probabilities for supported reasoning/chat models. */
864
+ readonly logprobs?: boolean | undefined;
865
+ readonly top_logprobs?: number | undefined;
866
+ readonly tools?: readonly OpenAITool[] | undefined;
867
+ /**
868
+ * @remarks Accepted for OpenAI compatibility but ignored by Ollama — every tool the
869
+ * model is given remains callable regardless of this value.
870
+ */
871
+ readonly tool_choice?: 'none' | 'auto' | 'required' | {
872
+ readonly type: 'function';
873
+ readonly function: {
874
+ readonly name: string;
875
+ };
876
+ } | undefined;
877
+ /**
878
+ * @remarks Accepted for OpenAI compatibility but ignored by Ollama — Ollama does not
879
+ * control tool-call parallelism through this flag.
880
+ */
881
+ readonly parallel_tool_calls?: boolean | undefined;
882
+ /**
883
+ * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`). Equivalent to
884
+ * `reasoning.effort`; only effective for models that support reasoning/thinking.
885
+ */
886
+ readonly reasoning_effort?: OpenAIReasoningEffort | undefined;
887
+ /**
888
+ * Effort level for thinking models (e.g. `deepseek-r1`, `qwen3`), nested OpenAI-style.
889
+ * Equivalent to `reasoning_effort`; only effective for models that support
890
+ * reasoning/thinking.
891
+ */
892
+ readonly reasoning?: {
893
+ readonly effort?: OpenAIReasoningEffort | undefined;
894
+ } | undefined;
895
+ }
896
+ /** Ollama Chat Completions supports text plus base64 image content via a string image URL. */
897
+ type OllamaOpenAIChatContentPart = OpenAITextContentPart | {
898
+ readonly type: 'image_url';
899
+ /** Ollama's current compatibility docs accept an image URL string, including data URLs. */
900
+ readonly image_url: string;
901
+ };
902
+ type OllamaOpenAIReasoningEffort = 'high' | 'medium' | 'low' | 'max' | 'none';
903
+ type OllamaOpenAIChatMessage = Omit<OpenAIMessage, 'content'> & {
904
+ readonly content: string | readonly OllamaOpenAIChatContentPart[];
905
+ };
906
+ /** Strict Ollama-documented Chat Completions request; excludes only the SDK-only parallel tool flag. */
907
+ type OllamaOpenAIChatCompletionRequest = Omit<OpenAIChatCompletionRequest, 'messages' | 'parallel_tool_calls' | 'reasoning_effort' | 'reasoning'> & {
908
+ readonly messages: readonly OllamaOpenAIChatMessage[];
909
+ readonly reasoning_effort?: OllamaOpenAIReasoningEffort | undefined;
910
+ readonly reasoning?: {
911
+ readonly effort?: OllamaOpenAIReasoningEffort | undefined;
912
+ } | undefined;
913
+ };
914
+ interface OpenAIChatCompletionChoice {
915
+ readonly index: number;
916
+ readonly message: OpenAIMessage;
917
+ readonly finish_reason: string;
918
+ readonly logprobs?: Record<string, unknown> | null | undefined;
919
+ }
920
+ interface OpenAIToolCallDelta {
921
+ readonly index: number;
922
+ readonly id?: string | undefined;
923
+ readonly type?: 'function' | undefined;
924
+ readonly function?: {
925
+ readonly name?: string | undefined;
926
+ readonly arguments?: string | undefined;
927
+ } | undefined;
928
+ }
929
+ interface OpenAIChatCompletionDelta {
930
+ readonly role?: OpenAIMessage['role'] | undefined;
931
+ readonly content?: string | null | undefined;
932
+ readonly reasoning?: string | null | undefined;
933
+ readonly refusal?: string | null | undefined;
934
+ readonly tool_calls?: readonly OpenAIToolCallDelta[] | undefined;
935
+ }
936
+ interface OpenAIChatCompletionChunkChoice {
937
+ readonly index: number;
938
+ readonly delta: OpenAIChatCompletionDelta;
939
+ readonly finish_reason?: string | null | undefined;
940
+ readonly logprobs?: Record<string, unknown> | null | undefined;
941
+ }
942
+ interface OpenAIChatCompletionChunk {
943
+ readonly id: string;
944
+ readonly object: 'chat.completion.chunk';
945
+ readonly created: number;
946
+ readonly model: string;
947
+ readonly system_fingerprint?: string | undefined;
948
+ readonly choices: readonly OpenAIChatCompletionChunkChoice[];
949
+ readonly usage?: {
950
+ readonly prompt_tokens: number;
951
+ readonly completion_tokens: number;
952
+ readonly total_tokens: number;
953
+ } | null | undefined;
954
+ }
955
+ interface OpenAIUsage {
956
+ readonly prompt_tokens: number;
957
+ readonly completion_tokens: number;
958
+ readonly total_tokens: number;
959
+ readonly prompt_tokens_details?: {
960
+ readonly cached_tokens?: number | undefined;
961
+ } | undefined;
962
+ }
963
+ interface OpenAIChatCompletionResponse {
964
+ readonly id: string;
965
+ readonly object: 'chat.completion';
966
+ readonly created: number;
967
+ readonly model: string;
968
+ readonly system_fingerprint?: string | undefined;
969
+ readonly choices: readonly OpenAIChatCompletionChoice[];
970
+ readonly usage?: OpenAIUsage | undefined;
971
+ }
972
+ interface OpenAIModelItem {
973
+ readonly id: string;
974
+ readonly object: 'model';
975
+ readonly created: number;
976
+ readonly owned_by: string;
977
+ }
978
+ interface OpenAIListModelsResponse {
979
+ readonly object: 'list';
980
+ readonly data: readonly OpenAIModelItem[];
981
+ }
982
+ interface OpenAICompletionRequest {
983
+ readonly model: string;
984
+ /** Ollama currently accepts a string prompt for /v1/completions. */
985
+ readonly prompt: string;
986
+ /** Number of log probability alternatives requested for completion tokens. */
987
+ readonly logprobs?: number | undefined;
988
+ readonly frequency_penalty?: number | undefined;
989
+ readonly presence_penalty?: number | undefined;
990
+ readonly seed?: number | undefined;
991
+ readonly stop?: readonly string[] | undefined;
992
+ readonly stream?: boolean | undefined;
993
+ readonly stream_options?: OpenAIStreamOptions | undefined;
994
+ readonly temperature?: number | undefined;
995
+ readonly top_p?: number | undefined;
996
+ readonly max_tokens?: number | undefined;
997
+ readonly suffix?: string | undefined;
998
+ readonly best_of?: number | undefined;
999
+ readonly echo?: boolean | undefined;
1000
+ readonly logit_bias?: Record<string, number> | undefined;
1001
+ readonly user?: string | undefined;
1002
+ readonly n?: number | undefined;
1003
+ }
1004
+ /** Strict Ollama-documented Completions request. */
1005
+ type OllamaOpenAICompletionRequest = OpenAICompletionRequest;
1006
+ interface OpenAICompletionChoice {
1007
+ readonly text: string;
1008
+ readonly index: number;
1009
+ readonly logprobs?: Record<string, unknown> | null | undefined;
1010
+ readonly finish_reason: string | null;
1011
+ }
1012
+ interface OpenAICompletionChunk {
1013
+ readonly id: string;
1014
+ readonly object: 'text_completion';
1015
+ readonly created: number;
1016
+ readonly model: string;
1017
+ readonly system_fingerprint?: string | undefined;
1018
+ readonly choices: readonly {
1019
+ readonly text: string;
1020
+ readonly index: number;
1021
+ readonly logprobs?: Record<string, unknown> | null | undefined;
1022
+ readonly finish_reason?: string | null | undefined;
1023
+ }[];
1024
+ readonly usage?: {
1025
+ readonly prompt_tokens: number;
1026
+ readonly completion_tokens: number;
1027
+ readonly total_tokens: number;
1028
+ } | null | undefined;
1029
+ }
1030
+ interface OpenAICompletionResponse {
1031
+ readonly id: string;
1032
+ readonly object: 'text_completion';
1033
+ readonly created: number;
1034
+ readonly model: string;
1035
+ readonly system_fingerprint?: string | undefined;
1036
+ readonly choices: readonly OpenAICompletionChoice[];
1037
+ readonly usage?: OpenAIUsage | undefined;
1038
+ }
1039
+ type OpenAIEmbeddingInput = string | readonly string[] | readonly number[] | readonly (readonly number[])[];
1040
+ interface OpenAIEmbeddingRequest {
1041
+ readonly model: string;
1042
+ readonly input: OpenAIEmbeddingInput;
1043
+ readonly encoding_format?: 'float' | 'base64' | undefined;
1044
+ readonly dimensions?: number | undefined;
1045
+ readonly user?: string | undefined;
1046
+ }
1047
+ /** Strict Ollama-documented Embeddings request. */
1048
+ type OllamaOpenAIEmbeddingRequest = OpenAIEmbeddingRequest;
1049
+ interface OpenAIEmbeddingItem {
1050
+ readonly object: 'embedding';
1051
+ readonly embedding: readonly number[] | string;
1052
+ readonly index: number;
1053
+ }
1054
+ interface OpenAIEmbeddingResponse {
1055
+ readonly object: 'list';
1056
+ readonly data: readonly OpenAIEmbeddingItem[];
1057
+ readonly model: string;
1058
+ readonly usage?: {
1059
+ readonly prompt_tokens: number;
1060
+ readonly total_tokens: number;
1061
+ } | undefined;
1062
+ }
1063
+ /**
1064
+ * Request body for OpenAI's Responses API (`/v1/responses`), added in Ollama v0.13.3.
1065
+ *
1066
+ * @remarks
1067
+ * Ollama implements this **non-statefully**: every call is independent, so
1068
+ * {@link previous_response_id} and {@link conversation} — OpenAI's mechanisms for
1069
+ * resuming server-side conversation state — are accepted for compatibility but ignored.
1070
+ * Send the full conversation in `input` on every call, the same as `/api/chat`.
1071
+ */
1072
+ interface OpenAIResponsesRequest {
1073
+ readonly model: string;
1074
+ readonly input: string | readonly OpenAIMessage[];
1075
+ readonly instructions?: string | undefined;
1076
+ readonly tools?: readonly OpenAITool[] | undefined;
1077
+ readonly stream?: boolean | undefined;
1078
+ readonly temperature?: number | undefined;
1079
+ readonly top_p?: number | undefined;
1080
+ readonly max_output_tokens?: number | undefined;
1081
+ /** @remarks Not supported by Ollama, which is stateless across calls — accepted but ignored. */
1082
+ readonly previous_response_id?: string | undefined;
1083
+ /** @remarks Not supported by Ollama, which is stateless across calls — accepted but ignored. */
1084
+ readonly conversation?: string | undefined;
1085
+ readonly truncation?: string | undefined;
1086
+ readonly reasoning?: {
1087
+ readonly effort?: OpenAIReasoningEffort | undefined;
1088
+ } | undefined;
1089
+ /** Ollama extension: boolean, model-defined string, or null for model default. */
1090
+ readonly think?: boolean | string | null | undefined;
1091
+ }
1092
+ /** Strict Ollama-documented Responses request; excludes stateful and SDK-only request fields. */
1093
+ /** Strict Ollama-documented Responses request; excludes only unsupported stateful fields. */
1094
+ type OllamaOpenAIResponsesRequest = Omit<OpenAIResponsesRequest, 'previous_response_id' | 'conversation'>;
1095
+ type OpenAIResponsesStatus = 'completed' | 'failed' | 'in_progress' | 'cancelled' | 'queued' | 'incomplete';
1096
+ interface OpenAIResponsesError {
1097
+ readonly code?: string | undefined;
1098
+ readonly message?: string | undefined;
1099
+ readonly [key: string]: unknown;
1100
+ }
1101
+ interface OpenAIResponsesIncompleteDetails {
1102
+ readonly reason?: string | undefined;
1103
+ readonly [key: string]: unknown;
1104
+ }
1105
+ interface OpenAIResponsesOutputTextContent {
1106
+ readonly type: 'output_text';
1107
+ readonly text: string;
1108
+ readonly annotations?: readonly Record<string, unknown>[] | undefined;
1109
+ readonly logprobs?: readonly Record<string, unknown>[] | undefined;
1110
+ }
1111
+ interface OpenAIResponsesOutputRefusal {
1112
+ readonly type: 'refusal';
1113
+ readonly refusal: string;
1114
+ }
1115
+ type OpenAIResponsesOutputContent = OpenAIResponsesOutputTextContent | OpenAIResponsesOutputRefusal;
1116
+ interface OpenAIResponsesOutputMessage {
1117
+ readonly type: 'message';
1118
+ readonly id?: string | undefined;
1119
+ readonly status?: OpenAIResponsesStatus | undefined;
1120
+ readonly role?: string | undefined;
1121
+ readonly phase?: string | undefined;
1122
+ readonly content: readonly OpenAIResponsesOutputContent[];
1123
+ }
1124
+ interface OpenAIResponsesOutputFunctionCall {
1125
+ readonly type: 'function_call';
1126
+ readonly id?: string | undefined;
1127
+ readonly call_id?: string | undefined;
1128
+ readonly name: string;
1129
+ readonly arguments: string;
1130
+ readonly status?: OpenAIResponsesStatus | undefined;
1131
+ }
1132
+ interface OpenAIResponsesOutputReasoning {
1133
+ readonly type: 'reasoning';
1134
+ readonly id?: string | undefined;
1135
+ readonly status?: OpenAIResponsesStatus | undefined;
1136
+ readonly summary?: readonly {
1137
+ readonly type: 'summary_text';
1138
+ readonly text: string;
1139
+ }[] | undefined;
1140
+ readonly text?: string | undefined;
1141
+ readonly encrypted_content?: string | undefined;
1142
+ }
1143
+ type OpenAIResponsesOutputItem = OpenAIResponsesOutputMessage | OpenAIResponsesOutputFunctionCall | OpenAIResponsesOutputReasoning;
1144
+ interface OpenAIResponsesUsage {
1145
+ readonly input_tokens: number;
1146
+ readonly output_tokens: number;
1147
+ readonly total_tokens: number;
1148
+ readonly input_tokens_details?: Record<string, unknown> | undefined;
1149
+ readonly output_tokens_details?: Record<string, unknown> | undefined;
1150
+ }
1151
+ /** Non-stateful response shape for the Ollama Responses compatibility endpoint. */
1152
+ interface OpenAIResponsesResponse {
1153
+ readonly id: string;
1154
+ readonly object: 'response';
1155
+ readonly created: number;
1156
+ readonly created_at?: number | undefined;
1157
+ readonly status?: OpenAIResponsesStatus | undefined;
1158
+ readonly completed_at?: number | null | undefined;
1159
+ readonly error?: OpenAIResponsesError | null | undefined;
1160
+ readonly incomplete_details?: OpenAIResponsesIncompleteDetails | null | undefined;
1161
+ readonly model: string;
1162
+ readonly output: readonly OpenAIResponsesOutputItem[];
1163
+ readonly output_text?: string | undefined;
1164
+ readonly previous_response_id?: string | null | undefined;
1165
+ readonly parallel_tool_calls?: boolean | undefined;
1166
+ readonly usage?: OpenAIResponsesUsage | undefined;
1167
+ }
1168
+ declare class OpenAIResponsesStreamError extends OllamaClientError {
1169
+ readonly responsePayload: OpenAIResponsesResponse;
1170
+ constructor(message: string, responsePayload: OpenAIResponsesResponse);
1171
+ }
1172
+ declare class OpenAIChatCompletionStream implements AsyncIterable<OpenAIChatCompletionChunk> {
1173
+ private readonly source;
1174
+ private readonly finalResultPromise;
1175
+ private resolveFinal;
1176
+ private rejectFinal;
1177
+ private removeAbortListener;
1178
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1179
+ get finalResult(): Promise<OpenAIChatCompletionResponse>;
1180
+ abort(): void;
1181
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAIChatCompletionChunk, void, undefined>;
1182
+ }
1183
+ declare class OpenAICompletionStream implements AsyncIterable<OpenAICompletionChunk> {
1184
+ private readonly source;
1185
+ private readonly finalResultPromise;
1186
+ private resolveFinal;
1187
+ private rejectFinal;
1188
+ private removeAbortListener;
1189
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1190
+ get finalResult(): Promise<OpenAICompletionResponse>;
1191
+ abort(): void;
1192
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAICompletionChunk, void, undefined>;
1193
+ }
1194
+ interface OpenAIResponsesEventBase {
1195
+ readonly response_id?: string | undefined;
1196
+ readonly sequence_number?: number | undefined;
1197
+ }
1198
+ interface OpenAIResponsesOutputTextDeltaEvent extends OpenAIResponsesEventBase {
1199
+ readonly type: 'response.output_text.delta';
1200
+ readonly item_id: string;
1201
+ readonly output_index: number;
1202
+ readonly content_index: number;
1203
+ readonly delta: string;
1204
+ }
1205
+ interface OpenAIResponsesOutputTextDoneEvent extends OpenAIResponsesEventBase {
1206
+ readonly type: 'response.output_text.done';
1207
+ readonly item_id: string;
1208
+ readonly output_index: number;
1209
+ readonly content_index: number;
1210
+ readonly text: string;
1211
+ }
1212
+ interface OpenAIResponsesFunctionCallArgumentsDeltaEvent extends OpenAIResponsesEventBase {
1213
+ readonly type: 'response.function_call_arguments.delta';
1214
+ readonly item_id: string;
1215
+ readonly output_index: number;
1216
+ readonly delta: string;
1217
+ }
1218
+ interface OpenAIResponsesFunctionCallArgumentsDoneEvent extends OpenAIResponsesEventBase {
1219
+ readonly type: 'response.function_call_arguments.done';
1220
+ readonly item_id: string;
1221
+ readonly output_index: number;
1222
+ readonly arguments: string;
1223
+ readonly name?: string | undefined;
1224
+ }
1225
+ interface OpenAIResponsesReasoningTextDeltaEvent extends OpenAIResponsesEventBase {
1226
+ readonly type: 'response.reasoning_text.delta';
1227
+ readonly item_id: string;
1228
+ readonly output_index: number;
1229
+ readonly content_index: number;
1230
+ readonly delta: string;
1231
+ }
1232
+ interface OpenAIResponsesReasoningTextDoneEvent extends OpenAIResponsesEventBase {
1233
+ readonly type: 'response.reasoning_text.done';
1234
+ readonly item_id: string;
1235
+ readonly output_index: number;
1236
+ readonly content_index: number;
1237
+ readonly text: string;
1238
+ }
1239
+ interface OpenAIResponsesReasoningSummaryPartAddedEvent extends OpenAIResponsesEventBase {
1240
+ readonly type: 'response.reasoning_summary_part.added';
1241
+ readonly item_id: string;
1242
+ readonly output_index: number;
1243
+ readonly summary_index: number;
1244
+ readonly part: {
1245
+ readonly type: 'summary_text';
1246
+ readonly text: string;
1247
+ };
1248
+ }
1249
+ interface OpenAIResponsesReasoningSummaryPartDoneEvent extends OpenAIResponsesEventBase {
1250
+ readonly type: 'response.reasoning_summary_part.done';
1251
+ readonly item_id: string;
1252
+ readonly output_index: number;
1253
+ readonly summary_index: number;
1254
+ readonly part: {
1255
+ readonly type: 'summary_text';
1256
+ readonly text: string;
1257
+ };
1258
+ readonly status?: 'incomplete' | undefined;
1259
+ }
1260
+ interface OpenAIResponsesReasoningSummaryTextDeltaEvent extends OpenAIResponsesEventBase {
1261
+ readonly type: 'response.reasoning_summary_text.delta';
1262
+ readonly item_id: string;
1263
+ readonly output_index: number;
1264
+ readonly summary_index: number;
1265
+ readonly delta: string;
1266
+ }
1267
+ interface OpenAIResponsesReasoningSummaryTextDoneEvent extends OpenAIResponsesEventBase {
1268
+ readonly type: 'response.reasoning_summary_text.done';
1269
+ readonly item_id: string;
1270
+ readonly output_index: number;
1271
+ readonly summary_index: number;
1272
+ readonly text: string;
1273
+ }
1274
+ interface OpenAIResponsesOutputItemAddedEvent extends OpenAIResponsesEventBase {
1275
+ readonly type: 'response.output_item.added';
1276
+ readonly item: OpenAIResponsesOutputItem;
1277
+ readonly output_index: number;
1278
+ }
1279
+ interface OpenAIResponsesOutputItemDoneEvent extends OpenAIResponsesEventBase {
1280
+ readonly type: 'response.output_item.done';
1281
+ readonly item: OpenAIResponsesOutputItem;
1282
+ readonly output_index: number;
1283
+ }
1284
+ interface OpenAIResponsesContentPartAddedEvent extends OpenAIResponsesEventBase {
1285
+ readonly type: 'response.content_part.added';
1286
+ readonly item_id: string;
1287
+ readonly output_index: number;
1288
+ readonly content_index: number;
1289
+ readonly part: OpenAIResponsesOutputContent | {
1290
+ readonly type: string;
1291
+ readonly [key: string]: unknown;
1292
+ };
1293
+ }
1294
+ interface OpenAIResponsesContentPartDoneEvent extends OpenAIResponsesEventBase {
1295
+ readonly type: 'response.content_part.done';
1296
+ readonly item_id: string;
1297
+ readonly output_index: number;
1298
+ readonly content_index: number;
1299
+ readonly part: OpenAIResponsesOutputContent | {
1300
+ readonly type: string;
1301
+ readonly [key: string]: unknown;
1302
+ };
1303
+ }
1304
+ interface OpenAIResponsesRefusalDeltaEvent extends OpenAIResponsesEventBase {
1305
+ readonly type: 'response.refusal.delta';
1306
+ readonly item_id: string;
1307
+ readonly output_index: number;
1308
+ readonly content_index: number;
1309
+ readonly delta: string;
1310
+ }
1311
+ interface OpenAIResponsesRefusalDoneEvent extends OpenAIResponsesEventBase {
1312
+ readonly type: 'response.refusal.done';
1313
+ readonly item_id: string;
1314
+ readonly output_index: number;
1315
+ readonly content_index: number;
1316
+ readonly refusal: string;
1317
+ }
1318
+ interface OpenAIResponsesCreatedEvent extends OpenAIResponsesEventBase {
1319
+ readonly type: 'response.created';
1320
+ readonly response: OpenAIResponsesResponse;
1321
+ }
1322
+ interface OpenAIResponsesInProgressEvent extends OpenAIResponsesEventBase {
1323
+ readonly type: 'response.in_progress';
1324
+ readonly response: OpenAIResponsesResponse;
1325
+ }
1326
+ interface OpenAIResponsesQueuedEvent extends OpenAIResponsesEventBase {
1327
+ readonly type: 'response.queued';
1328
+ readonly response: OpenAIResponsesResponse;
1329
+ }
1330
+ interface OpenAIResponsesCompletedEvent extends OpenAIResponsesEventBase {
1331
+ readonly type: 'response.completed' | 'response.done';
1332
+ readonly response: OpenAIResponsesResponse;
1333
+ }
1334
+ interface OpenAIResponsesFailedEvent extends OpenAIResponsesEventBase {
1335
+ readonly type: 'response.failed';
1336
+ readonly response: OpenAIResponsesResponse;
1337
+ }
1338
+ interface OpenAIResponsesIncompleteEvent extends OpenAIResponsesEventBase {
1339
+ readonly type: 'response.incomplete';
1340
+ readonly response: OpenAIResponsesResponse;
1341
+ }
1342
+ type OpenAIResponsesStreamEvent = OpenAIResponsesOutputTextDeltaEvent | OpenAIResponsesOutputTextDoneEvent | OpenAIResponsesFunctionCallArgumentsDeltaEvent | OpenAIResponsesFunctionCallArgumentsDoneEvent | OpenAIResponsesReasoningTextDeltaEvent | OpenAIResponsesReasoningTextDoneEvent | OpenAIResponsesReasoningSummaryPartAddedEvent | OpenAIResponsesReasoningSummaryPartDoneEvent | OpenAIResponsesReasoningSummaryTextDeltaEvent | OpenAIResponsesReasoningSummaryTextDoneEvent | OpenAIResponsesOutputItemAddedEvent | OpenAIResponsesOutputItemDoneEvent | OpenAIResponsesContentPartAddedEvent | OpenAIResponsesContentPartDoneEvent | OpenAIResponsesRefusalDeltaEvent | OpenAIResponsesRefusalDoneEvent | OpenAIResponsesCreatedEvent | OpenAIResponsesInProgressEvent | OpenAIResponsesQueuedEvent | OpenAIResponsesCompletedEvent | OpenAIResponsesFailedEvent | OpenAIResponsesIncompleteEvent | {
1343
+ readonly type: string;
1344
+ readonly [key: string]: unknown;
1345
+ };
1346
+ declare class OpenAIResponsesStream implements AsyncIterable<OpenAIResponsesStreamEvent> {
1347
+ private readonly source;
1348
+ private readonly finalResultPromise;
1349
+ private resolveFinal;
1350
+ private rejectFinal;
1351
+ private removeAbortListener;
1352
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1353
+ get finalResult(): Promise<OpenAIResponsesResponse>;
1354
+ abort(): void;
1355
+ [Symbol.asyncIterator](): AsyncGenerator<OpenAIResponsesStreamEvent, void, undefined>;
1356
+ }
1357
+ declare class OpenAICompatClient {
1358
+ private readonly http;
1359
+ private readonly runner?;
1360
+ constructor(http: HttpClient, runner?: RequestRunner | undefined);
1361
+ private request;
1362
+ createChatCompletion(request: OpenAIChatCompletionRequest & {
1363
+ stream: true;
1364
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionStream>;
1365
+ createChatCompletion(request: OpenAIChatCompletionRequest & {
1366
+ stream?: false | undefined;
1367
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
1368
+ chatCompletions(request: OpenAIChatCompletionRequest & {
1369
+ stream: true;
1370
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionStream>;
1371
+ chatCompletions(request: OpenAIChatCompletionRequest & {
1372
+ stream?: false | undefined;
1373
+ }, signal?: AbortSignal): Promise<OpenAIChatCompletionResponse>;
1374
+ listModels(signal?: AbortSignal): Promise<OpenAIListModelsResponse>;
1375
+ retrieveModel(model: string, signal?: AbortSignal): Promise<OpenAIModelItem>;
1376
+ getModel(model: string, signal?: AbortSignal): Promise<OpenAIModelItem>;
1377
+ createCompletion(request: OpenAICompletionRequest & {
1378
+ stream: true;
1379
+ }, signal?: AbortSignal): Promise<OpenAICompletionStream>;
1380
+ createCompletion(request: OpenAICompletionRequest & {
1381
+ stream?: false | undefined;
1382
+ }, signal?: AbortSignal): Promise<OpenAICompletionResponse>;
1383
+ completions(request: OpenAICompletionRequest & {
1384
+ stream: true;
1385
+ }, signal?: AbortSignal): Promise<OpenAICompletionStream>;
1386
+ completions(request: OpenAICompletionRequest & {
1387
+ stream?: false | undefined;
1388
+ }, signal?: AbortSignal): Promise<OpenAICompletionResponse>;
1389
+ createEmbedding(request: OpenAIEmbeddingRequest, signal?: AbortSignal): Promise<OpenAIEmbeddingResponse>;
1390
+ embeddings(request: OpenAIEmbeddingRequest, signal?: AbortSignal): Promise<OpenAIEmbeddingResponse>;
1391
+ createResponses(request: OpenAIResponsesRequest & {
1392
+ stream: true;
1393
+ }, signal?: AbortSignal): Promise<OpenAIResponsesStream>;
1394
+ createResponses(request: OpenAIResponsesRequest & {
1395
+ stream?: false | undefined;
1396
+ }, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
1397
+ responses(request: OpenAIResponsesRequest & {
1398
+ stream: true;
1399
+ }, signal?: AbortSignal): Promise<OpenAIResponsesStream>;
1400
+ responses(request: OpenAIResponsesRequest & {
1401
+ stream?: false | undefined;
1402
+ }, signal?: AbortSignal): Promise<OpenAIResponsesResponse>;
1403
+ }
1404
+
1405
+ /**
1406
+ * Anthropic Compatibility interfaces and client helpers for Ollama.
1407
+ * Ollama supports the Anthropic Messages API format.
1408
+ */
1409
+
1410
+ interface AnthropicCacheControl {
1411
+ readonly type: 'ephemeral';
1412
+ readonly ttl?: '5m' | '1h' | undefined;
1413
+ }
1414
+ interface AnthropicTextContentBlock {
1415
+ readonly type: 'text';
1416
+ readonly text: string;
1417
+ readonly cache_control?: AnthropicCacheControl | undefined;
1418
+ }
1419
+ interface AnthropicImageContentBlock {
1420
+ readonly type: 'image';
1421
+ readonly source: {
1422
+ readonly type: 'base64';
1423
+ readonly media_type: string;
1424
+ readonly data: string;
1425
+ };
1426
+ }
1427
+ interface AnthropicToolUseContentBlock {
1428
+ readonly type: 'tool_use';
1429
+ readonly id: string;
1430
+ readonly name: string;
1431
+ readonly input: Record<string, unknown>;
1432
+ }
1433
+ interface AnthropicToolResultContentBlock {
1434
+ readonly type: 'tool_result';
1435
+ readonly tool_use_id: string;
1436
+ readonly content?: string | readonly AnthropicTextContentBlock[] | undefined;
1437
+ readonly is_error?: boolean | undefined;
1438
+ }
1439
+ interface AnthropicThinkingContentBlock {
1440
+ readonly type: 'thinking';
1441
+ readonly thinking: string;
1442
+ readonly signature?: string | undefined;
1443
+ }
1444
+ interface AnthropicRedactedThinkingContentBlock {
1445
+ readonly type: 'redacted_thinking';
1446
+ readonly data: string;
1447
+ }
1448
+ type AnthropicContentBlock = AnthropicTextContentBlock | AnthropicImageContentBlock | AnthropicToolUseContentBlock | AnthropicToolResultContentBlock | AnthropicThinkingContentBlock | AnthropicRedactedThinkingContentBlock;
1449
+ interface AnthropicMessage {
1450
+ readonly role: 'user' | 'assistant';
1451
+ readonly content: string | readonly AnthropicContentBlock[];
1452
+ }
1453
+ interface AnthropicSystemTextBlock {
1454
+ readonly type: 'text';
1455
+ readonly text: string;
1456
+ readonly cache_control?: AnthropicCacheControl | undefined;
1457
+ }
1458
+ type AnthropicSystem = string | readonly AnthropicSystemTextBlock[];
1459
+ interface AnthropicTool {
1460
+ readonly name: string;
1461
+ readonly description?: string | undefined;
1462
+ readonly input_schema: Record<string, unknown>;
1463
+ readonly eager_input_streaming?: boolean | undefined;
1464
+ }
1465
+ type AnthropicToolChoice = {
1466
+ readonly type: 'auto';
1467
+ readonly disable_parallel_tool_use?: boolean | undefined;
1468
+ } | {
1469
+ readonly type: 'any';
1470
+ readonly disable_parallel_tool_use?: boolean | undefined;
1471
+ } | {
1472
+ readonly type: 'tool';
1473
+ readonly name: string;
1474
+ readonly disable_parallel_tool_use?: boolean | undefined;
1475
+ } | {
1476
+ readonly type: 'none';
1477
+ };
1478
+ interface AnthropicThinkingConfig {
1479
+ readonly type: 'enabled' | 'disabled' | 'adaptive';
1480
+ readonly display?: 'omitted' | 'summarized' | 'updates' | undefined;
1481
+ /** Accepted by Ollama for compatibility but currently not enforced by the server. */
1482
+ readonly budget_tokens?: number | undefined;
1483
+ }
1484
+ interface AnthropicOutputConfig {
1485
+ readonly effort?: string | undefined;
1486
+ }
1487
+ interface AnthropicMetadata {
1488
+ readonly user_id?: string | undefined;
1489
+ }
1490
+ interface AnthropicMessagesRequest {
1491
+ readonly model: string;
1492
+ readonly messages: readonly AnthropicMessage[];
1493
+ readonly system?: AnthropicSystem | undefined;
1494
+ readonly max_tokens?: number | undefined;
1495
+ readonly temperature?: number | undefined;
1496
+ readonly top_p?: number | undefined;
1497
+ readonly top_k?: number | undefined;
1498
+ readonly stop_sequences?: readonly string[] | undefined;
1499
+ readonly stream?: boolean | undefined;
1500
+ readonly tools?: readonly AnthropicTool[] | undefined;
1501
+ readonly thinking?: AnthropicThinkingConfig | undefined;
1502
+ readonly output_config?: AnthropicOutputConfig | undefined;
1503
+ /**
1504
+ * Accepted for Anthropic compatibility but currently ignored by Ollama.
1505
+ * Tool selection cannot be forced through the Ollama compatibility endpoint.
1506
+ */
1507
+ readonly tool_choice?: AnthropicToolChoice | undefined;
1508
+ /** Accepted for compatibility but currently ignored by Ollama. */
1509
+ readonly metadata?: AnthropicMetadata | undefined;
1510
+ }
1511
+ /** Strict Ollama-documented Messages request; excludes fields Ollama marks unsupported. */
1512
+ type OllamaAnthropicTextContentBlock = Omit<AnthropicTextContentBlock, 'cache_control'>;
1513
+ type OllamaAnthropicTool = Omit<AnthropicTool, 'eager_input_streaming'>;
1514
+ type OllamaAnthropicThinkingConfig = {
1515
+ readonly type: 'enabled' | 'disabled';
1516
+ /** Accepted by Ollama for compatibility but currently not enforced by the server. */
1517
+ readonly budget_tokens?: number | undefined;
1518
+ };
1519
+ type OllamaAnthropicToolResultContentBlock = Omit<AnthropicToolResultContentBlock, 'content'> & {
1520
+ readonly content?: string | readonly OllamaAnthropicTextContentBlock[] | undefined;
1521
+ };
1522
+ type OllamaAnthropicContentBlock = OllamaAnthropicTextContentBlock | AnthropicImageContentBlock | AnthropicToolUseContentBlock | OllamaAnthropicToolResultContentBlock | AnthropicThinkingContentBlock;
1523
+ type OllamaAnthropicMessage = Omit<AnthropicMessage, 'content'> & {
1524
+ readonly content: string | readonly OllamaAnthropicContentBlock[];
1525
+ };
1526
+ type OllamaAnthropicSystemTextBlock = Omit<AnthropicSystemTextBlock, 'cache_control'>;
1527
+ type OllamaAnthropicSystem = string | readonly OllamaAnthropicSystemTextBlock[];
1528
+ /** Strict Ollama-documented Messages request; excludes unsupported caching/tool-choice metadata. */
1529
+ type OllamaAnthropicMessagesRequest = Omit<AnthropicMessagesRequest, 'messages' | 'system' | 'tools' | 'thinking' | 'tool_choice' | 'metadata'> & {
1530
+ readonly messages: readonly OllamaAnthropicMessage[];
1531
+ readonly system?: OllamaAnthropicSystem | undefined;
1532
+ readonly tools?: readonly OllamaAnthropicTool[] | undefined;
1533
+ readonly thinking?: OllamaAnthropicThinkingConfig | undefined;
1534
+ };
1535
+ interface AnthropicMessagesResponse {
1536
+ readonly id: string;
1537
+ readonly type: 'message';
1538
+ readonly role: 'assistant';
1539
+ readonly content: readonly AnthropicContentBlock[];
1540
+ readonly model: string;
1541
+ readonly stop_reason: string | null;
1542
+ readonly stop_sequence?: string | null | undefined;
1543
+ readonly usage?: {
1544
+ readonly input_tokens: number;
1545
+ readonly output_tokens: number;
1546
+ readonly cache_creation_input_tokens?: number | undefined;
1547
+ readonly cache_read_input_tokens?: number | undefined;
1548
+ readonly cache_creation?: Record<string, unknown> | undefined;
1549
+ } | undefined;
1550
+ }
1551
+ interface AnthropicMessageStartEvent {
1552
+ readonly type: 'message_start';
1553
+ readonly message: AnthropicMessagesResponse;
1554
+ }
1555
+ interface AnthropicContentBlockStartEvent {
1556
+ readonly type: 'content_block_start';
1557
+ readonly index: number;
1558
+ readonly content_block: AnthropicContentBlock;
1559
+ }
1560
+ type AnthropicContentBlockDelta = {
1561
+ readonly type: 'text_delta';
1562
+ readonly text: string;
1563
+ } | {
1564
+ readonly type: 'input_json_delta';
1565
+ readonly partial_json: string;
1566
+ } | {
1567
+ readonly type: 'thinking_delta';
1568
+ readonly thinking: string;
1569
+ } | {
1570
+ readonly type: 'signature_delta';
1571
+ readonly signature: string;
1572
+ };
1573
+ interface AnthropicContentBlockDeltaEvent {
1574
+ readonly type: 'content_block_delta';
1575
+ readonly index: number;
1576
+ readonly delta: AnthropicContentBlockDelta;
1577
+ }
1578
+ interface AnthropicContentBlockStopEvent {
1579
+ readonly type: 'content_block_stop';
1580
+ readonly index: number;
1581
+ }
1582
+ interface AnthropicMessageDeltaEvent {
1583
+ readonly type: 'message_delta';
1584
+ readonly delta: {
1585
+ readonly stop_reason?: string | null | undefined;
1586
+ readonly stop_sequence?: string | null | undefined;
1587
+ };
1588
+ readonly usage?: {
1589
+ readonly input_tokens?: number | undefined;
1590
+ readonly output_tokens: number;
1591
+ readonly cache_creation_input_tokens?: number | undefined;
1592
+ readonly cache_read_input_tokens?: number | undefined;
1593
+ readonly cache_creation?: Record<string, unknown> | undefined;
1594
+ } | undefined;
1595
+ }
1596
+ interface AnthropicMessageStopEvent {
1597
+ readonly type: 'message_stop';
1598
+ }
1599
+ interface AnthropicPingEvent {
1600
+ readonly type: 'ping';
1601
+ }
1602
+ interface AnthropicErrorEvent {
1603
+ readonly type: 'error';
1604
+ readonly error: {
1605
+ readonly type: string;
1606
+ readonly message: string;
1607
+ };
1608
+ }
1609
+ interface AnthropicUnknownStreamEvent {
1610
+ /** Forward-compatible event type not yet modeled by this SDK. */
1611
+ readonly type: string;
1612
+ readonly [key: string]: unknown;
1613
+ }
1614
+ type AnthropicMessageStreamEvent = AnthropicMessageStartEvent | AnthropicContentBlockStartEvent | AnthropicContentBlockDeltaEvent | AnthropicContentBlockStopEvent | AnthropicMessageDeltaEvent | AnthropicMessageStopEvent | AnthropicPingEvent | AnthropicErrorEvent | AnthropicUnknownStreamEvent;
1615
+ declare class AnthropicMessagesStream implements AsyncIterable<AnthropicMessageStreamEvent> {
1616
+ private readonly source;
1617
+ private readonly finalResultPromise;
1618
+ private resolveFinal;
1619
+ private rejectFinal;
1620
+ private removeAbortListener;
1621
+ constructor(source: AbortableAsyncIterable<SseEvent>, signal?: AbortSignal);
1622
+ get finalResult(): Promise<AnthropicMessagesResponse>;
1623
+ abort(): void;
1624
+ [Symbol.asyncIterator](): AsyncGenerator<AnthropicMessageStreamEvent, void, undefined>;
1625
+ }
1626
+ declare class AnthropicCompatClient {
1627
+ private readonly http;
1628
+ private readonly runner?;
1629
+ constructor(http: HttpClient, runner?: RequestRunner | undefined);
1630
+ private request;
1631
+ createMessage(request: AnthropicMessagesRequest & {
1632
+ stream: true;
1633
+ }, signal?: AbortSignal): Promise<AnthropicMessagesStream>;
1634
+ createMessage(request: AnthropicMessagesRequest & {
1635
+ stream?: false | undefined;
1636
+ }, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1637
+ createMessage(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse | AnthropicMessagesStream>;
1638
+ messages(request: AnthropicMessagesRequest & {
1639
+ stream: true;
1640
+ }, signal?: AbortSignal): Promise<AnthropicMessagesStream>;
1641
+ messages(request: AnthropicMessagesRequest & {
1642
+ stream?: false | undefined;
1643
+ }, signal?: AbortSignal): Promise<AnthropicMessagesResponse>;
1644
+ messages(request: AnthropicMessagesRequest, signal?: AbortSignal): Promise<AnthropicMessagesResponse | AnthropicMessagesStream>;
1645
+ }
1646
+
1647
+ export { type OllamaAnthropicThinkingConfig as $, type AnthropicMessagesRequest as A, type AnthropicImageContentBlock as B, type AnthropicMessage as C, AnthropicMessagesStream as D, type AnthropicMetadata as E, type AnthropicOutputConfig as F, type AnthropicRedactedThinkingContentBlock as G, type AnthropicSystem as H, type AnthropicSystemTextBlock as I, type AnthropicTextContentBlock as J, type AnthropicThinkingConfig as K, type AnthropicThinkingContentBlock as L, type AnthropicTool as M, NativeApi as N, type OpenAIChatCompletionRequest as O, type AnthropicToolChoice as P, type AnthropicToolResultContentBlock as Q, type RequestRunner as R, type SystemOneChoiceAnswer as S, type AnthropicToolUseContentBlock as T, type AnthropicUnknownStreamEvent as U, type OllamaAnthropicContentBlock as V, type OllamaAnthropicMessage as W, type OllamaAnthropicMessagesRequest as X, type OllamaAnthropicSystem as Y, type OllamaAnthropicSystemTextBlock as Z, type OllamaAnthropicTextContentBlock as _, type OpenAIChatCompletionResponse as a, type SystemOneConfidence as a$, type OllamaAnthropicTool as a0, type OllamaAnthropicToolResultContentBlock as a1, type OllamaOpenAIChatCompletionRequest as a2, type OllamaOpenAICompletionRequest as a3, type OllamaOpenAIEmbeddingRequest as a4, type OllamaOpenAIReasoningEffort as a5, type OllamaOpenAIResponsesRequest as a6, type OpenAIChatCompletionChoice as a7, type OpenAIChatCompletionChunkChoice as a8, type OpenAIChatCompletionDelta as a9, type OpenAIResponsesOutputItemAddedEvent as aA, type OpenAIResponsesOutputItemDoneEvent as aB, type OpenAIResponsesOutputMessage as aC, type OpenAIResponsesOutputReasoning as aD, type OpenAIResponsesOutputRefusal as aE, type OpenAIResponsesOutputTextContent as aF, type OpenAIResponsesOutputTextDeltaEvent as aG, type OpenAIResponsesOutputTextDoneEvent as aH, type OpenAIResponsesQueuedEvent as aI, type OpenAIResponsesReasoningSummaryPartAddedEvent as aJ, type OpenAIResponsesReasoningSummaryPartDoneEvent as aK, type OpenAIResponsesReasoningSummaryTextDeltaEvent as aL, type OpenAIResponsesReasoningSummaryTextDoneEvent as aM, type OpenAIResponsesReasoningTextDeltaEvent as aN, type OpenAIResponsesReasoningTextDoneEvent as aO, type OpenAIResponsesRefusalDeltaEvent as aP, type OpenAIResponsesRefusalDoneEvent as aQ, type OpenAIResponsesStatus as aR, OpenAIResponsesStream as aS, OpenAIResponsesStreamError as aT, type OpenAIResponsesUsage as aU, type OpenAIStreamOptions as aV, type OpenAITextContentPart as aW, type OpenAITool as aX, type OpenAIToolCall as aY, type OpenAIToolCallDelta as aZ, type OpenAIUsage as a_, OpenAIChatCompletionStream as aa, type OpenAICompletionChoice as ab, OpenAICompletionStream as ac, type OpenAIContentPart as ad, type OpenAIEmbeddingInput as ae, type OpenAIEmbeddingItem as af, type OpenAIFunctionDefinition as ag, type OpenAIImageUrlContentPart as ah, type OpenAIMessage as ai, type OpenAIReasoningEffort as aj, type OpenAIResponseFormat as ak, type OpenAIResponsesCompletedEvent as al, type OpenAIResponsesContentPartAddedEvent as am, type OpenAIResponsesContentPartDoneEvent as an, type OpenAIResponsesCreatedEvent as ao, type OpenAIResponsesError as ap, type OpenAIResponsesEventBase as aq, type OpenAIResponsesFailedEvent as ar, type OpenAIResponsesFunctionCallArgumentsDeltaEvent as as, type OpenAIResponsesFunctionCallArgumentsDoneEvent as at, type OpenAIResponsesInProgressEvent as au, type OpenAIResponsesIncompleteDetails as av, type OpenAIResponsesIncompleteEvent as aw, type OpenAIResponsesOutputContent as ax, type OpenAIResponsesOutputFunctionCall as ay, type OpenAIResponsesOutputItem as az, type OpenAIChatCompletionChunk as b, type SystemOneProbabilities as b0, type OpenAICompletionRequest as c, type OpenAICompletionResponse as d, type OpenAICompletionChunk as e, type OpenAIEmbeddingRequest as f, type OpenAIEmbeddingResponse as g, type OpenAIListModelsResponse as h, type OpenAIModelItem as i, type OpenAIResponsesRequest as j, type OpenAIResponsesResponse as k, type OpenAIResponsesStreamEvent as l, type AnthropicMessagesResponse as m, type AnthropicMessageStreamEvent as n, type SystemOneNoulAnswer as o, type SystemOneScoreAnswer as p, type SystemOneChoiceQuestion as q, type SystemOneNoulQuestion as r, type SystemOneScoreQuestion as s, type SystemOneRequest as t, type SystemOneResponse as u, type SystemOneContent as v, OpenAICompatClient as w, AnthropicCompatClient as x, type AnthropicCacheControl as y, type AnthropicContentBlock as z };