redfox-python-sdk 0.4.0__py3-none-any.whl → 0.5.0__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.0"
7
7
  __all__ = [
8
8
  "RedFoxClient",
9
9
  "AsyncRedFoxClient",
@@ -7,71 +7,71 @@ class GPTImageAPI:
7
7
  """
8
8
  GPT 图片生成工具 API 集合
9
9
 
10
- 支持文生图和图生图,基于 image2-GPT 模型。
10
+ 基于 gpt-image-2 模型,支持文生图和参考图生图(最多 2 张参考图)。
11
+ 异步执行:submit() 返回 taskId,再轮询 result() 取 imageUrls。
12
+
13
+ 注意:result() 返回的图片 URL 有效期仅数分钟,过期后访问返回 404,
14
+ 需立即下载保存;用平台生成图做参考图时也必须在其失效前提交。
11
15
  """
12
16
 
17
+ # 服务端支持的输出分辨率档位
18
+ RESOLUTIONS = ("1k", "2k", "4k")
19
+
20
+ # 服务端支持的输出宽高比
21
+ SIZES = (
22
+ "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5",
23
+ "16:9", "9:16", "2:1", "1:2", "21:9", "9:21",
24
+ )
25
+
26
+ # result() 的 status 取值,仅后两者为终态
27
+ TERMINAL_STATUSES = ("completed", "failed")
28
+
13
29
  def __init__(self, client):
14
30
  self._client = client
15
31
 
16
32
  def submit(
17
33
  self,
18
34
  prompt: str,
35
+ resolution: str = "1k",
36
+ size: str = "1:1",
19
37
  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,
38
+ reference_images: Optional[List[str]] = None,
29
39
  ) -> dict:
30
40
  """
31
- 提交 GPT 图片生成任务
41
+ 提交 GPT-Image-2 图片生成任务
32
42
 
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 时必填
43
+ :param prompt: 图片生成提示词,描述期望的生成效果(必填)
44
+ :param resolution: 输出分辨率档位,支持 1k/2k/4k
45
+ :param size: 输出图片宽高比,支持 1:1、3:2、2:3、4:3、3:4、5:4、4:5、
46
+ 16:9、9:16、2:1、1:2、21:9、9:21
47
+ :param n: 生成图片数量,最大 4(超限服务端报 1002)
48
+ :param reference_images: 参考图片 URL 列表,最多 2 张,用于图生图场景;
49
+ 不传则为纯文生图。URL 必须公网可访问且未过期,
50
+ 否则任务会以 failed 结束
44
51
  :return: 包含 taskId 的字典
45
52
  """
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
53
  data: Dict[str, Any] = {
60
54
  "prompt": prompt,
61
- "operation": operation,
62
- "parameters": parameters,
55
+ "resolution": resolution,
56
+ "size": size,
57
+ "n": n,
63
58
  }
64
- if images is not None:
65
- data["images"] = images
66
- return self._client.post("/story/api/parseWork/imageGen/submitSkill", data=data)
59
+ if reference_images:
60
+ data["referenceImages"] = reference_images
61
+ return self._client.post(
62
+ "/story/api/parseWork/imageGen/gptImage2Submit", data=data
63
+ )
67
64
 
68
65
  def result(self, task_id: str) -> dict:
69
66
  """
70
- 查询 GPT 图片生成任务结果
67
+ 查询 GPT-Image-2 图片生成任务结果
71
68
 
72
69
  :param task_id: 任务 ID(由 submit 接口返回)
73
- :return: 任务结果字典,包含 status/imagePaths/failReason
70
+ :return: 任务结果字典,包含 status/progress/imageUrls/failReason/
71
+ model/resolution/size。status 取值 queued/in_progress/completed/
72
+ failed,仅 completed 与 failed 为终态;imageUrls 数量与 n 一致,
73
+ 但有效期仅数分钟,需立即下载保存
74
74
  """
75
75
  return self._client.post(
76
- "/story/api/parseWork/imageGen/result", data={"taskId": task_id}
76
+ "/story/api/parseWork/imageGen/gptImage2Result", data={"taskId": task_id}
77
77
  )
@@ -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.0
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
+ > **注意**:`result()` 返回的 `imageUrls` 有效期仅数分钟,过期即 404,请立即下载保存;`status` 实测取值 `queued`/`in_progress`/`completed`/`failed`,仅后两者为终态。用平台生成图作参考图时,必须在其失效前提交。
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=VLRAAqSDCQDLe8tWvRUJl9e_j92D8yMCUP3sETy3HG8,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=VteYrVrpa2ElBnrwSluWjevnbKHV3qgFf_Jzvurbwh0,2917
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.0.dist-info/METADATA,sha256=HvPMEahotBwVWy75S3d2ottG0n9f60tT_BC4K2L2k54,23392
26
+ redfox_python_sdk-0.5.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
+ redfox_python_sdk-0.5.0.dist-info/top_level.txt,sha256=cOIfFv-M-TaEjpiRQy-OygdvvuHeZrlQSoRWMj0DaEM,7
28
+ redfox_python_sdk-0.5.0.dist-info/RECORD,,