April 16, 2024, 8:18 p.m. | Luis

DEV Community dev.to

I created a module for @luisfun/cloudflare-ai-plugin, and this is its introduction.





What I Built


This is a plugin that allows you to write REST API and AI Gateway in the same way as binding AI (env.AI.run) when using Cloudflare's Workers AI.

Also, it supports Typescript.





How to Use


Install



npm i @luisfun/cloudflare-ai-plugin
npm i -D @cloudflare/ai # When using TypeScript


Coding



import { Ai } from '@luisfun/cloudflare-ai-plugin'

// const ai = env.AI
const ai = new Ai(env.AI_API_URL, env.AI_API_TOKEN)

const …

ai api cloudflare cloudflare ai env install introduction npm plugin rest rest api tutorial typescript workers workers ai

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US

Research Engineer

@ Allora Labs | Remote

Ecosystem Manager

@ Allora Labs | Remote

Founding AI Engineer, Agents

@ Occam AI | New York