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

Uploaded Source

Built Distribution

cloudflareai-0.3.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cloudflareai-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f47e9478b0d9cff2158d00ed47a40b402fd614c1c28e84c727009f4672838495
MD5 2a7e76ad137e9b6b7c88f0bc4cbe3a9f
BLAKE2b-256 9572c29c22f884ae2145efb7c4ea27368f89776e61f735fdb5fdb83e78ed294c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cloudflareai-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c683355647b1a2de10a1619d4d7198a2ba1e6f518c95fe1fb318804719c6a3a4
MD5 ad7b90c86c478d4db874a577a2573606
BLAKE2b-256 7473c70fc9bad8b1bc829296b7b9aab93ac5b7673a8171030906f8de2117ac43

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