@ai-sdk/anthropic 4.0.90 → 4.0.91
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-provider.ts +24 -12
package/package.json
CHANGED
|
@@ -160,18 +160,8 @@ export function createAnthropic(
|
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
? { Authorization: `Bearer ${await resolve(options.authToken)}` }
|
|
166
|
-
: {
|
|
167
|
-
'x-api-key': loadApiKey({
|
|
168
|
-
apiKey: options.apiKey,
|
|
169
|
-
environmentVariableName: 'ANTHROPIC_API_KEY',
|
|
170
|
-
description: 'Anthropic',
|
|
171
|
-
}),
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return withUserAgentSuffix(
|
|
163
|
+
const createHeaders = (authHeaders: Record<string, string>) =>
|
|
164
|
+
withUserAgentSuffix(
|
|
175
165
|
{
|
|
176
166
|
'anthropic-version': '2023-06-01',
|
|
177
167
|
...authHeaders,
|
|
@@ -179,6 +169,28 @@ export function createAnthropic(
|
|
|
179
169
|
},
|
|
180
170
|
`ai-sdk-anthropic/${VERSION}`,
|
|
181
171
|
);
|
|
172
|
+
|
|
173
|
+
const getHeaders = () => {
|
|
174
|
+
const authToken = options.authToken;
|
|
175
|
+
|
|
176
|
+
if (authToken) {
|
|
177
|
+
const token = typeof authToken === 'function' ? authToken() : authToken;
|
|
178
|
+
const createBearerHeaders = (token: string) =>
|
|
179
|
+
createHeaders({ Authorization: `Bearer ${token}` });
|
|
180
|
+
|
|
181
|
+
// Keep synchronous credentials serializable across workflow boundaries.
|
|
182
|
+
return typeof token === 'string'
|
|
183
|
+
? createBearerHeaders(token)
|
|
184
|
+
: resolve(token).then(createBearerHeaders);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return createHeaders({
|
|
188
|
+
'x-api-key': loadApiKey({
|
|
189
|
+
apiKey: options.apiKey,
|
|
190
|
+
environmentVariableName: 'ANTHROPIC_API_KEY',
|
|
191
|
+
description: 'Anthropic',
|
|
192
|
+
}),
|
|
193
|
+
});
|
|
182
194
|
};
|
|
183
195
|
|
|
184
196
|
const languageModelConfig = {
|