{"record":{"id":"49ffc229cee455e8","repo":"vercel/ai","slug":"the-cohere-model-function-cannot-be-called-with-th","errorCode":null,"errorMessage":"The Cohere model function cannot be called with the new keyword.","messagePattern":"The Cohere model function cannot be called with the new keyword\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cohere/src/cohere-provider.ts","lineNumber":141,"sourceCode":"  const createEmbeddingModel = (modelId: CohereEmbeddingModelId) =>\n    new CohereEmbeddingModel(modelId, {\n      provider: 'cohere.textEmbedding',\n      baseURL,\n      headers: getHeaders,\n      fetch: options.fetch,\n    });\n\n  const createRerankingModel = (modelId: CohereRerankingModelId) =>\n    new CohereRerankingModel(modelId, {\n      provider: 'cohere.reranking',\n      baseURL,\n      headers: getHeaders,\n      fetch: options.fetch,\n    });\n\n  const provider = function (modelId: CohereChatModelId) {\n    if (new.target) {\n      throw new Error(\n        'The Cohere model function cannot be called with the new keyword.',\n      );\n    }\n\n    return createChatModel(modelId);\n  };\n\n  provider.specificationVersion = 'v4' as const;\n  provider.languageModel = createChatModel;\n  provider.embedding = createEmbeddingModel;\n  provider.embeddingModel = createEmbeddingModel;\n  provider.textEmbedding = createEmbeddingModel;\n  provider.textEmbeddingModel = createEmbeddingModel;\n  provider.reranking = createRerankingModel;\n  provider.rerankingModel = createRerankingModel;\n\n  provider.imageModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'imageModel' });","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/cohere/src/cohere-provider.ts#L123-L159","documentation":"Error \"The Cohere model function cannot be called with the new keyword.\" thrown in vercel/ai.","triggerScenarios":"Thrown at packages/cohere/src/cohere-provider.ts:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}