redfox-python-sdk 0.4.0__tar.gz → 0.5.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.
Files changed (34) hide show
  1. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/PKG-INFO +11 -11
  2. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/README.md +10 -10
  3. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/__init__.py +1 -1
  4. redfox_python_sdk-0.5.0/redfox/endpoints/gpt_image.py +77 -0
  5. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox_python_sdk.egg-info/PKG-INFO +11 -11
  6. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/setup.py +1 -1
  7. redfox_python_sdk-0.4.0/redfox/endpoints/gpt_image.py +0 -77
  8. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/client.py +0 -0
  9. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/__init__.py +0 -0
  10. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/ai_search.py +0 -0
  11. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/autohome.py +0 -0
  12. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/bilibili.py +0 -0
  13. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/dongchedi.py +0 -0
  14. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/doubao_image.py +0 -0
  15. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/doubao_video.py +0 -0
  16. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/douyin.py +0 -0
  17. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/hotspot.py +0 -0
  18. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/instagram.py +0 -0
  19. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/kuaishou.py +0 -0
  20. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/tiktok.py +0 -0
  21. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/tools.py +0 -0
  22. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/toutiao.py +0 -0
  23. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/twitter.py +0 -0
  24. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/wechat.py +0 -0
  25. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/wechat_channels.py +0 -0
  26. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/xiaohongshu.py +0 -0
  27. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/yiche.py +0 -0
  28. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/endpoints/youtube.py +0 -0
  29. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox/exceptions.py +0 -0
  30. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox_python_sdk.egg-info/SOURCES.txt +0 -0
  31. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox_python_sdk.egg-info/dependency_links.txt +0 -0
  32. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox_python_sdk.egg-info/requires.txt +0 -0
  33. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/redfox_python_sdk.egg-info/top_level.txt +0 -0
  34. {redfox_python_sdk-0.4.0 → redfox_python_sdk-0.5.0}/setup.cfg +0 -0
@@ -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
@@ -550,26 +550,26 @@ result = client.ai_search.baidu_result(task_id=task["taskId"])
550
550
  # 文生图
551
551
  task = client.gpt_image.submit(
552
552
  prompt="一只坐在窗台上的橘猫,阳光洒在毛发上",
553
- size="1024x1024",
554
- quality="medium",
555
- output_format="png",
556
- model_name="gpt-image-2",
557
- operation="generate",
553
+ resolution="1k", # 1k / 2k / 4k
554
+ size="1:1", # 宽高比,支持 1:1、16:9、9:16 等 13 种
555
+ n=1, # 生成数量,最多 4 张
558
556
  )
559
557
  result = client.gpt_image.result(task_id=task["taskId"])
558
+ print(result["status"], result["imageUrls"])
560
559
 
561
560
  # 图生图/编辑
562
561
  task = client.gpt_image.submit(
563
562
  prompt="将背景替换成海滩",
564
- size="1024x1024",
565
- model_name="gpt-image-2",
566
- operation="edit",
567
- input_fidelity=5,
568
- images=[{"url": "https://example.com/your-image.jpg"}],
563
+ resolution="2k",
564
+ size="16:9",
565
+ n=2,
566
+ reference_images=["https://example.com/your-image.jpg"], # 参考图 URL,最多 2 张
569
567
  )
570
568
  result = client.gpt_image.result(task_id=task["taskId"])
571
569
  ```
572
570
 
571
+ > **注意**:`result()` 返回的 `imageUrls` 有效期仅数分钟,过期即 404,请立即下载保存;`status` 实测取值 `queued`/`in_progress`/`completed`/`failed`,仅后两者为终态。用平台生成图作参考图时,必须在其失效前提交。
572
+
573
573
  ### 豆包图片生成
574
574
 
575
575
  ```python
@@ -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",
@@ -0,0 +1,77 @@
1
+ """GPT 图片生成工具 API 端点"""
2
+
3
+ from typing import Optional, Dict, Any, List
4
+
5
+
6
+ class GPTImageAPI:
7
+ """
8
+ GPT 图片生成工具 API 集合
9
+
10
+ 基于 gpt-image-2 模型,支持文生图和参考图生图(最多 2 张参考图)。
11
+ 异步执行:submit() 返回 taskId,再轮询 result() 取 imageUrls。
12
+
13
+ 注意:result() 返回的图片 URL 有效期仅数分钟,过期后访问返回 404,
14
+ 需立即下载保存;用平台生成图做参考图时也必须在其失效前提交。
15
+ """
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
+
29
+ def __init__(self, client):
30
+ self._client = client
31
+
32
+ def submit(
33
+ self,
34
+ prompt: str,
35
+ resolution: str = "1k",
36
+ size: str = "1:1",
37
+ n: int = 1,
38
+ reference_images: Optional[List[str]] = None,
39
+ ) -> dict:
40
+ """
41
+ 提交 GPT-Image-2 图片生成任务
42
+
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 结束
51
+ :return: 包含 taskId 的字典
52
+ """
53
+ data: Dict[str, Any] = {
54
+ "prompt": prompt,
55
+ "resolution": resolution,
56
+ "size": size,
57
+ "n": n,
58
+ }
59
+ if reference_images:
60
+ data["referenceImages"] = reference_images
61
+ return self._client.post(
62
+ "/story/api/parseWork/imageGen/gptImage2Submit", data=data
63
+ )
64
+
65
+ def result(self, task_id: str) -> dict:
66
+ """
67
+ 查询 GPT-Image-2 图片生成任务结果
68
+
69
+ :param task_id: 任务 ID(由 submit 接口返回)
70
+ :return: 任务结果字典,包含 status/progress/imageUrls/failReason/
71
+ model/resolution/size。status 取值 queued/in_progress/completed/
72
+ failed,仅 completed 与 failed 为终态;imageUrls 数量与 n 一致,
73
+ 但有效期仅数分钟,需立即下载保存
74
+ """
75
+ return self._client.post(
76
+ "/story/api/parseWork/imageGen/gptImage2Result", data={"taskId": task_id}
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
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="redfox-python-sdk",
5
- version="0.4.0",
5
+ version="0.5.0",
6
6
  description="RedFox 红狐数据平台 Python SDK — 同步+异步双客户端,自动重试,零配置",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
@@ -1,77 +0,0 @@
1
- """GPT 图片生成工具 API 端点"""
2
-
3
- from typing import Optional, Dict, Any, List
4
-
5
-
6
- class GPTImageAPI:
7
- """
8
- GPT 图片生成工具 API 集合
9
-
10
- 支持文生图和图生图,基于 image2-GPT 模型。
11
- """
12
-
13
- def __init__(self, client):
14
- self._client = client
15
-
16
- def submit(
17
- self,
18
- prompt: str,
19
- 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,
29
- ) -> dict:
30
- """
31
- 提交 GPT 图片生成任务
32
-
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 时必填
44
- :return: 包含 taskId 的字典
45
- """
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
- data: Dict[str, Any] = {
60
- "prompt": prompt,
61
- "operation": operation,
62
- "parameters": parameters,
63
- }
64
- if images is not None:
65
- data["images"] = images
66
- return self._client.post("/story/api/parseWork/imageGen/submitSkill", data=data)
67
-
68
- def result(self, task_id: str) -> dict:
69
- """
70
- 查询 GPT 图片生成任务结果
71
-
72
- :param task_id: 任务 ID(由 submit 接口返回)
73
- :return: 任务结果字典,包含 status/imagePaths/failReason
74
- """
75
- return self._client.post(
76
- "/story/api/parseWork/imageGen/result", data={"taskId": task_id}
77
- )