fix(ai): resolve request-scoped auth before provider calls
closes #6021
This commit is contained in:
@@ -231,7 +231,16 @@ class ModelsImpl implements MutableModels {
|
||||
model: Model<Api>,
|
||||
options: TOptions | undefined,
|
||||
): Promise<{ requestModel: Model<Api>; requestOptions: TOptions | undefined }> {
|
||||
const resolution = await this.getAuth(model);
|
||||
const resolution = await resolveProviderAuth(
|
||||
this.requireProvider(model),
|
||||
model,
|
||||
this.credentials,
|
||||
this.authContext,
|
||||
{
|
||||
apiKey: options?.apiKey,
|
||||
env: options?.env,
|
||||
},
|
||||
);
|
||||
const auth = resolution?.auth;
|
||||
if (!auth) return { requestModel: model, requestOptions: options };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user