Skip to main content

llm-cloudflare

A plugin for the llm CLI that allows you to use the text generation models (LLMs) running on globally on Cloudflare Workers AI, including models like Llama 3.1, Mistral 7B, Gemma and a number of task-specific fine tunes.

llm-cloudflare is useful for:

  • Using and building with LLMs that may not efficiently run on your local machine (limited GPU, memory, etc) vs. having Workers AI run it on a GPU near you.
  • Validating the performance of and/or comparing multiple models.
  • Experimenting without needing to download models ahead-of-time.

Usage

Prerequisite: You'll need the llm CLI installed first.

Install and setup the plugin:

# Install the plugin from pip
llm install llm-cloudflare

# Provide a valid Workers AI token
# Docs: https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id
llm keys set cloudflare

# Set your Cloudflare account ID
# Docs: https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id
export CLOUDFLARE_ACCOUNT_ID="33charlonghexstringhere"

Use it by specifying a Workers AI model:

llm -m "@cf/meta/llama-3.1-8b-instruct" "Write a Cloudflare Worker in ESM format that returns an empty JSON object as a response. Show only the code."

You can set a Workers AI model as the default model in llm:

# Set Llama 3.1 8B as the default
llm models default "@cf/meta/llama-3.1-8b-instruct" 
# See what model is set as the default
llm models default
# @cf/meta/llama-3.1-8b-instruct

Available models

This plugin provides access to the text generation models (LLMs) provided by Workers AI.

To see what models are available, invoke llm models. Models prefixed with Cloudflare Workers AI are provided by this plugin.

The supported models are generated by scripts. New models thus rely on this plugin being updated periodically.

In the future, this plugin may also add support for Workers AI's embedding models for use with llm embed.

Credits

Credit to @hex for https://github.com/hex/llm-perplexity, which heavily inspired the design of this plugin.

License

Copyright Cloudflare, Inc (2024). Apache-2.0 licensed. See the LICENSE file for details.

Metadata

Release files for llm-cloudflare 0.5.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-cloudflare 0.5.6
File Size Uploaded
llm_cloudflare-0.5.6.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-cloudflare 0.5.6
File Interpreter ABI Platform
llm_cloudflare-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / llm_cloudflare-0.5.6.tar.gz

Download URL llm_cloudflare-0.5.6.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f60299962418ef5121e7a5d05b1a83a48c5f677e18090a5840d2c237f4dcccdd
BLAKE2b-256 checksum
How to use checksums
a00041d48a86ffdcd5f5891aab7e00d8fd9621f39d7b219b60d8c81f09dfcde8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 3, 2025.

Transparency log

Release files / llm_cloudflare-0.5.6-py3-none-any.whl

Download URL llm_cloudflare-0.5.6-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d856430d189535e9a0adc88e4ad16ee90c7683fa78aa9d4875da2db6094a943f
BLAKE2b-256 checksum
How to use checksums
b4ae445206a1f3731f2f81b7a5ac06c0c60855bd40ab4e342e20a1b4830b33f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 3, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.1

2 release files

0.3

2 release files

0.2.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page