跳转至

はじめに

インストール

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

認証

API token または API key を使います。

export AIMAGE_SEARCH_TOKEN="your_token_here"
# または
export AIMAGE_API_KEY="your_api_key_here"
from aimage import search

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

Service の指定

service には定義済み enum または 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 に直接渡すこともできます。

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

client = SearchClient(service=SearchService.DEV)

メールログイン

context に入るとメールコードが送信されます。ユーザーが入力した後に code() を呼びます。

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)

MFA が必要な場合は TOTP を続けて入力します。

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