Skip to main content

Cloudflare AI Python SDK

Project description

Cloudflare AI Python Wrapper

This is an Async Python wrapper for the Cloudflare AI API. It is a work in progress and is not yet ready for production use. This does not include all of the Cloudflare AI API endpoints. If you would like to add more, please open a pull request.

If you have any updates or suggestions, please open an issue or pull request. :)

Installation

pip install cloudflare-ai

Usage

import asyncio

from CloudflareAI import CloudflareAI, AiTextToImageModels, AiTextGenerationModels, AiImageClassificationModels


async def main():
    ai = CloudflareAI(
        Cloudflare_API_Key=<Your Token>,
        Cloudflare_Account_Identifier=<Account ID>,
    )
    image = await ai.ImageClassification(
        image_path="image.jpg", model_name=AiImageClassificationModels.RESNET_50
    )

    text = await ai.TextGeneration(
        prompt="You are helpful",
        system_prompt="Hello, my name is Alex",
        model_name=AiTextGenerationModels.CODE_LLAMA_7B,
    )
    image = await ai.TextToImage(prompt="a Cat", model_name=AiTextToImageModels.XL_BASE)

asyncio.run(main())

License

Mozilla Public License Version 2.0 (MPL-2.0) - See LICENSE for more information.

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

cloudflareai-0.1.0.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distribution

cloudflareai-0.1.0-py3-none-any.whl (10.9 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