Skip to main content

Access Shuttle AI's API via a simple and user-friendly lib. Dashboard: https://shuttleai.app Discord: https://discord.gg/shuttleai

Project description

The official Python library for the ShuttleAI API

Access the ShuttleAI API with a simple, user-friendly lib.

PRs appreciated 🙂

Installation

ShuttleAI

pip install shuttleai

ShuttleAI CLI

pip install shuttleai[cli]

Usage

ShuttleAI CLI

shuttleai-cli --help

ShuttleAI

[!IMPORTANT] It is strongly recommended to use the asynchronous client instead of the synchronous client.

import asyncio
from shuttleai import *

SHUTTLE_KEY = "ShuttleAPI Key"

async def main():
    async with ShuttleAsyncClient(SHUTTLE_KEY, timeout=60) as shuttle:
        """Optionally change base url"""
        # shuttle.base_url = "https://api.shuttleai.app/v1"

        """Get Models Example"""
        # response = await shuttle.get_models()
        # print(response)
        """Get Model Example"""
        # response = await shuttle.get_model("gpt-4")
        # print(response)
        """Streaming Example"""
        # response = await shuttle.chat_completion(
        #     model="gpt-3.5-turbo",
        #     messages="write me a short story about bees",
        #     stream=True,
        #     plain=True,
        #     internet=False
        # )
        # async for chunk in response:
        #     print(chunk.choices[0].delta.content)
        """Non-Streaming Example"""
        # response = await shuttle.chat_completion(
        #     model="gpt-3.5-turbo",
        #     messages=[{"role":"user","content":"write me a short story about bees"}],
        #     stream=False,
        #     plain=False,
        #     internet=False,
        #     max_tokens=100,
        #     temperature=0.5,
        #     image="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
        # )
        # print(response)
        """Image Generation Example"""
        # response = await shuttle.images_generations(
        #     model='sdxl',
        #     prompt='a cute cat',
        #     n=1,
        # )
        # print(response)
        """Audio Generation Example"""
        # response = await shuttle.audio_generations(
        #     model='eleven-labs-999',
        #     input='Once upon a time, there was a cute cat wondering through a dark, cold forest.',
        #     voice="mimi"
        # )
        # print(response)
        """Audio Transcription Example"""
        # response = await shuttle.audio_transcriptions(
        #     model='whisper-large',
        #     file="test.mp3"
        # )
        # print(response)
        """Moderation Example"""
        # response = await shuttle.moderations(
        #     model='text-moderation-latest',
        #     input="I hate you"
        # )
        # print(response)
        """Embeddings Example"""
        # response = await shuttle.embeddings(
        #     model='text-embedding-ada-002',
        #     input="Hello there world"
        # )
        # print(response)


if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

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

shuttleai-3.5.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file shuttleai-3.5.tar.gz.

File metadata

  • Download URL: shuttleai-3.5.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for shuttleai-3.5.tar.gz
Algorithm Hash digest
SHA256 180212331cf0fe86e7d661fb2993d2cc34d8a25b18ce0bd5119084afedc69669
MD5 1ce68a8045496b5ac7d1d5b96c55ac23
BLAKE2b-256 167d709dc5c29ed8fd7fd571b83431ddb63b0abdc54bccc0b7a6168685020fc2

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