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.1.tar.gz (30.6 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.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: turboapi_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 30.6 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.1.tar.gz
Algorithm Hash digest
SHA256 a9ac15ba9bc2c57d3cdebff6d424ddcff43b3b559351e2685477130465333d11
MD5 edaa01e615045dc6a5c6a8a8722f2832
BLAKE2b-256 0684e772f95b16daf11f02e441bc6f377d40f6b0565bf4e4e4d1455d33e9558a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: turboapi_sdk-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7aac6b914650276bc4392babdfbd301d2ac38a9ae3a47611ba28ed6a0d71fc3
MD5 4e4e9e5745ecbad36bb037bbeefddd89
BLAKE2b-256 cf12c57352632e8235ca7eb668bbb3d5f889fd97fe7f191adecf847caa59bcd3

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