AI Marketplace Python SDK
Project description
AIMP SDK (Python)
This package provides the class-based SDK used by model authors.
Install
python -m pip install ai-marketplace-sdk
Install (local source)
cd sdk/python
uv pip install .
Development (editable)
cd sdk/python
uv pip install -e .
Fine-Tune From Scratch
The fine-tune flow has two sides:
- model authoring: define the schema and training runtime inside the model project
- consumer dataset creation: build one local bundle that matches the published schema
1. Define the training input contract
Model authors declare fine-tune inputs by subclassing FineTuneSchema and adding fields in
tuning.py.
Available field types:
ImageFieldAudioFieldVideoFieldFileFieldTuningTextFieldTuningJsonField
Example:
from aimp_sdk import FineTuneSchema, ImageField
def validate_png(value: object) -> None:
if not str(value).lower().endswith(".png"):
raise ValueError("Only PNG files are allowed")
class ModelFineTuneSchema(FineTuneSchema):
query_image = ImageField(required=True, validators=[validate_png])
candidate_image = ImageField(required=True, validators=[validate_png])
Use field-level validators=[...] and preprocessors=[...] when one field needs custom cleanup or
validation. These hooks run during local bundle build, before upload.
2. Implement the tuning runtime
Model authors implement exactly one method: Component.tune(self, tuning) -> TuneResult.
The platform opens the uploaded bundle, splits train/validation data, injects trial parameters, and
passes a single author-facing tuning object into your component.
from aimp_sdk import Component, TuneResult
class CoreModel(Component):
tuning = ModelFineTuneSchema
# In the current SDK, build(ctx) is the author hook used to load runtime state once.
def build(self, ctx):
self.runtime = load_runtime(ctx.artifacts_dir)
return self.runtime
def tune(self, tuning) -> TuneResult:
learning_rate = tuning.params.learning_rate
epochs = tuning.params.epochs
for record in tuning.train_dataset:
train_step(
query_image=tuning.resolve_path(record.query_image),
candidate_image=tuning.resolve_path(record.candidate_image),
learning_rate=learning_rate,
)
_ = epochs
validation_loss = evaluate(tuning.validation_dataset)
return TuneResult(metrics={"validation_loss": validation_loss})
tuning exposes only training concerns:
tuning.train_datasettuning.validation_datasettuning.paramstuning.resolve_path(...)
In the current SDK, authors implement build(self, ctx) to load runtime state once. The separate
load(...) method is framework-internal cache/lifecycle plumbing and is not the author-facing hook.
tuning.params comes from the model's published tuning.parameters contract. Defaults and search
space metadata are contract-owned by the platform. Model code must not introduce hidden fallbacks
such as getattr(tuning.params, "learning_rate", 1e-5).
Model code does not handle dataset files, S3 uploads, adapter URIs, or trial orchestration.
3. Build the consumer dataset bundle
Consumers do not write model-side tuning code. They use the published schema through the CLI:
ai fine-tune schema --model <model-slug>ai fine-tune scaffold --model <model-slug>- edit
prepare_bundle.pyand add any localassets/ python prepare_bundle.pyai fine-tune create --model <model-slug> --output-dir .
During bundle build the SDK:
- validates required fields and field types
- runs field preprocessors
- validates the processed values
- copies binary assets into the bundle
- writes
data.parquetandmanifest.json
That means field preprocessors and validators run before upload, not during remote execution.
4. Use the derived model directly
Successful LoRA fine-tunes produce a derived executable model with its own asset ID and slug. Clients should execute that derived model directly, as if it were a new model:
job = client.fine_tune_job(job_id="ft-123").wait_for_completion()
result = client.models.execute(
model=job.tuned_model_slug,
mode="generate",
input={"prompt": "hello"},
)
Client code should not pass adapter_id to executions. Adapter resolution is platform-internal.
Project details
Release history Release notifications | RSS feed
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 ai_marketplace_sdk-0.1.1.tar.gz.
File metadata
- Download URL: ai_marketplace_sdk-0.1.1.tar.gz
- Upload date:
- Size: 194.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01fb37c1571dfc7a196c3568a44740c963cf343c66e1f14c16d375d5930f3b54
|
|
| MD5 |
2a6687a270bb69d0f96f0a4bf14059ae
|
|
| BLAKE2b-256 |
eb8f7abd3fa7b5417fcaaf17d5877a5b83de3e88197f99e887bcf415a288a7dd
|
Provenance
The following attestation bundles were made for ai_marketplace_sdk-0.1.1.tar.gz:
Publisher:
publish-python-packages.yml on zakariaalmoktar/AI-Marketplace-Platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_marketplace_sdk-0.1.1.tar.gz -
Subject digest:
01fb37c1571dfc7a196c3568a44740c963cf343c66e1f14c16d375d5930f3b54 - Sigstore transparency entry: 1195701591
- Sigstore integration time:
-
Permalink:
zakariaalmoktar/AI-Marketplace-Platform@6c603431df19dedb17d8d51bee818f2be2746630 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zakariaalmoktar
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-packages.yml@6c603431df19dedb17d8d51bee818f2be2746630 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ai_marketplace_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ai_marketplace_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 56.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea5d2c0477a1fec370ee68c2040014b99a06cc209e3961ba391b7a820cc2c8a
|
|
| MD5 |
edb540b8007ecd0a0f4a2a072d3042a9
|
|
| BLAKE2b-256 |
2886ac8955251883e0fffdb6af0dbb4fe859c4730682c5b4838ac688e6fca9a5
|
Provenance
The following attestation bundles were made for ai_marketplace_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish-python-packages.yml on zakariaalmoktar/AI-Marketplace-Platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_marketplace_sdk-0.1.1-py3-none-any.whl -
Subject digest:
4ea5d2c0477a1fec370ee68c2040014b99a06cc209e3961ba391b7a820cc2c8a - Sigstore transparency entry: 1195701614
- Sigstore integration time:
-
Permalink:
zakariaalmoktar/AI-Marketplace-Platform@6c603431df19dedb17d8d51bee818f2be2746630 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zakariaalmoktar
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-packages.yml@6c603431df19dedb17d8d51bee818f2be2746630 -
Trigger Event:
workflow_dispatch
-
Statement type: