Skip to main content
This will help you get started with CloudflareWorkersAI chat models. For detailed documentation of all ChatCloudflareWorkersAI features and configurations head to the API reference.

Overview

Integration details

Model features

Setup

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

Credentials

Head to www.cloudflare.com/developer-platform/products/workers-ai/ to sign up to CloudflareWorkersAI and generate an API key. Once you’ve done this set the CF_AI_API_KEY environment variable and the CF_ACCOUNT_ID environment variable:
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Installation

The LangChain CloudflareWorkersAI integration lives in the langchain-cloudflare package:

Instantiation

Now we can instantiate our model object and generate chat completions:
  • Update model instantiation with relevant params.

Invocation

Chaining

We can chain our model with a prompt template like so:

Structured Outputs

Bind tools

API reference

developers.cloudflare.com/workers-ai/ developers.cloudflare.com/agents/