runapi-gpt-image 0.2.2__tar.gz → 0.3.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.
@@ -1,18 +1,18 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: runapi-gpt-image
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: RunAPI GPT Image SDK for text-to-image and image editing workflows in JavaScript, Python, Ruby, Go, Java, and PHP
5
5
  Project-URL: Homepage, https://runapi.ai/models/gpt-image
6
6
  Project-URL: Documentation, https://runapi.ai/docs/resources/sdks
7
7
  Project-URL: Source, https://github.com/runapi-ai/gpt-image-sdk
8
8
  Project-URL: Issues, https://github.com/runapi-ai/gpt-image-sdk/issues
9
9
  Project-URL: Changelog, https://github.com/runapi-ai/gpt-image-sdk/blob/main/CHANGELOG.md
10
- Project-URL: Release Notes, https://github.com/runapi-ai/gpt-image-sdk/releases/tag/python%2Fv0.2.2
10
+ Project-URL: Release Notes, https://github.com/runapi-ai/gpt-image-sdk/releases/tag/python%2Fv0.3.0
11
11
  Author-email: RunAPI <contact@runapi.ai>
12
12
  License-Expression: Apache-2.0
13
13
  Keywords: api,golang,gpt-image,gpt-image-api,gradle,image-api,image-generation,java,maven,python,ruby,runapi,runapi-ai,sdk,text-to-image,typescript
14
14
  Requires-Python: >=3.9
15
- Requires-Dist: runapi-core>=0.3.3
15
+ Requires-Dist: runapi-core~=0.10.0
16
16
  Description-Content-Type: text/markdown
17
17
 
18
18
  # GPT Image Python SDK for RunAPI
@@ -4,14 +4,14 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "runapi-gpt-image"
7
- version = "0.2.2"
7
+ version = "0.3.0"
8
8
  description = "RunAPI GPT Image SDK for text-to-image and image editing workflows in JavaScript, Python, Ruby, Go, Java, and PHP"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
11
  license = "Apache-2.0"
12
12
  authors = [{ name = "RunAPI", email = "contact@runapi.ai" }]
13
13
  keywords = ["runapi", "runapi-ai", "gpt-image", "api", "sdk", "typescript", "python", "ruby", "golang", "java", "maven", "gradle", "image-generation", "text-to-image", "image-api", "gpt-image-api"]
14
- dependencies = ["runapi-core>=0.3.3"]
14
+ dependencies = ["runapi-core~=0.10.0"]
15
15
 
16
16
  [project.urls]
17
17
  Homepage = "https://runapi.ai/models/gpt-image"
@@ -19,7 +19,7 @@ Documentation = "https://runapi.ai/docs/resources/sdks"
19
19
  Source = "https://github.com/runapi-ai/gpt-image-sdk"
20
20
  Issues = "https://github.com/runapi-ai/gpt-image-sdk/issues"
21
21
  Changelog = "https://github.com/runapi-ai/gpt-image-sdk/blob/main/CHANGELOG.md"
22
- "Release Notes" = "https://github.com/runapi-ai/gpt-image-sdk/releases/tag/python%2Fv0.2.2"
22
+ "Release Notes" = "https://github.com/runapi-ai/gpt-image-sdk/releases/tag/python%2Fv0.3.0"
23
23
 
24
24
  [tool.hatch.build.targets.wheel]
25
25
  packages = ["src/runapi"]
@@ -6,7 +6,6 @@ from typing import Any, Optional
6
6
 
7
7
  from runapi.core import Resource, RequestOptions
8
8
 
9
- from ..contract_gen import CONTRACT
10
9
  from ..types import (
11
10
  CompletedEditImageResponse,
12
11
  EditImageResponse,
@@ -43,7 +42,6 @@ class EditImage(Resource):
43
42
  The task creation result with an id.
44
43
  """
45
44
  compacted = self._compact_params(params)
46
- self._validate_contract(CONTRACT["edit-image"], compacted)
47
45
  return self._request("post", self.ENDPOINT, body=compacted, options=options)
48
46
 
49
47
  def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
@@ -6,7 +6,6 @@ from typing import Any, Optional
6
6
 
7
7
  from runapi.core import Resource, RequestOptions
8
8
 
9
- from ..contract_gen import CONTRACT
10
9
  from ..types import (
11
10
  CompletedTextToImageResponse,
12
11
  TextToImageResponse,
@@ -43,7 +42,6 @@ class TextToImage(Resource):
43
42
  The task creation result with an id.
44
43
  """
45
44
  compacted = self._compact_params(params)
46
- self._validate_contract(CONTRACT["text-to-image"], compacted)
47
45
  return self._request("post", self.ENDPOINT, body=compacted, options=options)
48
46
 
49
47
  def get(self, id: str, options: Optional[RequestOptions] = None) -> Any:
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
3
  from runapi.core import config
4
- from runapi.core.errors import AuthenticationError, ValidationError
4
+ from runapi.core.errors import AuthenticationError
5
5
  from runapi.gpt_image import GptImageClient
6
6
  from runapi.gpt_image.resources.edit_image import EditImage
7
7
  from runapi.gpt_image.resources.text_to_image import TextToImage
@@ -83,8 +83,7 @@ def test_text_to_image_create_posts_compacted_body():
83
83
  "post",
84
84
  "/api/v1/gpt_image/text_to_image",
85
85
  {"model": "gpt-image-1.5", "prompt": "hello world", "aspect_ratio": "1:1", "quality": "high"},
86
- ),
87
- ]
86
+ )]
88
87
  assert isinstance(result, TextToImageResponse)
89
88
  assert result.task_replayed is True
90
89
 
@@ -115,10 +114,8 @@ def test_edit_image_create_posts_compacted_body():
115
114
  "prompt": "oil painting",
116
115
  "source_image_urls": ["https://runapi.ai/a.jpg"],
117
116
  "aspect_ratio": "2:3",
118
- "quality": "medium",
119
- },
120
- ),
121
- ]
117
+ "quality": "medium"},
118
+ )]
122
119
  assert isinstance(result, TextToImageResponse)
123
120
 
124
121
 
@@ -132,7 +129,7 @@ def test_edit_image_get_fetches_by_id():
132
129
  def test_run_narrows_completed_type():
133
130
  fake = FakeHttp(
134
131
  {"id": "t1", "status": "pending"},
135
- {"id": "t1", "status": "completed", "images": [{"url": "https://x/y.png"}]},
132
+ {"id": "t1", "status": "completed", "usage": {"cost": 0.05}, "images": [{"url": "https://x/y.png"}]},
136
133
  )
137
134
  client = GptImageClient(api_key="k", http_client=fake)
138
135
  result = client.text_to_image.run(
@@ -140,60 +137,3 @@ def test_run_narrows_completed_type():
140
137
  )
141
138
  assert isinstance(result, CompletedTextToImageResponse)
142
139
  assert result.images[0].url == "https://x/y.png"
143
-
144
-
145
- # --- validation -----------------------------------------------------------
146
-
147
-
148
- def test_requires_model():
149
- client = GptImageClient(api_key="k", http_client=FakeHttp())
150
- with pytest.raises(ValidationError, match="model must be one of: gpt-image-1.5"):
151
- client.text_to_image.create(prompt="hi there")
152
-
153
-
154
- def test_requires_prompt():
155
- client = GptImageClient(api_key="k", http_client=FakeHttp())
156
- with pytest.raises(ValidationError, match="prompt is required"):
157
- client.text_to_image.create(model="gpt-image-1.5", aspect_ratio="1:1", quality="high")
158
-
159
-
160
- def test_rejects_unknown_model():
161
- client = GptImageClient(api_key="k", http_client=FakeHttp())
162
- with pytest.raises(ValidationError, match="model must be one of: gpt-image-1.5"):
163
- client.text_to_image.create(model="nope", prompt="hi there")
164
-
165
-
166
- def test_requires_aspect_ratio():
167
- client = GptImageClient(api_key="k", http_client=FakeHttp())
168
- with pytest.raises(ValidationError, match="aspect_ratio is required"):
169
- client.text_to_image.create(model="gpt-image-1.5", prompt="hi there", quality="high")
170
-
171
-
172
- def test_rejects_invalid_aspect_ratio():
173
- client = GptImageClient(api_key="k", http_client=FakeHttp())
174
- with pytest.raises(ValidationError, match="aspect_ratio must be one of: 1:1, 2:3, 3:2"):
175
- client.text_to_image.create(
176
- model="gpt-image-1.5", prompt="hi there", aspect_ratio="9:16", quality="high"
177
- )
178
-
179
-
180
- def test_requires_quality():
181
- client = GptImageClient(api_key="k", http_client=FakeHttp())
182
- with pytest.raises(ValidationError, match="quality is required"):
183
- client.text_to_image.create(model="gpt-image-1.5", prompt="hi there", aspect_ratio="1:1")
184
-
185
-
186
- def test_rejects_invalid_quality():
187
- client = GptImageClient(api_key="k", http_client=FakeHttp())
188
- with pytest.raises(ValidationError, match="quality must be one of: medium, high"):
189
- client.text_to_image.create(
190
- model="gpt-image-1.5", prompt="hi there", aspect_ratio="1:1", quality="low"
191
- )
192
-
193
-
194
- def test_edit_requires_source_image_urls():
195
- client = GptImageClient(api_key="k", http_client=FakeHttp())
196
- with pytest.raises(ValidationError, match="source_image_urls is required"):
197
- client.edit_image.create(
198
- model="gpt-image-1.5", prompt="make it pop", aspect_ratio="1:1", quality="high"
199
- )
@@ -1,41 +0,0 @@
1
- CONTRACT = {
2
- "edit-image": {
3
- "models": ["gpt-image-1.5"],
4
- "fields_by_model": {
5
- "gpt-image-1.5": {
6
- "aspect_ratio": {
7
- "enum": ["1:1", "2:3", "3:2"],
8
- "required": True
9
- },
10
- "prompt": {
11
- "required": True
12
- },
13
- "quality": {
14
- "enum": ["medium", "high"],
15
- "required": True
16
- },
17
- "source_image_urls": {
18
- "required": True
19
- }
20
- }
21
- }
22
- },
23
- "text-to-image": {
24
- "models": ["gpt-image-1.5"],
25
- "fields_by_model": {
26
- "gpt-image-1.5": {
27
- "aspect_ratio": {
28
- "enum": ["1:1", "2:3", "3:2"],
29
- "required": True
30
- },
31
- "prompt": {
32
- "required": True
33
- },
34
- "quality": {
35
- "enum": ["medium", "high"],
36
- "required": True
37
- }
38
- }
39
- }
40
- }
41
- }