Skip to main content

IXSPY AI API Python SDK

IXSPY AI API V1.0 官方 Python SDK。

安装

从 PyPI 安装:

pip install ixspy-ai-api

从源码安装:

git clone https://github.com/ixspyinc/ixspy-ai-api-python.git
cd ixspy-ai-api-python
python setup.py install

基础用法

SDK 使用异步任务模式。大多数图片和视频接口会先创建任务并返回 task_id,然后通过轮询查询任务状态,直到任务完成。

import os
import sys
import time
from ixspy_ai_api import ImageClient

API_KEY = "YOUR_KEY"
FOLDER_PATH = os.path.dirname(os.path.abspath(sys.argv[0])) + os.sep
original_image_path = FOLDER_PATH + "images/speaker.jpg"

client = ImageClient(api_key=API_KEY)

task_id = client.create_custom_composition(
    original_image=original_image_path,
    prompt="移除产品背景,只保留白色背景产品图",
)
print(f"任务 ID: {task_id}")

result = client.wait_for_completion(task_id, poll_interval=3, timeout=180)
print("标清图 URL:", result["sd_image_url"])

# 高清图可能需要在任务完成后继续等待一小段处理时间。
time.sleep(30)
hd_url = client.get_hd_image(task_id)
print("高清图 URL:", hd_url)

更多示例请参考 examples 目录:

  • create_custom_composition.py:分步骤创建单图自由构图任务、轮询结果并获取高清图。
  • create_custom_composition_multi.py:分步骤创建多图自由构图任务,使用多张输入图完成组合生成。
  • create_custom_composition_text_only.py:创建无参考图自由构图任务,仅通过文字描述生成图片。
  • image_generate.py:使用 ImageClient.generate() 一步式创建图片任务并等待完成。
  • video_generate.py:使用参考图创建图片生成视频任务,并查询已完成视频任务列表。
  • video_generate_text_only.py:创建纯文字生成视频任务,无需输入图片。
  • chat_generate.py:创建对话生成任务,演示文字对话和图文识别用法。

任务生命周期

图片和视频生成接口都基于任务执行:

  1. 创建任务,例如调用 create_custom_composition() 或 create_video()。
  2. API 返回 task_id。
  3. 使用 get_task_status() 或 get_video_status() 查询任务状态。
  4. 等待任务状态变为 completed。
  5. 读取结果字段,例如 sd_image_url、hd_image_url 或 video_url。

常见任务状态:

  • queued:任务已提交,正在等待执行。
  • processing:任务正在生成中。
  • completed:任务已成功完成,结果 URL 可用。
  • error:任务执行失败。

便捷轮询方法:

  • ImageClient.wait_for_completion(task_id, poll_interval=3, timeout=180)
  • VideoClient.wait_for_video_completion(task_id, poll_interval=15, timeout=600)

如果任务失败或轮询超时,SDK 会抛出 APIError。

API 文档

https://img.ixspy.com/api-doc.html

Metadata

Release files for ixspy-ai-api 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ixspy-ai-api 1.1.3
File Size Uploaded
ixspy_ai_api-1.1.3.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ixspy-ai-api 1.1.3
File Interpreter ABI Platform
ixspy_ai_api-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / ixspy_ai_api-1.1.3.tar.gz

Download URL ixspy_ai_api-1.1.3.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ec49f0f98766a163d3f25fbeb1e3d13ba09ea5caa19da3112f6c6f6d81b53016
BLAKE2b-256 checksum
How to use checksums
735f819a93147ac72e496ae68b4bedd9c8a17cf344cada573906ba62e7b829e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / ixspy_ai_api-1.1.3-py3-none-any.whl

Download URL ixspy_ai_api-1.1.3-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ef2bea9ef646ceb32f60156a2633ef2157d0420ca1afafc06440b8c101fda04
BLAKE2b-256 checksum
How to use checksums
d0e39fa1ffc2030a4ce00022c026eec8ee1088f5557b539b561b562e7393d3e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.5

2 release files

1.1.4

2 release files

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page