跳转至

Getting Started

Installation

git clone https://github.com/aimagexyz/aimage-sdk
cd aimage-sdk
pip install -e .

Authentication

Use an API token or API key:

export AIMAGE_SEARCH_TOKEN="your_token_here"
# or
export AIMAGE_API_KEY="your_api_key_here"
from aimage import search

with search.client() as client:
    assert client.health()

Service Selection

service accepts either a predefined enum or a custom ORPC origin URL:

from aimage import search
from aimage.search.settings import SearchService

client = search.client(service=SearchService.PROD)
client = search.client(service=SearchService.DEV)
client = search.client(service="https://custom-api.example.com")

SearchClient also accepts service directly:

from aimage.search.client import SearchClient
from aimage.search.settings import SearchService

client = SearchClient(service=SearchService.DEV)

Email Login

Entering the context sends an email code. Call code() after the user enters it:

from aimage.search.client import SearchClient

client = SearchClient(service="https://api.search.ai-mage.jp")

with client.login_with_email(email="[email protected]") as login:
    code = input("email code> ")
    result = login.code(code)

If MFA is required, continue with TOTP:

with client.login_with_email(email="[email protected]") as login:
    login.code(input("email code> "))
    result = login.totp(input("totp> "))