``` curl --location 'https://api.cloudflare.com/client/v4/accounts/{my-account}/ai/run/@cf/mistral/m
16 Replies
Hey there, I would love to use Cloudflare Workers to do NSFW image checks.
Stable Diffusion has the model
CompVis/stable-diffusion-safety-checker
[1] which is apart of their text 2 img pipeline. I have it stood up on SageMaker, but I really love to use it in CF workers.
1: https://huggingface.co/CompVis/stable-diffusion-safety-checkerHi all, where can I find information about pricing for using workers AI, and different LLMs? Can't find it anywhere in cloudflare's docs, or my dashboard
Workers AI is free during beta with the limits listed here https://developers.cloudflare.com/workers-ai/platform/limits/
Pricing is just an early plan at the moment, mentioned on https://blog.cloudflare.com/workers-ai/
Okay, thank you.
Is this code incorrect? I'm having issues with errors being spit out. Here is the code I'm using to call Workers AI.
I get the following error in the logs:
Is there something I'm missing? I thought this was pretty close to what was in the docs. https://developers.cloudflare.com/workers-ai/models/text-generation/#using-streaming
Text Generation · Cloudflare Workers AI docs
Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
Code looks fine to me. But it doesn't look like a regular worker. I would try to update deps, create a basic worker with your AI code and deploy it to the prod. Then adapt to your needs. I used this guide and it worked great:
https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/
I should have mentioned, its using Itty-Router. The actual worker index can be found here: https://github.com/chand1012/openai-cf-workers-ai/blob/assistants/index.js
GitHub
openai-cf-workers-ai/index.js at assistants · chand1012/openai-cf-w...
Replacing OpenAI's API with Cloudflare AI. Contribute to chand1012/openai-cf-workers-ai development by creating an account on GitHub.
TinyRouter or itty-router?
Itty-router, fixed the original message
Does non-streaming flow work fine?
Yeah non streaming is fine, but I want to be able to support streaming on the API as well as take advantage of the higher token limits that streaming allows
Looks like some of your middleware is using ReadableStream.pipeTo() which is not implemented in workers runtime, according to this post:
https://community.cloudflare.com/t/running-into-unimplemented-functionality/77343/3
Which middleware you referring to? I just pushed the above test endpoint to my
assistants
branch so its all there. Is there something within itty-router that's doing something its not supposed to?Test file for reference https://github.com/chand1012/openai-cf-workers-ai/blob/assistants/routes/test.js
GitHub
openai-cf-workers-ai/routes/test.js at assistants · chand1012/opena...
Replacing OpenAI's API with Cloudflare AI. Contribute to chand1012/openai-cf-workers-ai development by creating an account on GitHub.
I think so. I've tested your Test snippet with my basic worker and it works just fine. I see that your only additional dep. is itty-router, so I would try to comment it out and test.
also, check your "@Cloudflare/ai" version. It's stale in your git repo.
"@Cloudflare/ai": "^1.0.15"
On the assistants branch its updated
Haven't merged to main since the features aren't done yet