Skip to main content

The Official Python Library for the ShuttleAI API

Build, Lint, Format pypi Downloads Downloads/Month Python Versions

The ShuttleAI Python library provides easy access to the ShuttleAI REST API for Python 3.9+ applications. It includes type definitions for all request parameters and response fields, offering both synchronous and asynchronous clients powered by httpx and aiohttp, respectively.

We prioritize performance optimizations across the library. Beyond using orjson for near-instant JSON processing, we implement various techniques to reduce overhead and enhance speed, ensuring efficient and swift API interactions. These optimizations include minimizing built-in library usage, leveraging reusable aiohttp client sessions, and incorporating several small adjustments to streamline operations.

Installation

pip install shuttleai

We recommend using --upgrade or -U to ensure you have the latest version of the library.

From Source

This client uses poetry as a dependency and virtual environment manager.

You can install poetry with

pip install poetry

poetry will set up a virtual environment and install dependencies with the following command:

poetry install

Getting Started

Below is a non-streamed sync and async example for the ShuttleAI API. You can find more examples in the examples/ directory.

Synchronous Client

from shuttleai import ShuttleAI

shuttleai = ShuttleAI()

response = shuttleai.chat.completions.create(
    model="shuttle-3",
    messages=[{"role": "user", "content": "What day is today?"}],
    internet=False
)

print(chunk.choices[0].message.content)

Asynchronous Client

import asyncio
from shuttleai import AsyncShuttleAI

async def main():
    shuttleai = AsyncShuttleAI()

    response = await shuttleai.chat.completions.create(
        model="shuttle-3",
        messages=[{"role": "user", "content": "Imagine an AI like no other, its name is ShuttleAI."}],
    )

    print(response.choices[0].message.content)

asyncio.run(main())

ShuttleAI CLI

Scroll down to the Scripts section for more information.

Run examples

You can run the examples in the examples/ directory using poetry run or by entering the virtual environment using poetry shell.

Using poetry run

cd examples
poetry run python chat_no_streaming.py

Using poetry shell

poetry shell
cd examples

>> python chat_no_streaming.py

API Key Setup

To use the ShuttleAI API, you need to have an API key. You can get a FREE API key by signing up at shuttleai.com and heading to the key management page.

After you have an API key, you can set it as an environment variable:

Windows

setx SHUTTLEAI_API_KEY "<your_api_key>"

[!Note] This will only work in the current terminal session. To set it permanently, you can use the setx command with the /m flag.

setx SHUTTLEAI_API_KEY "<your_api_key>" /m

macOS/Linux

export SHUTTLEAI_API_KEY=<your_api_key>

Contribution

We welcome and appreciate contributions to the ShuttleAI API Python SDK. Please see the contribution guide for more information. Benefits may apply! :smile:

Scripts

Formatting/Checks

  • poetry run ruff check shuttleai - Check ruff
  • poetry run black shuttleai --diff --color - Check black
  • poetry run black shuttleai - Format code
  • poetry run mypy shuttleai - Check for type errors

Tools

  • poetry run clean - Clean up the project directory
  • poetry run key - Display your default API key (if set by environment variable)
  • poetry run contr - Display contributors

ShuttleAI CLI

  • poetry run shuttleai or shuttleai - Run the ShuttleAI CLI. Example of Chatbot Example response of Chatbot

[!Important] We support auto TAB completion of commands and model names! Just press TAB! Example of TAB of Chatbot

Metadata

Release files for shuttleai 4.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shuttleai 4.9.3
File Size Uploaded
shuttleai-4.9.3.tar.gz 696.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shuttleai 4.9.3
File Interpreter ABI Platform
shuttleai-4.9.3-py3-none-any.whl Python 3 none any Details

Total release size: 735.0 kB

Release files / shuttleai-4.9.3.tar.gz

Download URL shuttleai-4.9.3.tar.gz
Size 696.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0fbc6a398ba9b1a1690b44b75edd8ecdd35dc9ebf66fd50dfbd7f1ae56cb4392
BLAKE2b-256 checksum
How to use checksums
d3abfb123552f89737ae7e7db73452f24bba8a61e8f4599240526ff71524981e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / shuttleai-4.9.3-py3-none-any.whl

Download URL shuttleai-4.9.3-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e14c7e049577ac0d78e7c224c694da77e72bad3854ced6fda88500149449cc2
BLAKE2b-256 checksum
How to use checksums
75ce8a6fdf7e58bd6bd02f1b0fabfd4d434b09c499319f64ee2cb4e9e2feb1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

4.9.3 This release

2 release files

4.9.1

2 release files

4.9.0

2 release files

4.8.1

2 release files

4.8.0

2 release files

4.7.3

2 release files

4.7.2

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.2

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.7

2 release files

4.5.6

2 release files

4.4.4

2 release files

4.2.3

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.9

2 release files

4.1.8

2 release files

4.1.7

2 release files

4.1.6

2 release files

4.1.5

2 release files

4.1.4

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.9

2 release files

4.0.8

2 release files

4.0.7

2 release files

4.0.5

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.9.6

1 release file

3.9.4

1 release file

3.9.0

1 release file

3.8.9

1 release file

3.8.8

1 release file

3.8.6

1 release file

3.8.5

1 release file

3.8.4

1 release file

3.8.3

1 release file

3.8.2

1 release file

3.8.1

1 release file

3.8

1 release file

3.7

1 release file

3.6

1 release file

3.5

1 release file

3.4

1 release file

3.3

1 release file

3.2

1 release file

3.1

1 release file

3

1 release file

2

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.8

2 release files

0.7

2 release files

0.6

1 release file

0.5

1 release file

0.4

1 release file

0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page