ollama-ai-provider-v2 1.6.0-beta.0 → 2.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.
package/README.md CHANGED
@@ -15,7 +15,7 @@ Use Ollama with the Vercel AI SDK, implementing the official Ollama API. This pr
15
15
  - ✅ **Advanced Features** - Tool calling, streaming, thinking mode, embeddings, and completion models
16
16
  - ✅ **Type Safety** - Full TypeScript support with comprehensive type definitions
17
17
  - ✅ **Zero Configuration** - Works out-of-the-box with sensible defaults
18
- - ✅ **Actively Maintained** - Regular updates and AI SDK v5+ compatibility
18
+ - ✅ **Actively Maintained** - Regular updates and AI SDK v6+ compatibility
19
19
 
20
20
  ## Quick Start
21
21
 
@@ -82,19 +82,11 @@ const { text, toolCalls } = await generateText({
82
82
  Unique feature for models that support chain-of-thought reasoning:
83
83
 
84
84
  ```typescript
85
- // For most models - simple boolean
86
85
  const { text } = await generateText({
87
86
  model: ollama('deepseek-r1:7b'),
88
87
  providerOptions: { ollama: { think: true } },
89
88
  prompt: 'Solve this complex math problem step by step: 2x + 5 = 17',
90
89
  });
91
-
92
- // For GPT-OSS models - use thinking levels for trace length control
93
- const { text } = await generateText({
94
- model: ollama('gpt-oss:7b'),
95
- providerOptions: { ollama: { think: 'high' } }, // 'low', 'medium', or 'high'
96
- prompt: 'Analyze this complex scenario in detail',
97
- });
98
90
  ```
99
91
 
100
92
  ### Advanced Ollama Options
@@ -182,7 +174,7 @@ Works with any model in your Ollama installation, including:
182
174
 
183
175
  - **Chat Models**: `llama3.2`, `mistral`, `phi4-mini`, `qwen2.5`, `codellama`, `gemma3`
184
176
  - **Vision Models**: `llava`, `llama3.2-vision`, `minicpm-v`
185
- - **Reasoning Models**: `deepseek-r1:7b`, `deepseek-r1:1.5b`, `deepseek-r1:8b`, `gpt-oss:7b`
177
+ - **Reasoning Models**: `deepseek-r1:7b`, `deepseek-r1:1.5b`, `deepseek-r1:8b`
186
178
  - **Code Models**: `codellama:code`, `codellama:python`, `deepseek-coder-v2`
187
179
  - **Embedding Models**: `nomic-embed-text`, `all-minilm`, `mxbai-embed-large`
188
180
 
@@ -216,4 +208,4 @@ Contributions are welcome! Here's how to get started:
216
208
 
217
209
  Apache-2.0 © [nordwestt](https://github.com/nordwestt/ollama-ai-provider-v2)
218
210
 
219
- See [LICENSE.md](./LICENSE.md) for details.
211
+ See [LICENSE.md](./LICENSE.md) for details.
package/dist/index.d.mts CHANGED
@@ -1,14 +1,10 @@
1
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
 
5
5
  type OllamaChatModelId = "athene-v2" | "athene-v2:72b" | "aya-expanse" | "aya-expanse:8b" | "aya-expanse:32b" | "codegemma" | "codegemma:2b" | "codegemma:7b" | "codellama" | "codellama:7b" | "codellama:13b" | "codellama:34b" | "codellama:70b" | "codellama:code" | "codellama:python" | "command-r" | "command-r:35b" | "command-r-plus" | "command-r-plus:104b" | "command-r7b" | "command-r7b:7b" | "deepseek-r1" | "deepseek-r1:1.5b" | "deepseek-r1:7b" | "deepseek-r1:8b" | "deepseek-r1:14b" | "deepseek-r1:32b" | "deepseek-r1:70b" | "deepseek-r1:671b" | "deepseek-coder-v2" | "deepseek-coder-v2:16b" | "deepseek-coder-v2:236b" | "deepseek-v3" | "deepseek-v3:671b" | "devstral" | "devstral:24b" | "dolphin3" | "dolphin3:8b" | "exaone3.5" | "exaone3.5:2.4b" | "exaone3.5:7.8b" | "exaone3.5:32b" | "falcon2" | "falcon2:11b" | "falcon3" | "falcon3:1b" | "falcon3:3b" | "falcon3:7b" | "falcon3:10b" | "firefunction-v2" | "firefunction-v2:70b" | "gemma" | "gemma:2b" | "gemma:7b" | "gemma2" | "gemma2:2b" | "gemma2:9b" | "gemma2:27b" | "gemma3" | "gemma3:1b" | "gemma3:4b" | "gemma3:12b" | "gemma3:27b" | "granite3-dense" | "granite3-dense:2b" | "granite3-dense:8b" | "granite3-guardian" | "granite3-guardian:2b" | "granite3-guardian:8b" | "granite3-moe" | "granite3-moe:1b" | "granite3-moe:3b" | "granite3.1-dense" | "granite3.1-dense:2b" | "granite3.1-dense:8b" | "granite3.1-moe" | "granite3.1-moe:1b" | "granite3.1-moe:3b" | "llama2" | "llama2:7b" | "llama2:13b" | "llama2:70b" | "llama3" | "llama3:8b" | "llama3:70b" | "llama3-chatqa" | "llama3-chatqa:8b" | "llama3-chatqa:70b" | "llama3-gradient" | "llama3-gradient:8b" | "llama3-gradient:70b" | "llama3.1" | "llama3.1:8b" | "llama3.1:70b" | "llama3.1:405b" | "llama3.2" | "llama3.2:1b" | "llama3.2:3b" | "llama3.2-vision" | "llama3.2-vision:11b" | "llama3.2-vision:90b" | "llama3.3" | "llama3.3:70b" | "llama4" | "llama4:16x17b" | "llama4:128x17b" | "llama-guard3" | "llama-guard3:1b" | "llama-guard3:8b" | "llava" | "llava:7b" | "llava:13b" | "llava:34b" | "llava-llama3" | "llava-llama3:8b" | "llava-phi3" | "llava-phi3:3.8b" | "marco-o1" | "marco-o1:7b" | "mistral" | "mistral:7b" | "mistral-large" | "mistral-large:123b" | "mistral-nemo" | "mistral-nemo:12b" | "mistral-small" | "mistral-small:22b" | "mixtral" | "mixtral:8x7b" | "mixtral:8x22b" | "moondream" | "moondream:1.8b" | "openhermes" | "openhermes:v2.5" | "nemotron" | "nemotron:70b" | "nemotron-mini" | "nemotron-mini:4b" | "olmo" | "olmo:7b" | "olmo:13b" | "opencoder" | "opencoder:1.5b" | "opencoder:8b" | "phi3" | "phi3:3.8b" | "phi3:14b" | "phi3.5" | "phi3.5:3.8b" | "phi4" | "phi4:14b" | "qwen" | "qwen:7b" | "qwen:14b" | "qwen:32b" | "qwen:72b" | "qwen:110b" | "qwen2" | "qwen2:0.5b" | "qwen2:1.5b" | "qwen2:7b" | "qwen2:72b" | "qwen2.5" | "qwen2.5:0.5b" | "qwen2.5:1.5b" | "qwen2.5:3b" | "qwen2.5:7b" | "qwen2.5:14b" | "qwen2.5:32b" | "qwen2.5:72b" | "qwen2.5-coder" | "qwen2.5-coder:0.5b" | "qwen2.5-coder:1.5b" | "qwen2.5-coder:3b" | "qwen2.5-coder:7b" | "qwen2.5-coder:14b" | "qwen2.5-coder:32b" | "qwen3" | "qwen3:0.6b" | "qwen3:1.7b" | "qwen3:4b" | "qwen3:8b" | "qwen3:14b" | "qwen3:30b" | "qwen3:32b" | "qwen3:235b" | "qwq" | "qwq:32b" | "sailor2" | "sailor2:1b" | "sailor2:8b" | "sailor2:20b" | "shieldgemma" | "shieldgemma:2b" | "shieldgemma:9b" | "shieldgemma:27b" | "smallthinker" | "smallthinker:3b" | "smollm" | "smollm:135m" | "smollm:360m" | "smollm:1.7b" | "tinyllama" | "tinyllama:1.1b" | "tulu3" | "tulu3:8b" | "tulu3:70b" | (string & {});
6
6
  declare const ollamaProviderOptions: z.ZodObject<{
7
- think: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
8
- low: "low";
9
- medium: "medium";
10
- high: "high";
11
- }>]>>;
7
+ think: z.ZodOptional<z.ZodBoolean>;
12
8
  options: z.ZodOptional<z.ZodObject<{
13
9
  num_ctx: z.ZodOptional<z.ZodNumber>;
14
10
  repeat_last_n: z.ZodOptional<z.ZodNumber>;
@@ -31,12 +27,9 @@ interface OllamaCompletionSettings {
31
27
  * the model's thinking from the model's output. When disabled, the model will not think
32
28
  * and directly output the content.
33
29
  *
34
- * For GPT-OSS models: accepts "low", "medium", or "high" to tune trace length.
35
- * For other models: accepts boolean true/false.
36
- *
37
- * Only supported by certain models like DeepSeek R1, Qwen 3, and GPT-OSS.
30
+ * Only supported by certain models like DeepSeek R1 and Qwen 3.
38
31
  */
39
- think?: boolean | "low" | "medium" | "high";
32
+ think?: boolean;
40
33
  /**
41
34
  * Echo back the prompt in addition to the completion.
42
35
  */
@@ -72,36 +65,44 @@ interface OllamaEmbeddingSettings {
72
65
  monitor and detect abuse. Learn more.
73
66
  */
74
67
  user?: string;
68
+ /**
69
+ Whether to truncate input text to fit within model's context length.
70
+ */
71
+ truncate?: boolean;
72
+ /**
73
+ How long to keep the model loaded in memory (e.g., "5m" for 5 minutes).
74
+ */
75
+ keepAlive?: string;
75
76
  }
76
77
 
77
- interface OllamaProvider extends ProviderV2 {
78
- (modelId: OllamaChatModelId): LanguageModelV2;
78
+ interface OllamaProvider extends ProviderV3 {
79
+ (modelId: OllamaChatModelId): LanguageModelV3;
79
80
  /**
80
81
  Creates an Ollama model for text generation.
81
82
  */
82
- languageModel(modelId: OllamaChatModelId): LanguageModelV2;
83
+ languageModel(modelId: OllamaChatModelId): LanguageModelV3;
83
84
  /**
84
85
  Creates an Ollama chat model for text generation.
85
86
  */
86
- chat(modelId: OllamaChatModelId, settings?: OllamaProviderOptions): LanguageModelV2;
87
+ chat(modelId: OllamaChatModelId, settings?: OllamaProviderOptions): LanguageModelV3;
87
88
  /**
88
89
  Creates an Ollama completion model for text generation.
89
90
  */
90
- completion(modelId: OllamaCompletionModelId, settings?: OllamaCompletionSettings): LanguageModelV2;
91
+ completion(modelId: OllamaCompletionModelId, settings?: OllamaCompletionSettings): LanguageModelV3;
91
92
  /**
92
93
  Creates a model for text embeddings.
93
94
  */
94
- embedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
95
+ embedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
95
96
  /**
96
97
  Creates a model for text embeddings.
97
98
 
98
99
  @deprecated Use `textEmbeddingModel` instead.
99
100
  */
100
- textEmbedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
101
+ textEmbedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
101
102
  /**
102
103
  Creates a model for text embeddings.
103
104
  */
104
- textEmbeddingModel(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
105
+ textEmbeddingModel(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
105
106
  }
106
107
  interface OllamaProviderSettings {
107
108
  /**
@@ -153,11 +154,7 @@ declare const ollamaEmbeddingProviderOptions: z.ZodObject<{
153
154
  type OllamaEmbeddingProviderOptions = z.infer<typeof ollamaEmbeddingProviderOptions>;
154
155
 
155
156
  declare const ollamaCompletionProviderOptions: z.ZodObject<{
156
- think: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
157
- low: "low";
158
- medium: "medium";
159
- high: "high";
160
- }>]>>;
157
+ think: z.ZodOptional<z.ZodBoolean>;
161
158
  user: z.ZodOptional<z.ZodString>;
162
159
  suffix: z.ZodOptional<z.ZodString>;
163
160
  echo: z.ZodOptional<z.ZodBoolean>;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2 } from '@ai-sdk/provider';
1
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
 
5
5
  type OllamaChatModelId = "athene-v2" | "athene-v2:72b" | "aya-expanse" | "aya-expanse:8b" | "aya-expanse:32b" | "codegemma" | "codegemma:2b" | "codegemma:7b" | "codellama" | "codellama:7b" | "codellama:13b" | "codellama:34b" | "codellama:70b" | "codellama:code" | "codellama:python" | "command-r" | "command-r:35b" | "command-r-plus" | "command-r-plus:104b" | "command-r7b" | "command-r7b:7b" | "deepseek-r1" | "deepseek-r1:1.5b" | "deepseek-r1:7b" | "deepseek-r1:8b" | "deepseek-r1:14b" | "deepseek-r1:32b" | "deepseek-r1:70b" | "deepseek-r1:671b" | "deepseek-coder-v2" | "deepseek-coder-v2:16b" | "deepseek-coder-v2:236b" | "deepseek-v3" | "deepseek-v3:671b" | "devstral" | "devstral:24b" | "dolphin3" | "dolphin3:8b" | "exaone3.5" | "exaone3.5:2.4b" | "exaone3.5:7.8b" | "exaone3.5:32b" | "falcon2" | "falcon2:11b" | "falcon3" | "falcon3:1b" | "falcon3:3b" | "falcon3:7b" | "falcon3:10b" | "firefunction-v2" | "firefunction-v2:70b" | "gemma" | "gemma:2b" | "gemma:7b" | "gemma2" | "gemma2:2b" | "gemma2:9b" | "gemma2:27b" | "gemma3" | "gemma3:1b" | "gemma3:4b" | "gemma3:12b" | "gemma3:27b" | "granite3-dense" | "granite3-dense:2b" | "granite3-dense:8b" | "granite3-guardian" | "granite3-guardian:2b" | "granite3-guardian:8b" | "granite3-moe" | "granite3-moe:1b" | "granite3-moe:3b" | "granite3.1-dense" | "granite3.1-dense:2b" | "granite3.1-dense:8b" | "granite3.1-moe" | "granite3.1-moe:1b" | "granite3.1-moe:3b" | "llama2" | "llama2:7b" | "llama2:13b" | "llama2:70b" | "llama3" | "llama3:8b" | "llama3:70b" | "llama3-chatqa" | "llama3-chatqa:8b" | "llama3-chatqa:70b" | "llama3-gradient" | "llama3-gradient:8b" | "llama3-gradient:70b" | "llama3.1" | "llama3.1:8b" | "llama3.1:70b" | "llama3.1:405b" | "llama3.2" | "llama3.2:1b" | "llama3.2:3b" | "llama3.2-vision" | "llama3.2-vision:11b" | "llama3.2-vision:90b" | "llama3.3" | "llama3.3:70b" | "llama4" | "llama4:16x17b" | "llama4:128x17b" | "llama-guard3" | "llama-guard3:1b" | "llama-guard3:8b" | "llava" | "llava:7b" | "llava:13b" | "llava:34b" | "llava-llama3" | "llava-llama3:8b" | "llava-phi3" | "llava-phi3:3.8b" | "marco-o1" | "marco-o1:7b" | "mistral" | "mistral:7b" | "mistral-large" | "mistral-large:123b" | "mistral-nemo" | "mistral-nemo:12b" | "mistral-small" | "mistral-small:22b" | "mixtral" | "mixtral:8x7b" | "mixtral:8x22b" | "moondream" | "moondream:1.8b" | "openhermes" | "openhermes:v2.5" | "nemotron" | "nemotron:70b" | "nemotron-mini" | "nemotron-mini:4b" | "olmo" | "olmo:7b" | "olmo:13b" | "opencoder" | "opencoder:1.5b" | "opencoder:8b" | "phi3" | "phi3:3.8b" | "phi3:14b" | "phi3.5" | "phi3.5:3.8b" | "phi4" | "phi4:14b" | "qwen" | "qwen:7b" | "qwen:14b" | "qwen:32b" | "qwen:72b" | "qwen:110b" | "qwen2" | "qwen2:0.5b" | "qwen2:1.5b" | "qwen2:7b" | "qwen2:72b" | "qwen2.5" | "qwen2.5:0.5b" | "qwen2.5:1.5b" | "qwen2.5:3b" | "qwen2.5:7b" | "qwen2.5:14b" | "qwen2.5:32b" | "qwen2.5:72b" | "qwen2.5-coder" | "qwen2.5-coder:0.5b" | "qwen2.5-coder:1.5b" | "qwen2.5-coder:3b" | "qwen2.5-coder:7b" | "qwen2.5-coder:14b" | "qwen2.5-coder:32b" | "qwen3" | "qwen3:0.6b" | "qwen3:1.7b" | "qwen3:4b" | "qwen3:8b" | "qwen3:14b" | "qwen3:30b" | "qwen3:32b" | "qwen3:235b" | "qwq" | "qwq:32b" | "sailor2" | "sailor2:1b" | "sailor2:8b" | "sailor2:20b" | "shieldgemma" | "shieldgemma:2b" | "shieldgemma:9b" | "shieldgemma:27b" | "smallthinker" | "smallthinker:3b" | "smollm" | "smollm:135m" | "smollm:360m" | "smollm:1.7b" | "tinyllama" | "tinyllama:1.1b" | "tulu3" | "tulu3:8b" | "tulu3:70b" | (string & {});
6
6
  declare const ollamaProviderOptions: z.ZodObject<{
7
- think: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
8
- low: "low";
9
- medium: "medium";
10
- high: "high";
11
- }>]>>;
7
+ think: z.ZodOptional<z.ZodBoolean>;
12
8
  options: z.ZodOptional<z.ZodObject<{
13
9
  num_ctx: z.ZodOptional<z.ZodNumber>;
14
10
  repeat_last_n: z.ZodOptional<z.ZodNumber>;
@@ -31,12 +27,9 @@ interface OllamaCompletionSettings {
31
27
  * the model's thinking from the model's output. When disabled, the model will not think
32
28
  * and directly output the content.
33
29
  *
34
- * For GPT-OSS models: accepts "low", "medium", or "high" to tune trace length.
35
- * For other models: accepts boolean true/false.
36
- *
37
- * Only supported by certain models like DeepSeek R1, Qwen 3, and GPT-OSS.
30
+ * Only supported by certain models like DeepSeek R1 and Qwen 3.
38
31
  */
39
- think?: boolean | "low" | "medium" | "high";
32
+ think?: boolean;
40
33
  /**
41
34
  * Echo back the prompt in addition to the completion.
42
35
  */
@@ -72,36 +65,44 @@ interface OllamaEmbeddingSettings {
72
65
  monitor and detect abuse. Learn more.
73
66
  */
74
67
  user?: string;
68
+ /**
69
+ Whether to truncate input text to fit within model's context length.
70
+ */
71
+ truncate?: boolean;
72
+ /**
73
+ How long to keep the model loaded in memory (e.g., "5m" for 5 minutes).
74
+ */
75
+ keepAlive?: string;
75
76
  }
76
77
 
77
- interface OllamaProvider extends ProviderV2 {
78
- (modelId: OllamaChatModelId): LanguageModelV2;
78
+ interface OllamaProvider extends ProviderV3 {
79
+ (modelId: OllamaChatModelId): LanguageModelV3;
79
80
  /**
80
81
  Creates an Ollama model for text generation.
81
82
  */
82
- languageModel(modelId: OllamaChatModelId): LanguageModelV2;
83
+ languageModel(modelId: OllamaChatModelId): LanguageModelV3;
83
84
  /**
84
85
  Creates an Ollama chat model for text generation.
85
86
  */
86
- chat(modelId: OllamaChatModelId, settings?: OllamaProviderOptions): LanguageModelV2;
87
+ chat(modelId: OllamaChatModelId, settings?: OllamaProviderOptions): LanguageModelV3;
87
88
  /**
88
89
  Creates an Ollama completion model for text generation.
89
90
  */
90
- completion(modelId: OllamaCompletionModelId, settings?: OllamaCompletionSettings): LanguageModelV2;
91
+ completion(modelId: OllamaCompletionModelId, settings?: OllamaCompletionSettings): LanguageModelV3;
91
92
  /**
92
93
  Creates a model for text embeddings.
93
94
  */
94
- embedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
95
+ embedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
95
96
  /**
96
97
  Creates a model for text embeddings.
97
98
 
98
99
  @deprecated Use `textEmbeddingModel` instead.
99
100
  */
100
- textEmbedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
101
+ textEmbedding(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
101
102
  /**
102
103
  Creates a model for text embeddings.
103
104
  */
104
- textEmbeddingModel(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV2<string>;
105
+ textEmbeddingModel(modelId: OllamaEmbeddingModelId, settings?: OllamaEmbeddingSettings): EmbeddingModelV3;
105
106
  }
106
107
  interface OllamaProviderSettings {
107
108
  /**
@@ -153,11 +154,7 @@ declare const ollamaEmbeddingProviderOptions: z.ZodObject<{
153
154
  type OllamaEmbeddingProviderOptions = z.infer<typeof ollamaEmbeddingProviderOptions>;
154
155
 
155
156
  declare const ollamaCompletionProviderOptions: z.ZodObject<{
156
- think: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
157
- low: "low";
158
- medium: "medium";
159
- high: "high";
160
- }>]>>;
157
+ think: z.ZodOptional<z.ZodBoolean>;
161
158
  user: z.ZodOptional<z.ZodString>;
162
159
  suffix: z.ZodOptional<z.ZodString>;
163
160
  echo: z.ZodOptional<z.ZodBoolean>;