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 cloudflareai

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.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

cloudflareai-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file cloudflareai-0.2.0.tar.gz.

File metadata

  • Download URL: cloudflareai-0.2.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for cloudflareai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1c77d86f576446bb8b662961d281ab9dd55d1c83c12f47fffc7c5930f69c3d51
MD5 7e401b3bbace804d037ba4cc2ffca06d
BLAKE2b-256 ffcac1433f28188db47ed3687fc73c9bec08e4312e76aa3fb0e07c1858e52aa4

See more details on using hashes here.

File details

Details for the file cloudflareai-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudflareai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 025838c8460ba7f716d047c3b9cbb712a02621e154fb005f5f85353507d0873a
MD5 08575fc53449a92e3e84f932292399ed
BLAKE2b-256 10da1bca2673a610284aad907177e4a285ddf4374bb60eefcc2518785438198b

See more details on using hashes here.

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