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.0.tar.gz (10.1 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.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

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

Hashes for ixspy_ai_api-1.1.0.tar.gz
Algorithm Hash digest
SHA256 368239d130dcc8fa7cb04fd6b0bc61efc7ea2b693db22e7b20ab6e47a8e5d1b1
MD5 93cbc23d6890ba8c65d3e121f27cada6
BLAKE2b-256 69576f3101b127d9807a2bef2d3bf81e7410f5cf205703b6cba686690a406726

See more details on using hashes here.

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

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

Hashes for ixspy_ai_api-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 004989a5eee67982a583d3868ee032f6f72fbb7dc8b5610411b8233d680a6eb8
MD5 985e543e491271e3940aed100da3da43
BLAKE2b-256 12ca6c0941a010c1c44fd3ad92a15205a4598c9188c77b6122def7a67e3c5518

See more details on using hashes here.

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

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