langchain's openai model fails on pages

I'm getting this error:

Error: Failed to publish your Function. Got error: Uncaught Error: [unenv] crypto.getHashes is not implemented yet!

From doing this:

import { OpenAI } from 'langchain/llms/openai';
...
const model = new OpenAI({openAIApiKey});

It should work though, because Cloudflare posted a blog that uses this same thing https://blog.cloudflare.com/langchain-and-cloudflare/

And even Langchain's docs say it supports workers: https://js.langchain.com/docs/get_started/installation

Is this something that only works on CF workers, and not on Pages?

If anyone knows of a workaround, please share!

My project is using Nuxt 3.
Was this page helpful?