Llama 2 7B Chat Hf LoRA (Cloudflare Workers AI)

This is a Llama2 base model that Cloudflare dedicated for inference with LoRA adapters. Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format.

Provider: All Meta models | Cloudflare Workers AI

API Endpoint

https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions

Quick Start (Python)

Install: pip install openai

import os

from openai import OpenAI

account_id = os.environ["CLOUDFLARE_ACCOUNT_ID"]

client = OpenAI(
    api_key=os.environ["CLOUDFLARE_API_TOKEN"],
    base_url=f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1",
)

response = client.chat.completions.create(
    model="@cf/meta-llama/llama-2-7b-chat-hf-lora",
    messages=[
        {"role": "user", "content": "Hello, how are you?"},
    ],
    max_tokens=1024,
)

print(response.choices[0].message.content)

Additional examples: Basic invoke, REST API (any task)

Supported Parameters

ParameterTypeDescription
max_tokensintegerMaximum tokens to generate. (≥1)
temperaturefloatControls randomness. Supported range varies by model. (≥0)
streambooleanStream response chunks as they are generated. Default: false.

Feature Guides

OpenAI Compatibility

Call text generation and embedding models with OpenAI-compatible client libraries using the account-scoped Workers AI base URL.

Documentation

REST API

Run any Workers AI model, including image, speech, and embedding models, through the account-scoped /ai/run endpoint.

Documentation

Model Catalog

List available models, tasks, and per-model properties with the Workers AI models search API.

Documentation