Skip to main content

TurboAPI SDK - Call AI services through the TurboAPI platform

Project description

TurboAPI SDK (Python)

Python client for calling AI services through TurboAPI.

Installation

pip install turboapi-sdk

Quick Start

from turboapi import TurboAPIClient

client = TurboAPIClient(api_key="tbp_your_api_key_here")

# Create a task and wait for result
result = client.call.create_and_wait(
    slug_id="karaoke-maker",
    input={
        "audio_file": "https://example.com/song.mp3",
        "task_key": "my-first-task",
    },
    timeout=300,
)
print(f"Task completed! Output: {result.output}")

# Or manage tasks manually
task = client.call.create("some-api", {"key": "value"})
print(f"Task ID: {task.task_id}, Status: {task.status}")

# Poll for updates
updated = client.call.get(task.task_id)
if updated.status.is_terminal:
    print(f"Output: {updated.output}")

# Cancel a queued task
client.call.cancel(task.task_id)

# List your recent tasks
tasks = client.tasks.list(status="succeeded", page=1, page_size=10)
for t in tasks.items:
    print(f"{t.task_id}: {t.name} - {t.status}")

API Reference

TurboAPIClient

TurboAPIClient(
    api_key: str | None = None,
    *,
    base_url: str = "https://api.turboapi.ai/api/v1",
    timeout: float = 30.0,
)

Call Module (client.call)

Method Description
create(slug_id, input, *, prefer_wait=False) Submit a task
get(task_id) Get task status & result
cancel(task_id) Cancel a queued task
create_and_wait(slug_id, input, *, timeout=300, poll_interval=2) Submit & block until complete

Tasks Module (client.tasks)

Method Description
list(*, status, api_slug, page, page_size) List your tasks
get(task_id) Get task detail
logs(task_id, *, page, page_size) Get execution logs

Error Handling

from turboapi import TurboAPIClient
from turboapi.errors import (
    AuthenticationError,
    RateLimitError,
    NotFoundError,
    TimeoutError,
)

client = TurboAPIClient(api_key="...")

try:
    result = client.call.create_and_wait("some-api", {"key": "value"})
except AuthenticationError:
    print("Check your API key")
except RateLimitError as e:
    print(f"Slow down! Retry after {e.retry_after}s")
except NotFoundError:
    print("Task or API not found")
except TimeoutError:
    print("Task did not complete in time")

Task Statuses

Status Terminal Description
pending No Waiting to be queued
queued No In queue awaiting execution
starting No Worker starting up
processing No Execution in progress
succeeded Yes Completed successfully
failed Yes Execution failed
cancelled Yes Cancelled by user
timeout Yes Timed out

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

turboapi_sdk-0.1.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

turboapi_sdk-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file turboapi_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: turboapi_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for turboapi_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96bdf88435069bc9b95853fc6e9d55597c179eb66601a00533c27b1f28ee901b
MD5 79f08942eeb8bb96da0b813d023d424c
BLAKE2b-256 64c82cad6fb6f065465e116f7db6b6bda3d48da9e938138321efa334c56c2fc0

See more details on using hashes here.

File details

Details for the file turboapi_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: turboapi_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for turboapi_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96a1542e9abc021eea8d56be5d2f3b925d8423fd76352f164853739b6014b94d
MD5 ef9e81cfee7f433dffb2fe34f66f8697
BLAKE2b-256 20c12842519db06c3e35ab20ce1e5eea1c071302b78cfc112e0ee1b26e68dacf

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