Metadata-Version: 2.4
Name: swarmauri_llm_cloudflare
Version: 0.11.0.dev2
Summary: Swarmauri chat and tool-calling adapters for Cloudflare Workers AI.
License-Expression: Apache-2.0
Keywords: swarmauri,llm,cloudflare,workers ai,tool calling,streaming,openai compatible
Author: Jacob Stewart
Author-email: jacob@swarmauri.com
Requires-Python: >=3.10,<3.13
Classifier: Development Status :: 1 - Planning
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: swarmauri_base (>=0.11.0.dev5)
Requires-Dist: swarmauri_core (>=0.11.0.dev5)
Requires-Dist: swarmauri_standard (>=0.11.0.dev6)
Requires-Dist: swarmauri_transport_httpx (>=0.1.0.dev5)
Requires-Dist: swarmauri_transport_retry (>=0.1.0.dev1)
Description-Content-Type: text/markdown

![Swarmauri](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)

<p align="center">
  <a href="https://pepy.tech/project/swarmauri_llm_cloudflare"><img src="https://static.pepy.tech/badge/swarmauri_llm_cloudflare/month" alt="Downloads"></a>
  <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_llm_cloudflare/"><img src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_llm_cloudflare.svg" alt="Hits"></a>
  <a href="https://pypi.org/project/swarmauri_llm_cloudflare/"><img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue" alt="Python"></a>
  <a href="https://pypi.org/project/swarmauri_llm_cloudflare/"><img src="https://img.shields.io/pypi/l/swarmauri_llm_cloudflare" alt="License"></a>
  <a href="https://pypi.org/project/swarmauri_llm_cloudflare/"><img src="https://img.shields.io/pypi/v/swarmauri_llm_cloudflare" alt="Release"></a>
</p>

# Swarmauri Cloudflare Workers AI LLM

`swarmauri_llm_cloudflare` connects Swarmauri conversations and toolkits to Cloudflare Workers AI's account-scoped REST API.

## Features

- OpenAI-compatible chat completions through `CloudflareWorkersAIModel`.
- Tool calling through `CloudflareWorkersAIToolModel` for models that advertise tool support.
- Synchronous, asynchronous, incremental streaming, and batch workflows.
- Optional discovery from Cloudflare's model-search endpoint.
- Explicit account ID and API-token configuration.
- Persistent, injectable Swarmauri HTTP clients with conservative rate-limit retries.

## Installation

```bash
uv add swarmauri_llm_cloudflare
```

```bash
pip install swarmauri_llm_cloudflare
```

## Usage

```python
import os

from swarmauri_llm_cloudflare import CloudflareWorkersAIModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation(messages=[HumanMessage(content="Explain edge inference.")])
model = CloudflareWorkersAIModel(
    account_id=os.environ["CLOUDFLARE_ACCOUNT_ID"],
    api_key=os.environ["CLOUDFLARE_API_TOKEN"],
    name="@cf/meta/llama-3.3-70b-instruct-fp8-fast",
)
model.predict(conversation)
print(conversation.get_last().content)
```

Set `discover_models=True` to query the current Workers AI model catalog. For tools, instantiate `CloudflareWorkersAIToolModel` with a tool-capable model and pass a Swarmauri `Toolkit`.

Pass an `IHttpClient` as `http_client` to integrate a custom transport or to test without network access. Pass an `IHttpRetryPolicy` as `retry_policy` to replace the default policy, which retries safe reads and rate-limited chat submissions without replaying failed POST requests for generic server errors.

See the [Cloudflare Workers AI REST guide](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) and [model-search API](https://developers.cloudflare.com/api/resources/ai/subresources/models/methods/list/) for account setup and current model details.

