redfox-python-sdk 0.4.0__py3-none-any.whl → 0.5.1__py3-none-any.whl

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.
redfox/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from .client import RedFoxClient, AsyncRedFoxClient
4
4
  from .exceptions import RedFoxAPIError, RedFoxAuthError, RedFoxRateLimitError
5
5
 
6
- __version__ = "0.4.0"
6
+ __version__ = "0.5.1"
7
7
  __all__ = [
8
8
  "RedFoxClient",
9
9
  "AsyncRedFoxClient",
@@ -7,71 +7,66 @@ class GPTImageAPI:
7
7
  """
8
8
  GPT 图片生成工具 API 集合
9
9
 
10
- 支持文生图和图生图,基于 image2-GPT 模型。
10
+ 基于 gpt-image-2 模型,支持文生图和参考图生图(最多 2 张参考图)。
11
+ 异步执行:submit() 返回 taskId,再轮询 result() 取 imageUrls。
11
12
  """
12
13
 
14
+ # 服务端支持的输出分辨率档位
15
+ RESOLUTIONS = ("1k", "2k", "4k")
16
+
17
+ # 服务端支持的输出宽高比
18
+ SIZES = (
19
+ "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5",
20
+ "16:9", "9:16", "2:1", "1:2", "21:9", "9:21",
21
+ )
22
+
23
+ # result() 的 status 取值,仅后两者为终态
24
+ TERMINAL_STATUSES = ("completed", "failed")
25
+
13
26
  def __init__(self, client):
14
27
  self._client = client
15
28
 
16
29
  def submit(
17
30
  self,
18
31
  prompt: str,
32
+ resolution: str = "1k",
33
+ size: str = "1:1",
19
34
  n: int = 1,
20
- size: str = "1024x1024",
21
- quality: str = "medium",
22
- background: str = "auto",
23
- output_format: str = "png",
24
- output_compression: int = None,
25
- model_name: str = "gpt-image-2",
26
- operation: str = "generate",
27
- input_fidelity: str = None,
28
- images: List[Dict[str, str]] = None,
35
+ reference_images: Optional[List[str]] = None,
29
36
  ) -> dict:
30
37
  """
31
- 提交 GPT 图片生成任务
38
+ 提交 GPT-Image-2 图片生成任务
32
39
 
33
- :param prompt: 图片生成提示词(必填)
34
- :param n: 生成数量,1~10
35
- :param size: 图片尺寸,如 "1024x1024"
36
- :param quality: 质量,支持 low/medium/high/auto
37
- :param background: 背景类型,支持 transparent/opaque/auto
38
- :param output_format: 输出格式,支持 png/jpeg/webp
39
- :param output_compression: 输出压缩比,0~100
40
- :param model_name: 模型名称,默认 gpt-image-2
41
- :param operation: 操作类型,generate(文生图)/ edit(图生图)
42
- :param input_fidelity: 输入图保真度,编辑模式(operation=edit)支持 high/low
43
- :param images: 图片编辑输入图列表,operation=edit 时必填
40
+ :param prompt: 图片生成提示词,描述期望的生成效果(必填)
41
+ :param resolution: 输出分辨率档位,支持 1k/2k/4k
42
+ :param size: 输出图片宽高比,支持 1:1、3:2、2:3、4:3、3:4、5:4、4:5、
43
+ 16:9、9:16、2:1、1:2、21:9、9:21
44
+ :param n: 生成图片数量,最大 4(超限服务端报 1002)
45
+ :param reference_images: 参考图片 URL 列表,最多 2 张,用于图生图场景;
46
+ 不传则为纯文生图。URL 需公网可访问
44
47
  :return: 包含 taskId 的字典
45
48
  """
46
- parameters: Dict[str, Any] = {
47
- "modelName": model_name,
48
- "n": n,
49
- "size": size,
50
- "quality": quality,
51
- "background": background,
52
- "outputFormat": output_format,
53
- }
54
- if output_compression is not None:
55
- parameters["outputCompression"] = output_compression
56
- if input_fidelity is not None:
57
- parameters["inputFidelity"] = input_fidelity
58
-
59
49
  data: Dict[str, Any] = {
60
50
  "prompt": prompt,
61
- "operation": operation,
62
- "parameters": parameters,
51
+ "resolution": resolution,
52
+ "size": size,
53
+ "n": n,
63
54
  }
64
- if images is not None:
65
- data["images"] = images
66
- return self._client.post("/story/api/parseWork/imageGen/submitSkill", data=data)
55
+ if reference_images:
56
+ data["referenceImages"] = reference_images
57
+ return self._client.post(
58
+ "/story/api/parseWork/imageGen/gptImage2Submit", data=data
59
+ )
67
60
 
68
61
  def result(self, task_id: str) -> dict:
69
62
  """
70
- 查询 GPT 图片生成任务结果
63
+ 查询 GPT-Image-2 图片生成任务结果
71
64
 
72
65
  :param task_id: 任务 ID(由 submit 接口返回)
73
- :return: 任务结果字典,包含 status/imagePaths/failReason
66
+ :return: 任务结果字典,包含 status/progress/imageUrls/failReason/
67
+ model/resolution/size。status 取值 queued/in_progress/completed/
68
+ failed,仅 completed 与 failed 为终态;imageUrls 数量与 n 一致
74
69
  """
75
70
  return self._client.post(
76
- "/story/api/parseWork/imageGen/result", data={"taskId": task_id}
71
+ "/story/api/parseWork/imageGen/gptImage2Result", data={"taskId": task_id}
77
72
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: redfox-python-sdk
3
- Version: 0.4.0
3
+ Version: 0.5.1
4
4
  Summary: RedFox 红狐数据平台 Python SDK — 同步+异步双客户端,自动重试,零配置
5
5
  Home-page: https://redfox.hk
6
6
  Author: RedFox
@@ -574,26 +574,26 @@ result = client.ai_search.baidu_result(task_id=task["taskId"])
574
574
  # 文生图
575
575
  task = client.gpt_image.submit(
576
576
  prompt="一只坐在窗台上的橘猫,阳光洒在毛发上",
577
- size="1024x1024",
578
- quality="medium",
579
- output_format="png",
580
- model_name="gpt-image-2",
581
- operation="generate",
577
+ resolution="1k", # 1k / 2k / 4k
578
+ size="1:1", # 宽高比,支持 1:1、16:9、9:16 等 13 种
579
+ n=1, # 生成数量,最多 4 张
582
580
  )
583
581
  result = client.gpt_image.result(task_id=task["taskId"])
582
+ print(result["status"], result["imageUrls"])
584
583
 
585
584
  # 图生图/编辑
586
585
  task = client.gpt_image.submit(
587
586
  prompt="将背景替换成海滩",
588
- size="1024x1024",
589
- model_name="gpt-image-2",
590
- operation="edit",
591
- input_fidelity=5,
592
- images=[{"url": "https://example.com/your-image.jpg"}],
587
+ resolution="2k",
588
+ size="16:9",
589
+ n=2,
590
+ reference_images=["https://example.com/your-image.jpg"], # 参考图 URL,最多 2 张
593
591
  )
594
592
  result = client.gpt_image.result(task_id=task["taskId"])
595
593
  ```
596
594
 
595
+ > **注意**:`status` 实测取值 `queued`/`in_progress`/`completed`/`failed`,仅后两者为终态(接口文档所写的 `processing` 实测不会返回)。
596
+
597
597
  ### 豆包图片生成
598
598
 
599
599
  ```python
@@ -1,4 +1,4 @@
1
- redfox/__init__.py,sha256=TleNyciu9dQNyKsb4rx7MUewI609aES_KHCSawuKba4,348
1
+ redfox/__init__.py,sha256=FaOD5sO3A8cOEx6eToaOVPQBGxc5iH5iF3wRqRXd-DI,348
2
2
  redfox/client.py,sha256=-1OqZHljQW0Cs7agpto32iCDBOnp2E7nUrnAvbUXgmE,20860
3
3
  redfox/exceptions.py,sha256=QWosa7FXJbxNPenMx1CRIPj7z8SFmmtg2_8Qjzika1E,668
4
4
  redfox/endpoints/__init__.py,sha256=sjtHfb6bkX_wdd_ryRajkPrBRnno2HMiwys0DcNIqSA,19
@@ -9,7 +9,7 @@ redfox/endpoints/dongchedi.py,sha256=TyNgWefKAChPZ8S61Ea2falpZnGhvdbSRd1K408qa7g
9
9
  redfox/endpoints/doubao_image.py,sha256=7ZY9jsy8CMNQ98oGArNnqz7-6csnY85yDgEcsT2FSUQ,4344
10
10
  redfox/endpoints/doubao_video.py,sha256=iQHEfj7ilTp8lFYbZWFt50y2-KjTncio0GFiV3P_4VU,2767
11
11
  redfox/endpoints/douyin.py,sha256=ysOvvRpfHDVmzZIoDw5FywHLOd_ypeAJJINsOPtRr3E,13265
12
- redfox/endpoints/gpt_image.py,sha256=GocecNEip9yJN8udlAKojhb_JLPwgJxq5CZi-KiZYIg,2669
12
+ redfox/endpoints/gpt_image.py,sha256=lUB_0Nog3T7DCLo6jxNfpLe7WgsAIE7F7xFBxhTFIlc,2573
13
13
  redfox/endpoints/hotspot.py,sha256=AaKrRCTgsq7456I1R89lrRMR680Md9WZGCbzPYS9Uhk,2748
14
14
  redfox/endpoints/instagram.py,sha256=HMJROgW3fHj6jLueB6uGjjiugEUEiU538T9xY6cJ6Ek,2626
15
15
  redfox/endpoints/kuaishou.py,sha256=kvMkcJ9G_kKFjzNy0y0hcfMhxRlqpZAK7kFvGm9t2Ew,4248
@@ -22,7 +22,7 @@ redfox/endpoints/wechat_channels.py,sha256=mQ-67-mROwegas3v0ziEowHswUkkfWP3xRSSI
22
22
  redfox/endpoints/xiaohongshu.py,sha256=PzHBvcXMXGLJiAPIG87jfnF8DYj0iLdHLOTfLG_wrko,11707
23
23
  redfox/endpoints/yiche.py,sha256=FmxbnWq0up4Tq9pZNYCG0uswgJOy3fGUnJfEQ6eS-9Q,2446
24
24
  redfox/endpoints/youtube.py,sha256=NUW8Sw7Hcmu04VzSb7XPyV9ZnAPU-RllFQC3Zc_Ksqk,3696
25
- redfox_python_sdk-0.4.0.dist-info/METADATA,sha256=kTSjB88gwh0ffR4HiK9mFmwI2MBghEY5b2UJfEnHdro,23052
26
- redfox_python_sdk-0.4.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
- redfox_python_sdk-0.4.0.dist-info/top_level.txt,sha256=cOIfFv-M-TaEjpiRQy-OygdvvuHeZrlQSoRWMj0DaEM,7
28
- redfox_python_sdk-0.4.0.dist-info/RECORD,,
25
+ redfox_python_sdk-0.5.1.dist-info/METADATA,sha256=9RBzIG-v6BucHCpvlkck5INKqR0OWcbxEuY2tO488o4,23288
26
+ redfox_python_sdk-0.5.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
+ redfox_python_sdk-0.5.1.dist-info/top_level.txt,sha256=cOIfFv-M-TaEjpiRQy-OygdvvuHeZrlQSoRWMj0DaEM,7
28
+ redfox_python_sdk-0.5.1.dist-info/RECORD,,