turboapi-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.10', '3.11', '3.12', '3.13']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Install dependencies
23
+ run: uv sync --dev
24
+ - name: Run tests
25
+ run: uv run pytest -q
@@ -0,0 +1,38 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Install uv
14
+ uses: astral-sh/setup-uv@v5
15
+ with:
16
+ python-version: '3.13'
17
+ - name: Install dependencies
18
+ run: uv sync --dev
19
+ - name: Run tests
20
+ run: uv run pytest -q
21
+
22
+ publish:
23
+ needs: test
24
+ runs-on: ubuntu-latest
25
+ permissions:
26
+ id-token: write
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v5
31
+ with:
32
+ python-version: '3.13'
33
+ - name: Build and publish
34
+ run: |
35
+ uv build
36
+ uv publish
37
+ env:
38
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .pytest_cache/
8
+ .venv/
9
+ venv/
10
+ .coverage
11
+ htmlcov/
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: turboapi-sdk
3
+ Version: 0.1.0
4
+ Summary: TurboAPI SDK - Call AI services through the TurboAPI platform
5
+ Project-URL: Homepage, https://turboapi.ai
6
+ Project-URL: Repository, https://github.com/turboapi/turboapi
7
+ Author: TurboAPI Team
8
+ License: MIT
9
+ Keywords: ai,api,sdk,turboapi
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: httpx<1,>=0.27
20
+ Requires-Dist: pydantic<3,>=2
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
23
+ Requires-Dist: pytest-httpx>=0.35; extra == 'dev'
24
+ Requires-Dist: pytest>=8; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # TurboAPI SDK (Python)
28
+
29
+ Python client for calling AI services through [TurboAPI](https://turboapi.ai).
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install turboapi-sdk
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ ```python
40
+ from turboapi import TurboAPIClient
41
+
42
+ client = TurboAPIClient(api_key="tbp_your_api_key_here")
43
+
44
+ # Create a task and wait for result
45
+ result = client.call.create_and_wait(
46
+ slug_id="karaoke-maker",
47
+ input={
48
+ "audio_file": "https://example.com/song.mp3",
49
+ "task_key": "my-first-task",
50
+ },
51
+ timeout=300,
52
+ )
53
+ print(f"Task completed! Output: {result.output}")
54
+
55
+ # Or manage tasks manually
56
+ task = client.call.create("some-api", {"key": "value"})
57
+ print(f"Task ID: {task.task_id}, Status: {task.status}")
58
+
59
+ # Poll for updates
60
+ updated = client.call.get(task.task_id)
61
+ if updated.status.is_terminal:
62
+ print(f"Output: {updated.output}")
63
+
64
+ # Cancel a queued task
65
+ client.call.cancel(task.task_id)
66
+
67
+ # List your recent tasks
68
+ tasks = client.tasks.list(status="succeeded", page=1, page_size=10)
69
+ for t in tasks.items:
70
+ print(f"{t.task_id}: {t.name} - {t.status}")
71
+ ```
72
+
73
+ ## API Reference
74
+
75
+ ### TurboAPIClient
76
+
77
+ ```python
78
+ TurboAPIClient(
79
+ api_key: str | None = None,
80
+ *,
81
+ base_url: str = "https://api.turboapi.ai/api/v1",
82
+ timeout: float = 30.0,
83
+ )
84
+ ```
85
+
86
+ ### Call Module (`client.call`)
87
+
88
+ | Method | Description |
89
+ |--------|-------------|
90
+ | `create(slug_id, input, *, prefer_wait=False)` | Submit a task |
91
+ | `get(task_id)` | Get task status & result |
92
+ | `cancel(task_id)` | Cancel a queued task |
93
+ | `create_and_wait(slug_id, input, *, timeout=300, poll_interval=2)` | Submit & block until complete |
94
+
95
+ ### Tasks Module (`client.tasks`)
96
+
97
+ | Method | Description |
98
+ |--------|-------------|
99
+ | `list(*, status, api_slug, page, page_size)` | List your tasks |
100
+ | `get(task_id)` | Get task detail |
101
+ | `logs(task_id, *, page, page_size)` | Get execution logs |
102
+
103
+ ## Error Handling
104
+
105
+ ```python
106
+ from turboapi import TurboAPIClient
107
+ from turboapi.errors import (
108
+ AuthenticationError,
109
+ RateLimitError,
110
+ NotFoundError,
111
+ TimeoutError,
112
+ )
113
+
114
+ client = TurboAPIClient(api_key="...")
115
+
116
+ try:
117
+ result = client.call.create_and_wait("some-api", {"key": "value"})
118
+ except AuthenticationError:
119
+ print("Check your API key")
120
+ except RateLimitError as e:
121
+ print(f"Slow down! Retry after {e.retry_after}s")
122
+ except NotFoundError:
123
+ print("Task or API not found")
124
+ except TimeoutError:
125
+ print("Task did not complete in time")
126
+ ```
127
+
128
+ ## Task Statuses
129
+
130
+ | Status | Terminal | Description |
131
+ |--------|----------|-------------|
132
+ | `pending` | No | Waiting to be queued |
133
+ | `queued` | No | In queue awaiting execution |
134
+ | `starting` | No | Worker starting up |
135
+ | `processing` | No | Execution in progress |
136
+ | `succeeded` | Yes | Completed successfully |
137
+ | `failed` | Yes | Execution failed |
138
+ | `cancelled` | Yes | Cancelled by user |
139
+ | `timeout` | Yes | Timed out |
@@ -0,0 +1,113 @@
1
+ # TurboAPI SDK (Python)
2
+
3
+ Python client for calling AI services through [TurboAPI](https://turboapi.ai).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install turboapi-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from turboapi import TurboAPIClient
15
+
16
+ client = TurboAPIClient(api_key="tbp_your_api_key_here")
17
+
18
+ # Create a task and wait for result
19
+ result = client.call.create_and_wait(
20
+ slug_id="karaoke-maker",
21
+ input={
22
+ "audio_file": "https://example.com/song.mp3",
23
+ "task_key": "my-first-task",
24
+ },
25
+ timeout=300,
26
+ )
27
+ print(f"Task completed! Output: {result.output}")
28
+
29
+ # Or manage tasks manually
30
+ task = client.call.create("some-api", {"key": "value"})
31
+ print(f"Task ID: {task.task_id}, Status: {task.status}")
32
+
33
+ # Poll for updates
34
+ updated = client.call.get(task.task_id)
35
+ if updated.status.is_terminal:
36
+ print(f"Output: {updated.output}")
37
+
38
+ # Cancel a queued task
39
+ client.call.cancel(task.task_id)
40
+
41
+ # List your recent tasks
42
+ tasks = client.tasks.list(status="succeeded", page=1, page_size=10)
43
+ for t in tasks.items:
44
+ print(f"{t.task_id}: {t.name} - {t.status}")
45
+ ```
46
+
47
+ ## API Reference
48
+
49
+ ### TurboAPIClient
50
+
51
+ ```python
52
+ TurboAPIClient(
53
+ api_key: str | None = None,
54
+ *,
55
+ base_url: str = "https://api.turboapi.ai/api/v1",
56
+ timeout: float = 30.0,
57
+ )
58
+ ```
59
+
60
+ ### Call Module (`client.call`)
61
+
62
+ | Method | Description |
63
+ |--------|-------------|
64
+ | `create(slug_id, input, *, prefer_wait=False)` | Submit a task |
65
+ | `get(task_id)` | Get task status & result |
66
+ | `cancel(task_id)` | Cancel a queued task |
67
+ | `create_and_wait(slug_id, input, *, timeout=300, poll_interval=2)` | Submit & block until complete |
68
+
69
+ ### Tasks Module (`client.tasks`)
70
+
71
+ | Method | Description |
72
+ |--------|-------------|
73
+ | `list(*, status, api_slug, page, page_size)` | List your tasks |
74
+ | `get(task_id)` | Get task detail |
75
+ | `logs(task_id, *, page, page_size)` | Get execution logs |
76
+
77
+ ## Error Handling
78
+
79
+ ```python
80
+ from turboapi import TurboAPIClient
81
+ from turboapi.errors import (
82
+ AuthenticationError,
83
+ RateLimitError,
84
+ NotFoundError,
85
+ TimeoutError,
86
+ )
87
+
88
+ client = TurboAPIClient(api_key="...")
89
+
90
+ try:
91
+ result = client.call.create_and_wait("some-api", {"key": "value"})
92
+ except AuthenticationError:
93
+ print("Check your API key")
94
+ except RateLimitError as e:
95
+ print(f"Slow down! Retry after {e.retry_after}s")
96
+ except NotFoundError:
97
+ print("Task or API not found")
98
+ except TimeoutError:
99
+ print("Task did not complete in time")
100
+ ```
101
+
102
+ ## Task Statuses
103
+
104
+ | Status | Terminal | Description |
105
+ |--------|----------|-------------|
106
+ | `pending` | No | Waiting to be queued |
107
+ | `queued` | No | In queue awaiting execution |
108
+ | `starting` | No | Worker starting up |
109
+ | `processing` | No | Execution in progress |
110
+ | `succeeded` | Yes | Completed successfully |
111
+ | `failed` | Yes | Execution failed |
112
+ | `cancelled` | Yes | Cancelled by user |
113
+ | `timeout` | Yes | Timed out |
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "turboapi-sdk"
7
+ version = "0.1.0"
8
+ description = "TurboAPI SDK - Call AI services through the TurboAPI platform"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ keywords = ["turboapi", "api", "ai", "sdk"]
13
+ authors = [
14
+ { name = "TurboAPI Team" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ ]
26
+
27
+ dependencies = [
28
+ "httpx>=0.27,<1",
29
+ "pydantic>=2,<3",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://turboapi.ai"
34
+ Repository = "https://github.com/turboapi/turboapi"
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=8",
39
+ "pytest-asyncio>=0.24",
40
+ "pytest-httpx>=0.35",
41
+ ]
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["turboapi"]
45
+
46
+ [tool.pytest.ini_options]
47
+ asyncio_mode = "auto"
48
+ testpaths = ["tests"]
49
+
50
+ [dependency-groups]
51
+ dev = [
52
+ "pytest-httpx>=0.36.2",
53
+ ]
File without changes