wavespeed 0.0.3__tar.gz → 0.0.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wavespeed
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Python client for WaveSpeed AI
5
5
  Author: WaveSpeed AI
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wavespeed"
7
- version = "0.0.3"
7
+ version = "0.0.4"
8
8
  description = "Python client for WaveSpeed AI"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -11,28 +11,29 @@ class WaveSpeed:
11
11
  A client for interacting with the Wavespeed AI API.
12
12
  """
13
13
 
14
- BASE_URL = "https://api.wavespeed.ai/api/v2/"
15
-
16
- def __init__(self, api_key: str):
14
+ def __init__(self, api_key: str="", base_url: str = "https://api.wavespeed.ai/api/v2/", timeout: int | None = None):
17
15
  """
18
- Initialize the Wavespeed client.
16
+ Initialize the WaveSpeed client.
19
17
 
20
18
  Args:
21
- api_key: Your Wavespeed API key
19
+ api_key: Your WaveSpeed API key
20
+ base_url: Base URL for the API
21
+ timeout: Timeout in seconds for http client send request
22
22
  """
23
23
  self.api_key = api_key
24
- if not api_key:
25
- api_key = os.environ.get("WAVESPEED_API_KEY", '')
26
- if not api_key:
24
+ if not self.api_key:
25
+ self.api_key = os.environ.get("WAVESPEED_API_KEY", '')
26
+ if not self.api_key:
27
27
  raise ValueError("API key is required.")
28
28
  self.headers = {
29
29
  "Content-Type": "application/json",
30
- "Authorization": f"Bearer {api_key}"
30
+ "Authorization": f"Bearer {self.api_key}"
31
31
  }
32
- self.async_client = httpx.AsyncClient(headers=self.headers)
33
- self.client = httpx.Client(headers=self.headers)
34
- self.poll_interval = float(os.environ.get("WAVESPEED_POLL_INTERVAL", 1)) # seconds
35
- self.timeout = int(os.environ.get("WAVESPEED_TIMEOUT", 60)) # seconds
32
+ self.async_client = httpx.AsyncClient(headers=self.headers, timeout=timeout)
33
+ self.client = httpx.Client(headers=self.headers, timeout=timeout)
34
+ self.base_url = base_url
35
+ self.timeout = timeout
36
+ self.poll_interval = float(os.environ.get("WAVESPEED_POLL_INTERVAL", 1))
36
37
 
37
38
  async def async_run(
38
39
  self,
@@ -51,7 +52,7 @@ class WaveSpeed:
51
52
  Returns:
52
53
  The API response as a dictionary
53
54
  """
54
- url = urljoin(self.BASE_URL, modelId)
55
+ url = urljoin(self.base_url, modelId)
55
56
 
56
57
  payload = input
57
58
 
@@ -63,7 +64,6 @@ class WaveSpeed:
63
64
  url,
64
65
  headers=self.headers,
65
66
  json=payload,
66
- timeout=self.timeout
67
67
  )
68
68
 
69
69
  # Raise an exception for HTTP errors
@@ -90,7 +90,7 @@ class WaveSpeed:
90
90
  Returns:
91
91
  The API response as a dictionary
92
92
  """
93
- url = urljoin(self.BASE_URL, modelId)
93
+ url = urljoin(self.base_url, modelId)
94
94
 
95
95
  payload = input
96
96
 
@@ -98,7 +98,6 @@ class WaveSpeed:
98
98
  url,
99
99
  headers=self.headers,
100
100
  json=payload,
101
- timeout=self.timeout
102
101
  )
103
102
 
104
103
  # Raise an exception for HTTP errors
@@ -109,13 +108,12 @@ class WaveSpeed:
109
108
  return prediction.wait()
110
109
 
111
110
  async def async_create(self, modelId: str, input: Dict[str, Any], **kwargs) -> Prediction:
112
- url = urljoin(self.BASE_URL, modelId)
111
+ url = urljoin(self.base_url, modelId)
113
112
  payload = input
114
113
  response = await self.async_client.post(
115
114
  url,
116
115
  headers=self.headers,
117
116
  json=payload,
118
- timeout=self.timeout
119
117
  )
120
118
  # Raise an exception for HTTP errors
121
119
  response.raise_for_status()
@@ -125,13 +123,12 @@ class WaveSpeed:
125
123
  return prediction
126
124
 
127
125
  def create(self, modelId: str, input: Dict[str, Any], **kwargs) -> Prediction:
128
- url = urljoin(self.BASE_URL, modelId)
126
+ url = urljoin(self.base_url, modelId)
129
127
  payload = input
130
128
  response = self.client.post(
131
129
  url,
132
130
  headers=self.headers,
133
131
  json=payload,
134
- timeout=self.timeout
135
132
  )
136
133
  # Raise an exception for HTTP errors
137
134
  response.raise_for_status()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wavespeed
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Python client for WaveSpeed AI
5
5
  Author: WaveSpeed AI
6
6
  License: MIT License
File without changes
File without changes
File without changes