Below you will find pages that utilize the taxonomy term “Cloudflare Worker”
mggg's Blog
How to Build a Zero-Cost AI Application Using Cloudflare
How to Build a Zero-Cost AI Application: A Step-by-Step Guide Using Cloudflare Harness the power of Cloudflare’s free tier to construct AI applications without incurring costs. This guide delineates the process of employing JavaScript along with Cloudflare’s suite of services—including AI inference engines and Cloudflare Workers—to craft a robust, serverless AI application.
Step-by-Step Configuration for AI Deployment on Cloudflare Step 1: Initiate with Cloudflare Account Configuration Kickstart your journey by setting up your Cloudflare account.
mggg's 博客
使用Cloudflare构建0成本的AI应用
构建0成本的AI应用:利用Cloudflare的强大功能 在当前的技术环境中,利用Cloudflare的免费套餐(Free Plan)可以轻松构建零成本的AI应用。仅通过使用JavaScript和Cloudflare的几个关键服务——Cloudflare AI, Cloudflare Worker, 和 Cloudflare Page——来实现这一目标。其中,Cloudflare Worker充当后端服务,而Cloudflare Page则扮演前端的角色。
初步准备 要开始这个项目,首先需要:
注册并开通Cloudflare账户。 从域名dashboard页面获取必要的认证信息,包括Account ID , 和API Token Cloudflare AI Cloudflare AI目前免费支持多种模型
@cf/baai/bge-base-en-v1.5 @cf/baai/bge-large-en-v1.5 @cf/baai/bge-small-en-v1.5 @cf/huggingface/distilbert-sst-2-int8 @cf/meta/llama-2-7b-chat-fp16 @cf/meta/llama-2-7b-chat-int8 @cf/meta/m2m100-1.2b @cf/microsoft/resnet-50 @cf/mistral/mistral-7b-instruct-v0.1 @cf/openai/whisper @cf/stabilityai/stable-diffusion-xl-base-1.0 可以通过以下命令行示例,结合前面获取的ACCOUNT_ID和API_TOKEN,快速测试这些模型:
curl -X POST \ https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/ai/run/@cf/meta/llama-2-7b-chat-int8 \ -H "Authorization: Bearer {API_TOKEN}" \ -d '{"messages":[{"role":"system","content":"You are a friendly assistant that helps write stories"},{"role":"user","content":"Write a short story about a llama that goes on a journey to find an orange cloud"}]}' Cloudflare Worker: 处理CORS 由于在使用Cloudflare Page时可能会遇到跨源资源共享(CORS)问题,因此可以通过Cloudflare Worker构建服务来解决这个问题,而不是直接调用Cloudflare AI的API。以下是一个基本的Cloudflare Worker脚本,用于处理CORS和转发AI模型请求: