A client of IXSPY AI Api
Project description
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()或create_video()。 - API 返回
task_id。 - 使用
get_task_status()或get_video_status()查询任务状态。 - 等待任务状态变为
completed。 - 读取结果字段,例如
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 文档
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ixspy_ai_api-1.1.0.tar.gz.
File metadata
- Download URL: ixspy_ai_api-1.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
368239d130dcc8fa7cb04fd6b0bc61efc7ea2b693db22e7b20ab6e47a8e5d1b1
|
|
| MD5 |
93cbc23d6890ba8c65d3e121f27cada6
|
|
| BLAKE2b-256 |
69576f3101b127d9807a2bef2d3bf81e7410f5cf205703b6cba686690a406726
|
Provenance
The following attestation bundles were made for ixspy_ai_api-1.1.0.tar.gz:
Publisher:
python-publish.yml on ixspyinc/ixspy-ai-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ixspy_ai_api-1.1.0.tar.gz -
Subject digest:
368239d130dcc8fa7cb04fd6b0bc61efc7ea2b693db22e7b20ab6e47a8e5d1b1 - Sigstore transparency entry: 1504218758
- Sigstore integration time:
-
Permalink:
ixspyinc/ixspy-ai-api-python@8d5a4b954c7b5d961aa886711c2d709f980ca989 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/ixspyinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8d5a4b954c7b5d961aa886711c2d709f980ca989 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ixspy_ai_api-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ixspy_ai_api-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
004989a5eee67982a583d3868ee032f6f72fbb7dc8b5610411b8233d680a6eb8
|
|
| MD5 |
985e543e491271e3940aed100da3da43
|
|
| BLAKE2b-256 |
12ca6c0941a010c1c44fd3ad92a15205a4598c9188c77b6122def7a67e3c5518
|
Provenance
The following attestation bundles were made for ixspy_ai_api-1.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on ixspyinc/ixspy-ai-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ixspy_ai_api-1.1.0-py3-none-any.whl -
Subject digest:
004989a5eee67982a583d3868ee032f6f72fbb7dc8b5610411b8233d680a6eb8 - Sigstore transparency entry: 1504218809
- Sigstore integration time:
-
Permalink:
ixspyinc/ixspy-ai-api-python@8d5a4b954c7b5d961aa886711c2d709f980ca989 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/ixspyinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8d5a4b954c7b5d961aa886711c2d709f980ca989 -
Trigger Event:
release
-
Statement type: