cloudflareai


Namecloudflareai JSON
Version 0.9.0 PyPI version JSON
download
home_pagehttps://github.com/alexraskin/cloudflareai-py
SummaryCloudflare AI Python SDK
upload_time2024-02-08 04:01:06
maintainer
docs_urlNone
authoralexraskin
requires_python
licenseMozilla Public License 2.0
keywords module cloudflare library package python cloudflareai
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cloudflare AI Python Wrapper

This Python library provides a convenient way to interact with the Cloudflare AI API asynchronously, allowing you to leverage the power of Cloudflare's AI models in your applications. With this wrapper, you can easily integrate AI-driven features into your projects without the hassle of handling API requests and responses manually.

## Installation

Install from PyPI:

```bash
pip install cloudflareai
```

Install from Github:

```bash
python -m pip install -U git+https://github.com/alexraskin/cloudflareai-py
```

Or build from source:

```bash
git clone
cd cloudflareai
python setup.py install
```

## Usage

Import the CloudflareAI class and the desired model enums. Then, create an instance of the CloudflareAI class with your Cloudflare API key and account identifier. You can then use the instance to call the desired AI model.

```python
import asyncio

from cloudflareai import (
    CloudflareAI,
    AiTextToImageModels,
    AiTextGenerationModels,
    AiImageClassificationModels,
)


async def main():
    ai = CloudflareAI(
        Cloudflare_API_Key=<Your Token>,
        Cloudflare_Account_Identifier=<Account ID>,
    )

    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
    )
    print(text.text) # returns string
    print(image.image) # returns bytes

    ### Also get status codes
    print(text.status_code)
    print(image.status_code)

asyncio.run(main())
```

## Models

This wrapper also includes enums for AI models, making it easier to select the desired model for your tasks. Available enums include:

- AiImageClassificationModels
- AiTranslationModels
- AiTextGenerationModels
- AiSpeechRecognitionModels
- AiTextToImageModels
- TranslationLanguages

## Contributing

If you'd like to contribute to this project, please follow these steps:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Submit a pull request with a clear description of your changes.

## License

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alexraskin/cloudflareai-py",
    "name": "cloudflareai",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "module,Cloudflare,library,package,python,CloudflareAI",
    "author": "alexraskin",
    "author_email": "<root@alexraskin.com>",
    "download_url": "https://files.pythonhosted.org/packages/f3/f6/924b6b09617220583763d0e02550cd3ccc82257a6fc331f1a6532015c77c/cloudflareai-0.9.0.tar.gz",
    "platform": null,
    "description": "# Cloudflare AI Python Wrapper\n\nThis Python library provides a convenient way to interact with the Cloudflare AI API asynchronously, allowing you to leverage the power of Cloudflare's AI models in your applications. With this wrapper, you can easily integrate AI-driven features into your projects without the hassle of handling API requests and responses manually.\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install cloudflareai\n```\n\nInstall from Github:\n\n```bash\npython -m pip install -U git+https://github.com/alexraskin/cloudflareai-py\n```\n\nOr build from source:\n\n```bash\ngit clone\ncd cloudflareai\npython setup.py install\n```\n\n## Usage\n\nImport the CloudflareAI class and the desired model enums. Then, create an instance of the CloudflareAI class with your Cloudflare API key and account identifier. You can then use the instance to call the desired AI model.\n\n```python\nimport asyncio\n\nfrom cloudflareai import (\n    CloudflareAI,\n    AiTextToImageModels,\n    AiTextGenerationModels,\n    AiImageClassificationModels,\n)\n\n\nasync def main():\n    ai = CloudflareAI(\n        Cloudflare_API_Key=<Your Token>,\n        Cloudflare_Account_Identifier=<Account ID>,\n    )\n\n    text = await ai.TextGeneration(\n        prompt=\"You are helpful\",\n        system_prompt=\"Hello, my name is Alex\",\n        model_name=AiTextGenerationModels.CODE_LLAMA_7B,\n    )\n    image = await ai.TextToImage(\n      prompt=\"a Cat\",\n      model_name=AiTextToImageModels.XL_BASE\n    )\n    print(text.text) # returns string\n    print(image.image) # returns bytes\n\n    ### Also get status codes\n    print(text.status_code)\n    print(image.status_code)\n\nasyncio.run(main())\n```\n\n## Models\n\nThis wrapper also includes enums for AI models, making it easier to select the desired model for your tasks. Available enums include:\n\n- AiImageClassificationModels\n- AiTranslationModels\n- AiTextGenerationModels\n- AiSpeechRecognitionModels\n- AiTextToImageModels\n- TranslationLanguages\n\n## Contributing\n\nIf you'd like to contribute to this project, please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request with a clear description of your changes.\n\n## License\n\nMozilla Public License Version 2.0 (MPL-2.0) - See LICENSE for more information.\n",
    "bugtrack_url": null,
    "license": "Mozilla Public License 2.0",
    "summary": "Cloudflare AI Python SDK",
    "version": "0.9.0",
    "project_urls": {
        "Homepage": "https://github.com/alexraskin/cloudflareai-py"
    },
    "split_keywords": [
        "module",
        "cloudflare",
        "library",
        "package",
        "python",
        "cloudflareai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d240f8bfd7b0d2762c5de3bd48c04a006d1d097e8e276f04a17f0d6c1fdf682",
                "md5": "97fe4a91c876347a3c07cc1982c7b21a",
                "sha256": "79b37ea514f8478f32b0f71e991f82f38413acb1667af67b9c77169751eff444"
            },
            "downloads": -1,
            "filename": "cloudflareai-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97fe4a91c876347a3c07cc1982c7b21a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14614,
            "upload_time": "2024-02-08T04:01:04",
            "upload_time_iso_8601": "2024-02-08T04:01:04.158558Z",
            "url": "https://files.pythonhosted.org/packages/2d/24/0f8bfd7b0d2762c5de3bd48c04a006d1d097e8e276f04a17f0d6c1fdf682/cloudflareai-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3f6924b6b09617220583763d0e02550cd3ccc82257a6fc331f1a6532015c77c",
                "md5": "0da0efe336c96b98fc2da85869803f1b",
                "sha256": "30ca44ad645bc91cc79a511b3ab2fa810539504b8fcf0c1260412648844d9528"
            },
            "downloads": -1,
            "filename": "cloudflareai-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0da0efe336c96b98fc2da85869803f1b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13006,
            "upload_time": "2024-02-08T04:01:06",
            "upload_time_iso_8601": "2024-02-08T04:01:06.360885Z",
            "url": "https://files.pythonhosted.org/packages/f3/f6/924b6b09617220583763d0e02550cd3ccc82257a6fc331f1a6532015c77c/cloudflareai-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 04:01:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alexraskin",
    "github_project": "cloudflareai-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "httpx",
            "specs": []
        }
    ],
    "lcname": "cloudflareai"
}
        
Elapsed time: 0.20255s