Skip to main content

A library meant to be a wrapper for the CablyAI service.

Project description

cablyai

A simple Python client for interacting with the CablyAI API, allowing you to easily make requests for text, image, audio generation, and moderation.

Installation

To install the package, you can clone the repository using git and install it using pip:

git clone https://github.com/acattoXD/cablyai.git
cd cablyai
pip install .

Or, you install it using the pypi library.

pip install cablyai

Usage

Here’s a basic example of how to use the CablyAI client:

from cablyai import CablyAI

# Initialize the client with your API key
client = CablyAI("YOUR_API_KEY")

# Example: Chat request
response = client.chat.completions.create(
    model="MODEL_NAME",
    messages=[
        {"role": "user", "content": "Hello!"},
        {"role": "assistant", "content": "Hello! How can I assist you today?"}
    ]
)
print("Chat Response:", response.choices[0].message.content)

# Example: Image generation request
image_response = client.images.generate(
    prompt="A sunset over the mountains.",
    n=1,
    size="1024x1024",
    response_format="url",
    model="MODEL_NAME"
)
print("Image Response:", image_response.data[0].url)


# Example: Text-to-speech request
from pathlib import Path

speech_file_path = Path(__file__).parent / "speech.mp3"
audio_response = client.audio.speech.create(
    model="tts-1",
    voice="alloy",
    input="Today is a wonderful day to build something people love!"
)
audio_response.stream_to_file(speech_file_path)
print(f"Speech saved to {speech_file_path}")

# Example: Content moderation request
moderation_response = client.moderations.create(
    model="omni-moderation-latest",
    input="I hate you"
)
print("Moderation Response:", moderation_response)

API Methods

client.chat.completions.create(model: str, messages: list)

  • Description: Sends a chat prompt to the CablyAI API and returns the response.
  • Parameters:
    • model: The model to use for the chat.
    • messages: A list of messages in the conversation.

client.images.generate(prompt: str, n: int = 1, size: str = "1024x1024", response_format: str = "url", model: str)

  • Description: Generates an image based on the provided prompt.
  • Parameters:
    • prompt: The prompt for the image.
    • n: The number of images to generate (default is 1).
    • size: The size of the generated image (default is "1024x1024").
    • response_format: Format of the response (default is "url").
    • model: The model to use for image generation.

client.audio.speech.create(model: str, voice: str, input: str)

  • Description: Generates speech from the provided text input.
  • Parameters:
    • model: The model to use for text-to-speech conversion.
    • voice: The voice to use for the generated speech.
    • input: The text input to convert to speech.

client.moderations.create(model: str, input)

  • Description: Checks the content moderation for the provided input, which can be text or a combination of text and images.
  • Parameters:
    • model: The moderation model to use.
    • input: The input to moderate, can be text or a list containing both text and images.

License

This project is licensed under the ISC License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Author

acatto

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

cablyai-0.0.4.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cablyai-0.0.4.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file cablyai-0.0.4.3.tar.gz.

File metadata

  • Download URL: cablyai-0.0.4.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for cablyai-0.0.4.3.tar.gz
Algorithm Hash digest
SHA256 d57fa7f01f87df2ccc8839f6c4f2aee0574517d9897b63d542443f13392204bc
MD5 308dd8e75dca575212c7d52f6bb2bf08
BLAKE2b-256 4374c6fff653768f38fe9510b21d2f77c75a634360fda5e35d7810d20d95b258

See more details on using hashes here.

File details

Details for the file cablyai-0.0.4.3-py3-none-any.whl.

File metadata

  • Download URL: cablyai-0.0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for cablyai-0.0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cee98686da428ce1abccaee1653a830e720c09bf3d4ca76e35fe890a9b6c8c81
MD5 4e3fcc946efe25e5b9bff5afb3c70e86
BLAKE2b-256 fa6a3d6dc35442a6ecdb89d3723f0782e13dee5a86c9d74ed7bdae1366ba1b29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page