aimage-sdk
Python SDK for the AI-Mage Search public API (/v0). Python 3.12+, httpx
is the only dependency.
Install
pip install aimage-sdk
# or: uv add aimage-sdk
API key permissions
New public API keys default to read_only: search (including POST), listing,
fetching, and asset URL resolution remain available. For the upload examples
below, explicitly create a read_write key and use a project where the owner
has admin access (video writes) or at least editor access (clip updates,
reference images, materials). Review upload/check creation also requires read_write and
Review membership. Optional expiry is set in the developer settings; expired
keys return 401 across SDKs, REST, and MCP. Existing keys retain write access
and no expiry during migration. To change permissions or expiry, create a new
key, switch consumers, then revoke the old one.
Read-only material fetches return pending for unprocessed files without
starting extraction. Existing extracted text remains readable. Read-only
refers to customer resource operations; derived read caches and usage records
may still be maintained by the service.
Quickstart
import os
from aimage_sdk import AimageClient
client = AimageClient(
api_key=os.environ["AIMAGE_API_KEY"], # "aimage_api_..."
base_url="https://api.search.ai-mage.jp", # API server origin; the client calls {base_url}/v0/...
)
# Discover accessible projects.
me = client.me()
project_id = me["projects"][0]["id"]
# Upload a video: mints a presigned URL, PUTs the bytes, registers the video.
video = client.upload_video(
project_id=project_id,
file="./episode-01.mp4", # str | pathlib.Path | bytes (bytes need file_name=)
name="Episode 1",
season=1,
episode=1,
on_progress=print,
)
# Wait until clip extraction and AI tagging finish.
processed = client.wait_for_processing(video["id"], poll_interval_s=10, timeout_s=1800)
if processed["processing_status"] == "failed":
raise RuntimeError(processed["processing_error"])
# Search clips with a natural-language query.
result = client.search_clips(project_id=project_id, query="two characters arguing in the rain")
for clip in result["clips"]:
print(clip["start_time"], clip["subtitle"], clip["tags"], clip["characters"])
API surface
ping()/me()list_projects()
Videos:
mint_upload_url(project_id=, file_name=, content_type=)register_video(project_id=, name=, file_name=|s3_key=, season=, episode=, auto_process=)get_video(video_id)/list_videos(project_id=, processing_status=, order=, page=, page_size=)/delete_video(video_id)get_video_media(video_id, rendition="playback")— time-limited playback (playback, default) or original (original) URLupload_video(project_id=, file=, name=, ...)— full 3-step upload orchestrationwait_for_processing(video_id, poll_interval_s=, timeout_s=)
Reference images:
mint_reference_image_upload_url(project_id=, file_name=, content_type=)register_reference_image(project_id=, file_name=|s3_key=, name=, category=, tags=, purpose=, license=, is_searchable=)list_reference_images(project_id=, page=, page_size=)/get_reference_image(reference_image_id)/delete_reference_image(reference_image_id)upload_reference_image(project_id=, file=, ...)— full 3-step upload orchestration
Materials:
mint_material_upload_url(project_id=, file_name=, content_type=)register_material(project_id=, file_name=|s3_key=, name=, auto_process=)list_materials(project_id=, file_type=, material_type=, page=, page_size=)/get_material(material_id)/delete_material(material_id)upload_material(project_id=, file=, ...)— full 3-step upload orchestration
Characters and visual assets:
list_characters(project_id=, page=, page_size=)/get_character(character_id)— characters with their images (stablevisual_asset_id+ short-liveddownload_url)list_visual_assets(project_id=, source_type=, character_id=, page=, page_size=)/resolve_visual_assets(project_id=, visual_asset_ids=)
Clips and search:
get_clip(clip_id)/update_clip(clip_id, subtitle=, description=, tags=, character_ids=)search_clips(project_id=, query=, reference_image_ids=, image_importance=, page=, page_size=)— passqueryand/orreference_image_ids; returnsranking(similarityis a 0–1 score only when it is"semantic") andmatched_characters(character names recognized inquery); reference images must beembedding_status == "ready"(409REFERENCE_IMAGE_NOT_EMBEDDEDotherwise)search_moments(project_id=, query=, sources=, season=, video_ids=, limit=, offset=)— Alaya moment index (projects whosesearch_capabilitiesincludemoments; 409MOMENT_INDEX_NOT_AVAILABLEotherwise)
Mage Review NG check (same key; the key owner must be a reviewer on the Mage Review project's default proposal):
mint_review_upload_url(project_id=, filename=, file_size=)/run_negative_check(image_id=, template=)/get_negative_check(job_id)check_image(project_id=, file=, file_name=, template=)— upload + run in one callwait_for_negative_check(job_id, poll_interval_s=, timeout_s=)
Failed API calls raise AimageApiError with code, message, and HTTP
status parsed from the {"error": {"code", "message"}} envelope.
Development
cd sdks/python
uv sync
uv run pytest
uv run ruff check .
Transport security (0.5.0)
Version 0.5.0 introduces breaking transport changes from 0.4.x.
API and presigned upload URLs must use HTTPS and must not contain URL credentials.
The client does not follow redirects. For local development only,
allow_insecure_localhost=True permits HTTP on localhost, 127.0.0.1, and
[::1]; it does not permit remote HTTP servers. Existing HTTP integrations must
migrate to HTTPS before upgrading.
The existing timeout option (default 30 seconds) controls httpx network operation
timeouts. Python polling timeouts are checked between requests, not a hard
wall-clock deadline for in-flight I/O. No requests are automatically retried;
a timeout does not guarantee a server-side write was rolled back.
Metadata
Release files for aimage-sdk 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aimage_sdk-0.7.0.tar.gz | 24.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aimage_sdk-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.8 kB
Release files / aimage_sdk-0.7.0.tar.gz
| Download URL | aimage_sdk-0.7.0.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78ac8a0094962af7bdca01a9361e7d39e97b4cad9cbdcd8513a64ddeab3187b7
|
|
BLAKE2b-256 checksum How to use checksums |
14fb57c121e68a8c19c70e005a5bb96ecbf1ed6bff46a0de90309c389b5a9f9f
|
| 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 Oct 8, 2026.
Transparency logRelease files / aimage_sdk-0.7.0-py3-none-any.whl
| Download URL | aimage_sdk-0.7.0-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95039846bca7599ff7c8b2e91a486753849887d9e86a767b1eeaf92f284f559c
|
|
BLAKE2b-256 checksum How to use checksums |
721eec243f03363d75d5d0ab0ebf5008eff6450ba2005d86cfbfdd32c814f435
|
| 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 Oct 8, 2026.
Transparency logSecurity for aimage-sdk 0.7.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for aimage_sdk-0.7.0.tar.gz
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 Oct 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.