Skip to main content
This will help you get started with Cloudflare Workers AI text completion models (LLMs) using LangChain. For detailed documentation on CloudflareWorkersAI features and configuration options, please refer to the API reference.

Overview

Integration details

Setup

To access Cloudflare Workers AI models you’ll need to create a Cloudflare account, get an API key, and install the @langchain/cloudflare integration package.

Credentials

Head to this page to sign up to Cloudflare and generate an API key. Once you’ve done this, set your credentials in the environment:

Installation

The LangChain Cloudflare integration lives in the @langchain/cloudflare package:

Instantiation

Now we can instantiate our model object and generate chat completions:

Invocation


API reference

For detailed documentation of all CloudflareWorkersAI features and configurations head to the API reference.