Skip to main content

Introduction

FlyMyAI CLI (fma) is a command-line tool for deploying custom machine learning models onto FlyMyAI cloud infrastructure. It uses Pydantic with custom field types to define model inputs/outputs, and interacts with FlyMyAI services to upload and run your models on our hardware.

Installation

pip install git+https://github.com/flymyai/fma-custom-models.git

Verify the installation:

fma --help

Quickstart

1. Initialize a project

Create a new empty folder and run:

mkdir my-project && cd my-project
fma init my_model

This creates the following structure:

my-project/
├── my_model/
│ └── model.py
└── metadata.yaml

The generated model.py contains a template:

from typing import List

from pydantic import BaseModel

from fma.toolkit import model as fma_model


class Input(BaseModel):
pass


class Output(BaseModel):
pass


class Model(fma_model.Model):
requirements: List[str] = []

def initialize(self):
pass

def predict(self, input: Input) -> Output:
return {}

2. Develop your model

Fill in the initialize and predict methods with your inference logic:

  • initialize() — runs once when the model starts. Load weights, set up pipelines, etc.
  • predict(input) — runs on every inference request. Takes input and returns a result.

All imports should be placed inside the methods. You can store state on self and list Python dependencies in the requirements field.

Important

Even though I/O is described via Pydantic models, the predict method currently accepts and returns plain Python dicts, not Pydantic objects. Full Pydantic support is planned for a future release.

3. Log in and deploy

fma login --username <username> --password <password>
fma deploy

After a successful deploy, model metadata is saved into metadata.yaml.

Field types

Standard types

You can use standard Python types in your Input and Output classes: str, int, float, bool, and their Optional variants.

Image

from fma.toolkit.fields.image import Image

The Image field maps to Pillow's PIL.Image.Image. When reading from input, it arrives as a PIL Image. When returning an image in output, the field value should also be a PIL.Image.Image instance.

File

from fma.toolkit.fields.file import File

The File field maps to io.BytesIO. It works the same way as Image, but with byte streams.

note

File is currently supported only as output.

Project structure

Your project directory must follow this layout:

<your_model_name>/
└── model.py
metadata.yaml

There should be no other folders in the same directory alongside your model folder — this will cause an error during deployment.

Supported third-party packages

The infrastructure provides these pre-installed packages at fixed versions:

PackageVersion
torch2.5.0
bitsandbytes0.44.1
transformers4.45.2
tokenizers0.20.1
sentencepiece0.2.0
accelerate1.0.1
numpy≤1.26.4

You can add any other packages via the requirements field in your Model class. The above packages are guaranteed to be available at the specified versions.