@openrouter/ai-sdk-provider 0.5.0 → 0.7.0-alpha.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
@@ -37,8 +37,7 @@ const { text } = await generateText({
37
37
 
38
38
  ## Supported models
39
39
 
40
- This list is not a definitive list of models supported by OpenRouter, as it constantly changes as we add new models (and deprecate old ones) to our system.
41
- You can find the latest list of models supported by OpenRouter [here](https://openrouter.ai/models).
40
+ This list is not a definitive list of models supported by OpenRouter, as it constantly changes as we add new models (and deprecate old ones) to our system. You can find the latest list of models supported by OpenRouter [here](https://openrouter.ai/models).
42
41
 
43
42
  You can find the latest list of tool-supported models supported by OpenRouter [here](https://openrouter.ai/models?order=newest&supported_parameters=tools). (Note: This list may contain models that are not compatible with the AI SDK.)
44
43
 
@@ -166,7 +165,7 @@ The provider supports [OpenRouter usage accounting](https://openrouter.ai/docs/u
166
165
  const model = openrouter('openai/gpt-3.5-turbo', {
167
166
  usage: {
168
167
  include: true,
169
- }
168
+ },
170
169
  });
171
170
 
172
171
  // Access usage accounting data
@@ -178,6 +177,9 @@ const result = await generateText({
178
177
  // Provider-specific usage details (available in providerMetadata)
179
178
  if (result.providerMetadata?.openrouter?.usage) {
180
179
  console.log('Cost:', result.providerMetadata.openrouter.usage.cost);
181
- console.log('Total Tokens:', result.providerMetadata.openrouter.usage.totalTokens);
180
+ console.log(
181
+ 'Total Tokens:',
182
+ result.providerMetadata.openrouter.usage.totalTokens,
183
+ );
182
184
  }
183
185
  ```
package/dist/index.d.mts CHANGED
@@ -56,8 +56,8 @@ type OpenRouterUsageAccounting = {
56
56
  cost?: number;
57
57
  };
58
58
 
59
- type OpenRouterChatModelId = string;
60
- type OpenRouterChatSettings = {
59
+ type OpenRouterCompletionModelId = string;
60
+ type OpenRouterCompletionSettings = {
61
61
  /**
62
62
  Modify the likelihood of specified tokens appearing in the completion.
63
63
 
@@ -71,7 +71,7 @@ type OpenRouterChatSettings = {
71
71
 
72
72
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
73
73
  token from being generated.
74
- */
74
+ */
75
75
  logitBias?: Record<number, number>;
76
76
  /**
77
77
  Return the log probabilities of the tokens. Including logprobs will increase
@@ -83,21 +83,16 @@ type OpenRouterChatSettings = {
83
83
 
84
84
  Setting to a number will return the log probabilities of the top n
85
85
  tokens that were generated.
86
- */
86
+ */
87
87
  logprobs?: boolean | number;
88
88
  /**
89
- Whether to enable parallel function calling during tool use. Default to true.
89
+ The suffix that comes after a completion of inserted text.
90
90
  */
91
- parallelToolCalls?: boolean;
92
- /**
93
- A unique identifier representing your end-user, which can help OpenRouter to
94
- monitor and detect abuse. Learn more.
95
- */
96
- user?: string;
91
+ suffix?: string;
97
92
  } & OpenRouterSharedSettings;
98
93
 
99
- type OpenRouterCompletionModelId = string;
100
- type OpenRouterCompletionSettings = {
94
+ type OpenRouterChatModelId = string;
95
+ type OpenRouterChatSettings = {
101
96
  /**
102
97
  Modify the likelihood of specified tokens appearing in the completion.
103
98
 
@@ -111,7 +106,7 @@ type OpenRouterCompletionSettings = {
111
106
 
112
107
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
113
108
  token from being generated.
114
- */
109
+ */
115
110
  logitBias?: Record<number, number>;
116
111
  /**
117
112
  Return the log probabilities of the tokens. Including logprobs will increase
@@ -123,12 +118,17 @@ type OpenRouterCompletionSettings = {
123
118
 
124
119
  Setting to a number will return the log probabilities of the top n
125
120
  tokens that were generated.
126
- */
121
+ */
127
122
  logprobs?: boolean | number;
128
123
  /**
129
- The suffix that comes after a completion of inserted text.
124
+ Whether to enable parallel function calling during tool use. Default to true.
130
125
  */
131
- suffix?: string;
126
+ parallelToolCalls?: boolean;
127
+ /**
128
+ A unique identifier representing your end-user, which can help OpenRouter to
129
+ monitor and detect abuse. Learn more.
130
+ */
131
+ user?: string;
132
132
  } & OpenRouterSharedSettings;
133
133
 
134
134
  type OpenRouterChatConfig = {
@@ -142,6 +142,8 @@ type OpenRouterChatConfig = {
142
142
  fetch?: typeof fetch;
143
143
  extraBody?: Record<string, unknown>;
144
144
  };
145
+ type DoGenerateOutput = Awaited<ReturnType<LanguageModelV1['doGenerate']>>;
146
+ type DoStreamOutput = Awaited<ReturnType<LanguageModelV1['doStream']>>;
145
147
  declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
146
148
  readonly specificationVersion = "v1";
147
149
  readonly defaultObjectGenerationMode = "tool";
@@ -151,8 +153,8 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
151
153
  constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
152
154
  get provider(): string;
153
155
  private getArgs;
154
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
155
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
156
+ doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<DoGenerateOutput>;
157
+ doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<DoStreamOutput>;
156
158
  }
157
159
 
158
160
  type OpenRouterCompletionConfig = {
package/dist/index.d.ts CHANGED
@@ -56,8 +56,8 @@ type OpenRouterUsageAccounting = {
56
56
  cost?: number;
57
57
  };
58
58
 
59
- type OpenRouterChatModelId = string;
60
- type OpenRouterChatSettings = {
59
+ type OpenRouterCompletionModelId = string;
60
+ type OpenRouterCompletionSettings = {
61
61
  /**
62
62
  Modify the likelihood of specified tokens appearing in the completion.
63
63
 
@@ -71,7 +71,7 @@ type OpenRouterChatSettings = {
71
71
 
72
72
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
73
73
  token from being generated.
74
- */
74
+ */
75
75
  logitBias?: Record<number, number>;
76
76
  /**
77
77
  Return the log probabilities of the tokens. Including logprobs will increase
@@ -83,21 +83,16 @@ type OpenRouterChatSettings = {
83
83
 
84
84
  Setting to a number will return the log probabilities of the top n
85
85
  tokens that were generated.
86
- */
86
+ */
87
87
  logprobs?: boolean | number;
88
88
  /**
89
- Whether to enable parallel function calling during tool use. Default to true.
89
+ The suffix that comes after a completion of inserted text.
90
90
  */
91
- parallelToolCalls?: boolean;
92
- /**
93
- A unique identifier representing your end-user, which can help OpenRouter to
94
- monitor and detect abuse. Learn more.
95
- */
96
- user?: string;
91
+ suffix?: string;
97
92
  } & OpenRouterSharedSettings;
98
93
 
99
- type OpenRouterCompletionModelId = string;
100
- type OpenRouterCompletionSettings = {
94
+ type OpenRouterChatModelId = string;
95
+ type OpenRouterChatSettings = {
101
96
  /**
102
97
  Modify the likelihood of specified tokens appearing in the completion.
103
98
 
@@ -111,7 +106,7 @@ type OpenRouterCompletionSettings = {
111
106
 
112
107
  As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
113
108
  token from being generated.
114
- */
109
+ */
115
110
  logitBias?: Record<number, number>;
116
111
  /**
117
112
  Return the log probabilities of the tokens. Including logprobs will increase
@@ -123,12 +118,17 @@ type OpenRouterCompletionSettings = {
123
118
 
124
119
  Setting to a number will return the log probabilities of the top n
125
120
  tokens that were generated.
126
- */
121
+ */
127
122
  logprobs?: boolean | number;
128
123
  /**
129
- The suffix that comes after a completion of inserted text.
124
+ Whether to enable parallel function calling during tool use. Default to true.
130
125
  */
131
- suffix?: string;
126
+ parallelToolCalls?: boolean;
127
+ /**
128
+ A unique identifier representing your end-user, which can help OpenRouter to
129
+ monitor and detect abuse. Learn more.
130
+ */
131
+ user?: string;
132
132
  } & OpenRouterSharedSettings;
133
133
 
134
134
  type OpenRouterChatConfig = {
@@ -142,6 +142,8 @@ type OpenRouterChatConfig = {
142
142
  fetch?: typeof fetch;
143
143
  extraBody?: Record<string, unknown>;
144
144
  };
145
+ type DoGenerateOutput = Awaited<ReturnType<LanguageModelV1['doGenerate']>>;
146
+ type DoStreamOutput = Awaited<ReturnType<LanguageModelV1['doStream']>>;
145
147
  declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
146
148
  readonly specificationVersion = "v1";
147
149
  readonly defaultObjectGenerationMode = "tool";
@@ -151,8 +153,8 @@ declare class OpenRouterChatLanguageModel implements LanguageModelV1 {
151
153
  constructor(modelId: OpenRouterChatModelId, settings: OpenRouterChatSettings, config: OpenRouterChatConfig);
152
154
  get provider(): string;
153
155
  private getArgs;
154
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
155
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
156
+ doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<DoGenerateOutput>;
157
+ doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<DoStreamOutput>;
156
158
  }
157
159
 
158
160
  type OpenRouterCompletionConfig = {