Python SDK for Fusion API task and action endpoints
Project description
oomol-fusion-sdk
Python SDK for Fusion API task and action endpoints.
This package is designed around the two stable shapes in Fusion API:
- async task endpoints:
submit -> state/result - action endpoints:
/action/{name}
It also includes:
- grouped service shortcuts such as
client.doubao_tts.run_data(...) - TypeScript-style aliases such as
client.doubaoTts.runData(...) - generated raw OpenAPI types
- normalized error handling
Install
pip install oomol-fusion-sdk
Requirements:
- Python 3.8+
requests
Initialize
from oomol_fusion_sdk import FusionClient
client = FusionClient(
api_key="your-api-key",
)
Available client options:
api_key: Optional[str]token: Optional[str]base_url: strdefault_headers: Optional[Dict[str, str]]poll_interval_ms: inttimeout_ms: intsession: Optional[requests.Session]
TypeScript-style constructor keys are also accepted:
apiKeybaseUrldefaultHeaderspollIntervalMstimeoutMs
Example with custom base_url:
client = FusionClient(
api_key="your-api-key",
base_url="https://fusion-api.oomol.com",
poll_interval_ms=2000,
timeout_ms=300000,
)
Default values:
base_url:https://fusion-api.oomol.compoll_interval_ms:2000timeout_ms:300000
Recommended Usage
Use these defaults unless you have a specific reason not to:
- task endpoints: prefer
run_data() - split task control: use
submit()thenwait_data() - action endpoints: prefer grouped methods like
client.jina_reader.read(...) - unmodeled future endpoints: use
client.request(...)
Quick Start
Task example:
audio = client.doubao_tts.run_data(
{
"text": "Hello from Fusion SDK",
"voice": "zh_female_vv_uranus_bigtts",
}
)
print(audio)
Action example:
page = client.jina_reader.read(
{
"URL": "https://example.com/article",
"format": "markdown",
}
)
print(page["data"])
Task APIs
Every async task service supports the same workflow methods:
submit(payload, options=None)state(session_id, options=None)result(session_id, options=None)wait(session_id, options=None)run(payload, options=None)wait_data(session_id, options=None)run_data(payload, options=None)
TypeScript-style aliases are also available:
waitData(sessionID, options=None)runData(payload, options=None)
Example:
submit_response = client.pdf_transform_markdown.submit(
{
"pdfURL": "https://example.com/book.pdf",
}
)
markdown = client.pdf_transform_markdown.wait_data(submit_response["sessionID"])
print(markdown)
run() vs run_data()
run()returns the completed response shaperun_data()returns the result payload directly
Fusion API completion responses are not perfectly uniform across all services. Some endpoints return:
{"success": True, "state": "completed", "data": {...}}
Some return the completed object directly.
wait_data() and run_data() normalize both cases and are the preferred choice for most callers.
Built-in Service Shortcuts
Built-in task services:
client.doubao_ttsclient.doubao_sttclient.oomol_ttsclient.fal_remove_backgroundclient.fal_flux_pro_kontextclient.fal_aura_srclient.fal_sora2_image_to_videoclient.fal_sora2_text_to_videoclient.fal_nano_banana_2client.fal_nano_bananaclient.image_translateclient.manga_zip_translateclient.qwen_mt_imageclient.wanx_imageclient.pdf_transform_epubclient.pdf_transform_markdownclient.fal_nano_banana_proclient.wanx_kf2v_videoclient.cphone_nano_banana
Built-in action groups:
client.custom_financial_fundamental_reportclient.doubao_text_to_image_seedreamclient.text_to_epub_illustrateclient.jina_readerclient.tinify_png_shrinkclient.file_uploadclient.qwen_image_edit_plusclient.qwen_doc_turbo
TypeScript-style camelCase aliases for the same shortcuts are also available.
Action APIs
You can call action endpoints either by grouped shortcut or by raw action key.
Grouped shortcut:
response = client.qwen_doc_turbo.analyze(
{
"text": "Product A costs 100 USD.",
"instruction": "Extract the product name and price.",
}
)
Raw action key:
response = client.action(
"jina-reader/search",
{
"content": "Fusion API SDK",
"jsonResponse": True,
},
)
Raw Request Escape Hatch
Use request() when the backend adds a new endpoint before the SDK model is updated:
response = client.request(
path="/v1/new-service/submit",
method="POST",
body={
"prompt": "hello",
},
)
Runtime Extension
If a new endpoint still matches the standard task shape:
client.register_task("new-service")
result = client.task("new-service").run_data(
{
"prompt": "hello",
}
)
If you need to register a custom action endpoint:
client.register_action(
{
"key": "custom-service/custom-action",
"method": "POST",
"path": "/v1/custom-service/action/custom-action",
}
)
TypeScript-style aliases registerTask(...) and registerAction(...) are also available.
Error Handling
The SDK exports a normalized error type:
from oomol_fusion_sdk import OomolFusionSdkError
try:
result = client.doubao_tts.run_data(
{
"text": "hello",
"voice": "zh_female_vv_uranus_bigtts",
}
)
except Exception as error:
sdk_error = OomolFusionSdkError.from_unknown(error)
print(sdk_error.code)
print(str(sdk_error))
print(sdk_error.status)
print(sdk_error.retryable)
print(sdk_error.details)
Normalized fields:
codemessagestatusretryabledetails
Package Exports
Main SDK:
from oomol_fusion_sdk import FusionClient, OomolFusionSdkError
Generated raw OpenAPI types:
from oomol_fusion_sdk.openapi_types import WanxImageSubmitPostRequest
Friendly aliases matching the TypeScript registry where practical:
from oomol_fusion_sdk.aliases import WanxImageSubmit, ImageTranslateResultData
Typed Extension
Python does not have a direct equivalent of TypeScript declaration merging. For new APIs that are not yet built into the SDK, define your own TypedDict shapes locally and annotate your payloads and results:
from typing import TypedDict
class NewServiceSubmit(TypedDict, total=False):
prompt: str
mode: str
payload: NewServiceSubmit = {
"prompt": "hello",
"mode": "fast",
}
client.register_task("new-service")
result = client.task("new-service").run_data(payload)
Code Generation
The Python SDK can generate raw OpenAPI types from the shared snapshot:
src/oomol_fusion_sdk/generated/openapi_types.py
Useful commands:
python3 scripts/generate_openapi_types.py
python3 scripts/generate_openapi_types.py --spec ../oomol-fusion-sdk-ts/openapi.full.snapshot.json
python3 -m unittest discover -s tests
Development Notes
- This package is currently versioned as
2.0.0 - Built-in grouped services mirror the TypeScript SDK registry
- Generated raw OpenAPI types are exposed as a separate import path
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oomol_fusion_sdk-2.0.0.tar.gz.
File metadata
- Download URL: oomol_fusion_sdk-2.0.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ff09d6ff67485fe507ed8dd609b921491e019400a84d78e18bd0b241c565a9
|
|
| MD5 |
8568bb2f82401b232ce6727c20b659af
|
|
| BLAKE2b-256 |
e23c688680aa4ccdf50a6ad82cb40311f7856f4bfa5a9b6d15fca306892d0eee
|
File details
Details for the file oomol_fusion_sdk-2.0.0-py3-none-any.whl.
File metadata
- Download URL: oomol_fusion_sdk-2.0.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46414b92f6cf19d283c8cf5eb69b414e953b1fff531471315bc42053fe01e528
|
|
| MD5 |
870c9e28fa856860f6a65d1e36effcc2
|
|
| BLAKE2b-256 |
2585e7b0b7a158d1db068ecadf5f934bb591b28c31e0d6e4bf29eb30032a0775
|