> ## Documentation Index
> Fetch the complete documentation index at: https://aimp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Use Python to call model runs and publish model projects.

# Python SDK

Use plain HTTP for simple server integrations. Use the AIMP Python packages when
you are authoring or publishing model projects.

## Consumer execution with Python

```python theme={null}
import os
import requests

gateway_url = os.environ["AIMP_GATEWAY_URL"].rstrip("/")

payload = {
    "model": "demo-model",
    "mode": "execute",
    "scope": "playground",
    "input": {"text": "Hello from Python"},
    "params": {},
}

response = requests.post(
    f"{gateway_url}/api/runs",
    headers={"X-API-Key": os.environ["AIMP_API_KEY"]},
    json=payload,
    timeout=60,
)
response.raise_for_status()
print(response.json())
```

## Model authoring packages

Model authors install the SDK inside model projects:

```bash theme={null}
python -m pip install ai-marketplace-sdk
```

The runtime entrypoint for model containers is:

```bash theme={null}
python -m aimp_sdk.model_runner --module /app/main.py
```

## When to use the CLI

Use the CLI for project scaffolding, contract validation, login, and publish
operations:

```bash theme={null}
ai init demo-model --yes
ai contract validate --json
ai publish --configure --json
ai push
```

Continue with [CLI publish](./cli-publish) if you are publishing a model.
