Deploying with Wrangler CLI

Learn how to deploy the Text Summarizer application using Cloudflare's command-line interface.

About Wrangler CLI

This guide shows you how to deploy the Text Summarizer application (App 1 from the main tutorial) using Cloudflare's Wrangler CLI instead of the dashboard approach.

Note: Wrangler is Cloudflare's command-line interface for developing and deploying Workers. Using Wrangler provides more flexibility for local development, version control, and CI/CD integration compared to the dashboard approach.

Prerequisites

Before you begin, you'll need:

1 Install Wrangler CLI

First, you need to install Wrangler globally on your system:

npm install -g wrangler

Verify the installation by checking the version:

wrangler --version

2 Log In to Your Cloudflare Account

Authenticate Wrangler with your Cloudflare account:

wrangler login

This will open a browser window where you can log in to your Cloudflare account and authorize Wrangler.

3 Create a New Workers Project

Create a new directory for your project and initialize it:

mkdir text-summarizer cd text-summarizer wrangler init

When prompted, select:

4 Configure the AI Binding in wrangler.toml

Open the wrangler.toml file and add the AI binding configuration:

name = "text-summarizer" main = "src/index.js" compatibility_date = "2025-10-02" # Add AI binding [[ai]] binding = "AI"

5 Implement the Text Summarizer Code

Replace the contents of src/index.js with the Text Summarizer application code (the same code from App 1).

Note: This is the same code that's used in the dashboard version, but deployed via Wrangler CLI instead.

6 Test Your Application Locally

Before deploying, you can test your application locally:

wrangler dev

This will start a local development server, typically at http://localhost:8787. Open this URL in your browser to test your application.

Important: When testing locally, the AI binding may not work as expected since it requires access to Cloudflare's infrastructure. You might see errors related to the AI binding. This is normal during local development, but the application will work correctly when deployed to Cloudflare's network.

7 Deploy Your Application

When you're ready to deploy your application to Cloudflare's global network:

wrangler deploy

After successful deployment, Wrangler will output the URL of your deployed Worker (typically https://text-summarizer.[your-subdomain].workers.dev).

8 Modify the Model (Optional)

To switch from Mistral to DeepSeek model, edit src/index.js and find this line:

const summary = await env.AI.run("@cf/mistral/mistral-7b-instruct-v0.1", {

Replace it with:

const summary = await env.AI.run("@cf/deepseek-ai/deepseek-coder-v2-instruct", {

Then redeploy your application with wrangler deploy.