Skip to main content

An LLM CLI plugin for Cloudflare Workers AI models.

Project description

cloudflare-llm

A plugin for the llm CLI that allows you to use the text generation models (LLMs) running on globally on Cloudflare Workers AI.

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_cloudflare-0.2.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

llm_cloudflare-0.2.1-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page