Harden and deploy your app¶
Finally, it's time to deploy your model. But before that, you have to make sure you follow AI deployment best practices. In the past, this step was too often either the source of unexpected struggle, or worse, simply ignored.
GreatAI's decorators add tracing and API scaffolding with a few lines of code. This brings the service nearly to production readiness, but does not establish the model's accuracy, fairness, or trustworthiness. Evaluate the model for its intended use, configure a production-suitable tracing database and storage, and review the remaining deployment best practices. The local TinyDB backend used below is for development, as the output warns.
Local setup¶
Use Python 3.12 or 3.13 and install this checkout with uv pip install --editable '.[notebooks]'.
See Run notebooks locally in the repository README for the kernel, execution order,
and full-data options. Run related notebooks from the same working directory
to share the default .cache/ model store and tracing_database.json database.
from great_ai import GreatAI, use_model
from great_ai.utilities import clean
@GreatAI.create
@use_model("my-domain-predictor")
def predict_domain(sentence, model):
inputs = [clean(sentence)]
return str(model.predict(inputs)[0])
Environment variable ENVIRONMENT is not set, defaulting to development mode ‼️
Cannot find credentials files, defaulting to using ParallelTinyDbDriver
The selected tracing database (ParallelTinyDbDriver) is not recommended for production
Cannot find credentials files, defaulting to using LargeFileLocal
GreatAI (v0.1.11): configured ✅
🔩 tracing_database: ParallelTinyDbDriver
🔩 large_file_implementation: LargeFileLocal
🔩 is_production: False
🔩 should_log_exception_stack: True
🔩 prediction_cache_size: 512
🔩 dashboard_table_size: 50
You still need to check whether you follow all best practices before trusting your deployment.
> Find out more at https://se-ml.github.io/practices
Fetching cached versions of my-domain-predictor
Latest version of my-domain-predictor is 0 (from versions: 0)
File my-domain-predictor-0 found in cache
File my-domain-predictor-0 found in cache
predict_domain("Mountains are just big rocks.")
Trace[str]({'created': '2026-10-28T22:47:28.223376',
'exception': None,
'feedback': None,
'logged_values': { 'arg:sentence:length': 29,
'arg:sentence:value': 'Mountains are just big rocks.'},
'models': [{'key': 'my-domain-predictor', 'version': 0}],
'original_execution_time_ms': 7.958,
'output': 'sociology',
'tags': ['predict_domain', 'online', 'development'],
'trace_id': 'b48540f9-3162-47de-b035-bf11cc4d1581'})
Notice how the original return value is under the .output key, alongside
tracing metadata. Run train.ipynb first, using the same local/full mode.
Start the development server in a separate terminal from the checkout root:
source .venv/bin/activate
great-ai docs/tutorial/deploy.ipynb
Open http://127.0.0.1:6060/dashboard. Stop the server with Ctrl+C. The next cell tests the HTTP API in-process so that Run All can finish.
from fastapi.testclient import TestClient
with TestClient(predict_domain.app) as client:
response = client.post(
"/predict", json={"sentence": "Mountains are just big rocks."}
)
response.raise_for_status()
assert isinstance(response.json()["output"], str)
print(response.json()["output"])
sociology
Congrats, you've just created your first GreatAI service! 🎉
Your service now has tracing and API scaffolding. Before deploying, replace the default local TinyDB tracing backend, configure storage and infrastructure, evaluate the model for its intended use, and review the remaining best practices. Model trustworthiness requires evidence and ongoing oversight beyond wrapping the inference function. You (or your organisation) remain responsible for deploying and operating the service.
There are three main approaches to deploy a GreatAI service: For more info about them, check out the deployment how-to.
For more thorough examples, see the examples page.