vercel/ai · error · Error
The Anthropic model function cannot be called with the new k
Error message
The Anthropic model function cannot be called with the new keyword.
What it means
Error "The Anthropic model function cannot be called with the new keyword." thrown in vercel/ai.
Source
Thrown at packages/google-vertex/src/anthropic/google-vertex-anthropic-provider.ts:235
transformRequestBody: args => {
// Remove model from args and add anthropic version
const { model: _model, ...rest } = args;
return {
...rest,
anthropic_version: 'vertex-2023-10-16',
};
},
// Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
supportedUrls: () => ({}),
// force the use of JSON tool fallback for structured outputs since beta header isn't supported
supportsNativeStructuredOutput: false,
// Vertex Anthropic doesn't support strict mode on tool definitions.
supportsStrictTools: false,
});
const provider = function (modelId: GoogleVertexAnthropicModelId) {
if (new.target) {
throw new Error(
'The Anthropic model function cannot be called with the new keyword.',
);
}
return createChatModel(modelId);
};
provider.specificationVersion = 'v4' as const;
provider.languageModel = createChatModel;
provider.chat = createChatModel;
provider.messages = createChatModel;
provider.embeddingModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });
};
provider.textEmbeddingModel = provider.embeddingModel;
provider.imageModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'imageModel' });View on GitHub (pinned to 69428b1f8b)
When it happens
Trigger: Thrown at packages/google-vertex/src/anthropic/google-vertex-anthropic-provider.ts:235 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/9b01fb2ede7a1d48.
Report an issue: GitHub.