Skip to main content

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

任务生命周期

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

  1. 创建任务,例如调用 create_custom_composition()create_video()
  2. API 返回 task_id
  3. 使用 get_task_status()get_video_status() 查询任务状态。
  4. 等待任务状态变为 completed
  5. 读取结果字段,例如 sd_image_urlhd_image_urlvideo_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ixspy_ai_api-1.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ixspy_ai_api-1.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ixspy_ai_api-1.1.1.tar.gz.

File metadata

  • Download URL: ixspy_ai_api-1.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ixspy_ai_api-1.1.1.tar.gz
Algorithm Hash digest
SHA256 07882d71245213bcd9b87c9f520536364a6115b05272ef6a067678f5ac0b4e77
MD5 2c8be296f4d838225fb0ed7624828787
BLAKE2b-256 d9bb3adcd4333b085ab5fd2d7716f1431a6d0d13d68f57eb4f88bb0bfb94bc75

See more details on using hashes here.

Provenance

The following attestation bundles were made for ixspy_ai_api-1.1.1.tar.gz:

Publisher: python-publish.yml on ixspyinc/ixspy-ai-api-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ixspy_ai_api-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: ixspy_ai_api-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ixspy_ai_api-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16889af50e678b4cd5ed91c9a4e18fa96dc6e6eed2a4865e5ef78de05e3b8340
MD5 00ff5ad9ba9dc5a40efd9cd85a8d31c6
BLAKE2b-256 744f74adb44607e22e2d63a32c0dc5ccefc2ac52c3748f74c47b6e0cea913275

See more details on using hashes here.

Provenance

The following attestation bundles were made for ixspy_ai_api-1.1.1-py3-none-any.whl:

Publisher: python-publish.yml on ixspyinc/ixspy-ai-api-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page