ewest 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.
ewest-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 eWest
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ewest-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: ewest
3
+ Version: 0.1.0
4
+ Summary: Small, typed helpers for eWest's async jobs (video, music, sound): submit, wait, stream, verify webhooks.
5
+ Author-email: eWest <support@ewest.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://ewest.ai/docs
8
+ Project-URL: Documentation, https://ewest.ai/docs
9
+ Project-URL: Changelog, https://ewest.ai/changelog
10
+ Project-URL: Source, https://gitlab.com/ewest-ai/sdk
11
+ Keywords: ewest,ai,video,audio,jobs,webhooks
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # ewest (Python)
28
+
29
+ Small, typed helpers for eWest's async jobs: video, music and sound. Standard library only, Python 3.9
30
+ or newer. **Beta.** For chat, embeddings and images use the OpenAI or Anthropic SDK with base URL
31
+ `https://api.ewest.ai/v1`; see the [cookbook](../COOKBOOK.md).
32
+
33
+ ```bash
34
+ pip install ewest
35
+ export EWEST_KEY="paste your key here"
36
+ ```
37
+
38
+ ## Make a video
39
+
40
+ ```python
41
+ from ewest import Ewest
42
+
43
+ client = Ewest() # api_key defaults to $EWEST_KEY, base_url to https://api.ewest.ai
44
+ job = client.videos.generate_and_wait("ewest/veo-3.1-fast", "A red fox walks through fresh snow", duration=6)
45
+ print(job.url) # a file on cdn.ewest.ai, kept for 7 days
46
+ ```
47
+
48
+ ## Jobs
49
+
50
+ ```python
51
+ from ewest import Ewest
52
+
53
+ client = Ewest()
54
+ job = client.videos.generate("ewest/veo-3.1-fast", "Waves at dusk", duration=4, resolution="720p") # 202, queued
55
+ job = client.jobs.get(job.id)
56
+ for j in client.jobs.list(limit=5):
57
+ print(j.id, j.status)
58
+
59
+ done = client.jobs.wait(job, timeout=600, poll_interval=3) # polls; raises JobFailedError / JobTimeoutError
60
+ for update in client.jobs.stream(job): # Server-Sent Events, reconnects on its own
61
+ print(update.status, update.progress)
62
+
63
+ song = client.audio.generate_and_wait("ewest/eleven-music-v2.5", "Calm piano", duration=30, instrumental=True)
64
+ ```
65
+
66
+ `Job` has `id`, `status` (`queued`, `running`, `succeeded`, `failed`), `progress`, `eta_seconds`, `input`,
67
+ `output` (`url`, `content_type`, `duration`, `resolution`), `error` (`code`, `message`), `usage` and
68
+ `raw` (the JSON as received), plus `done`, `succeeded` and `url`.
69
+
70
+ ## Cancel a job and retry safely
71
+
72
+ ```python
73
+ job = client.videos.generate(
74
+ "ewest/veo-3.1-fast", "Gulls over a harbor",
75
+ idempotency_key="harbor-001", # the same key returns the same job, so a retry never starts (or charges) a second one
76
+ )
77
+ client.jobs.cancel(job) # only before it starts; a running job raises APIError with status 409, code job_running
78
+ ```
79
+
80
+ With an `idempotency_key`, a failed `generate` (network error, 5xx) is retried on its own, because
81
+ repeating it is safe. Keys are kept 24 hours; reusing one with a different body answers 409
82
+ `idempotency_key_reused`. `generate_and_wait` takes the same option. See
83
+ [Jobs and webhooks](https://ewest.ai/docs/jobs).
84
+
85
+ ## Errors and retries
86
+
87
+ All errors derive from `EwestError`. HTTP errors are `APIError` subclasses with `status`, `type`, `code`,
88
+ `param`, `request_id` and `headers`:
89
+
90
+ | Status | Class |
91
+ |---|---|
92
+ | 400 | `BadRequestError` (`code`: `model_not_supported`, `unsupported_value`, ...) |
93
+ | 401 | `AuthError` |
94
+ | 402 | `InsufficientBudgetError` (never retried) |
95
+ | 403 | `PermissionDeniedError` |
96
+ | 404 | `NotFoundError` |
97
+ | 429 | `RateLimitError` (`retry_after`) |
98
+ | 5xx | `ServerError` |
99
+
100
+ `JobFailedError` (a job ended `failed`), `JobTimeoutError`, `APIConnectionError` and
101
+ `WebhookVerificationError` are not HTTP errors. A 429 is retried with backoff for every call (honouring
102
+ `Retry-After`, `max_retries=2`). 5xx answers and network errors are retried for reads only, because a
103
+ failed POST may already have started a paid job (unless you send an idempotency key; see above).
104
+
105
+ ## Verify a webhook (beta)
106
+
107
+ ```python
108
+ from ewest import WebhookVerificationError, verify_webhook
109
+
110
+ def handle(raw_body: bytes, headers, secret: str):
111
+ try:
112
+ job = verify_webhook(raw_body, headers, secret) # Standard Webhooks; tolerance 300 s
113
+ except WebhookVerificationError:
114
+ return 400
115
+ print(job["id"], job["status"])
116
+ return 204
117
+ ```
118
+
119
+ The secret (`whsec_...`) is `GET /v1/webhooks/secret` for your organization. Deliveries are retried over
120
+ about 27.6 hours and can arrive twice, so dedupe on the job `id` (a redelivery gets a new `webhook-id`); see the cookbook for Flask and FastAPI.
121
+
122
+ ## Other endpoints
123
+
124
+ `client.request("GET", "/v1/models")` sends any request with the same auth, retries and typed errors
125
+ and returns the parsed JSON.
126
+
127
+ ## Versions
128
+
129
+ Semantic versioning; `0.x` is beta, so a minor version may change an API.
ewest-0.1.0/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # ewest (Python)
2
+
3
+ Small, typed helpers for eWest's async jobs: video, music and sound. Standard library only, Python 3.9
4
+ or newer. **Beta.** For chat, embeddings and images use the OpenAI or Anthropic SDK with base URL
5
+ `https://api.ewest.ai/v1`; see the [cookbook](../COOKBOOK.md).
6
+
7
+ ```bash
8
+ pip install ewest
9
+ export EWEST_KEY="paste your key here"
10
+ ```
11
+
12
+ ## Make a video
13
+
14
+ ```python
15
+ from ewest import Ewest
16
+
17
+ client = Ewest() # api_key defaults to $EWEST_KEY, base_url to https://api.ewest.ai
18
+ job = client.videos.generate_and_wait("ewest/veo-3.1-fast", "A red fox walks through fresh snow", duration=6)
19
+ print(job.url) # a file on cdn.ewest.ai, kept for 7 days
20
+ ```
21
+
22
+ ## Jobs
23
+
24
+ ```python
25
+ from ewest import Ewest
26
+
27
+ client = Ewest()
28
+ job = client.videos.generate("ewest/veo-3.1-fast", "Waves at dusk", duration=4, resolution="720p") # 202, queued
29
+ job = client.jobs.get(job.id)
30
+ for j in client.jobs.list(limit=5):
31
+ print(j.id, j.status)
32
+
33
+ done = client.jobs.wait(job, timeout=600, poll_interval=3) # polls; raises JobFailedError / JobTimeoutError
34
+ for update in client.jobs.stream(job): # Server-Sent Events, reconnects on its own
35
+ print(update.status, update.progress)
36
+
37
+ song = client.audio.generate_and_wait("ewest/eleven-music-v2.5", "Calm piano", duration=30, instrumental=True)
38
+ ```
39
+
40
+ `Job` has `id`, `status` (`queued`, `running`, `succeeded`, `failed`), `progress`, `eta_seconds`, `input`,
41
+ `output` (`url`, `content_type`, `duration`, `resolution`), `error` (`code`, `message`), `usage` and
42
+ `raw` (the JSON as received), plus `done`, `succeeded` and `url`.
43
+
44
+ ## Cancel a job and retry safely
45
+
46
+ ```python
47
+ job = client.videos.generate(
48
+ "ewest/veo-3.1-fast", "Gulls over a harbor",
49
+ idempotency_key="harbor-001", # the same key returns the same job, so a retry never starts (or charges) a second one
50
+ )
51
+ client.jobs.cancel(job) # only before it starts; a running job raises APIError with status 409, code job_running
52
+ ```
53
+
54
+ With an `idempotency_key`, a failed `generate` (network error, 5xx) is retried on its own, because
55
+ repeating it is safe. Keys are kept 24 hours; reusing one with a different body answers 409
56
+ `idempotency_key_reused`. `generate_and_wait` takes the same option. See
57
+ [Jobs and webhooks](https://ewest.ai/docs/jobs).
58
+
59
+ ## Errors and retries
60
+
61
+ All errors derive from `EwestError`. HTTP errors are `APIError` subclasses with `status`, `type`, `code`,
62
+ `param`, `request_id` and `headers`:
63
+
64
+ | Status | Class |
65
+ |---|---|
66
+ | 400 | `BadRequestError` (`code`: `model_not_supported`, `unsupported_value`, ...) |
67
+ | 401 | `AuthError` |
68
+ | 402 | `InsufficientBudgetError` (never retried) |
69
+ | 403 | `PermissionDeniedError` |
70
+ | 404 | `NotFoundError` |
71
+ | 429 | `RateLimitError` (`retry_after`) |
72
+ | 5xx | `ServerError` |
73
+
74
+ `JobFailedError` (a job ended `failed`), `JobTimeoutError`, `APIConnectionError` and
75
+ `WebhookVerificationError` are not HTTP errors. A 429 is retried with backoff for every call (honouring
76
+ `Retry-After`, `max_retries=2`). 5xx answers and network errors are retried for reads only, because a
77
+ failed POST may already have started a paid job (unless you send an idempotency key; see above).
78
+
79
+ ## Verify a webhook (beta)
80
+
81
+ ```python
82
+ from ewest import WebhookVerificationError, verify_webhook
83
+
84
+ def handle(raw_body: bytes, headers, secret: str):
85
+ try:
86
+ job = verify_webhook(raw_body, headers, secret) # Standard Webhooks; tolerance 300 s
87
+ except WebhookVerificationError:
88
+ return 400
89
+ print(job["id"], job["status"])
90
+ return 204
91
+ ```
92
+
93
+ The secret (`whsec_...`) is `GET /v1/webhooks/secret` for your organization. Deliveries are retried over
94
+ about 27.6 hours and can arrive twice, so dedupe on the job `id` (a redelivery gets a new `webhook-id`); see the cookbook for Flask and FastAPI.
95
+
96
+ ## Other endpoints
97
+
98
+ `client.request("GET", "/v1/models")` sends any request with the same auth, retries and typed errors
99
+ and returns the parsed JSON.
100
+
101
+ ## Versions
102
+
103
+ Semantic versioning; `0.x` is beta, so a minor version may change an API.
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ewest"
7
+ version = "0.1.0"
8
+ description = "Small, typed helpers for eWest's async jobs (video, music, sound): submit, wait, stream, verify webhooks."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "eWest", email = "support@ewest.ai" }]
13
+ dependencies = []
14
+ keywords = ["ewest", "ai", "video", "audio", "jobs", "webhooks"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Typing :: Typed",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://ewest.ai/docs"
30
+ Documentation = "https://ewest.ai/docs"
31
+ Changelog = "https://ewest.ai/changelog"
32
+ Source = "https://gitlab.com/ewest-ai/sdk"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+
37
+ [tool.setuptools.package-data]
38
+ ewest = ["py.typed"]
39
+
40
+ [tool.setuptools]
41
+ license-files = ["LICENSE"]
ewest-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ """eWest helpers for async jobs (video, music, sound): submit, wait, stream, verify webhooks.
2
+
3
+ For chat, embeddings and images use the OpenAI or Anthropic SDK with base URL https://api.ewest.ai/v1.
4
+ """
5
+ __version__ = "0.1.0"
6
+
7
+ from ._client import Audio, Ewest, Jobs, ThreeD, Videos
8
+ from ._errors import (
9
+ APIConnectionError,
10
+ APIError,
11
+ AuthError,
12
+ BadRequestError,
13
+ EwestError,
14
+ InsufficientBudgetError,
15
+ JobFailedError,
16
+ JobTimeoutError,
17
+ NotFoundError,
18
+ PermissionDeniedError,
19
+ RateLimitError,
20
+ ServerError,
21
+ WebhookVerificationError,
22
+ )
23
+ from ._types import Job, JobError, JobOutput
24
+ from ._webhooks import verify_webhook
25
+
26
+ __all__ = [
27
+ "APIConnectionError", "APIError", "AuthError", "Audio", "BadRequestError", "Ewest", "EwestError", "ThreeD",
28
+ "InsufficientBudgetError", "Job", "JobError", "JobFailedError", "JobOutput", "JobTimeoutError",
29
+ "Jobs", "NotFoundError", "PermissionDeniedError", "RateLimitError", "ServerError", "Videos",
30
+ "WebhookVerificationError", "verify_webhook", "__version__",
31
+ ]