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 目录。

任务生命周期

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

  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.2

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.2
File Size Uploaded
ixspy_ai_api-1.1.2.tar.gz 11.0 kB Details

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / ixspy_ai_api-1.1.2.tar.gz

Download URL ixspy_ai_api-1.1.2.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
625e59579471eec1c43993a11303f40e63dbbf2161fec03f29ade9c56d03a36b
BLAKE2b-256 checksum
How to use checksums
b04796cb9cdc9227fc3b16e5970e6c360bb5e6fe80c06ded98d31c8bf1c15d83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

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

Download URL ixspy_ai_api-1.1.2-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d003d1582726cd711db0fb930478f527bdb1293613a46079be3c7b7c84269df0
BLAKE2b-256 checksum
How to use checksums
2aa891c74a2ba91d0ed613042e70699173e05346c4b4ea95a1834260bf3bd1b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 23, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

This release

1.1.2 This release

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