Metadata-Version: 2.4
Name: automl-agent-client
Version: 0.2.0
Summary: Python client and CLI for AutoML-Agent: describe an ML task in one sentence, get a verified, deployable pipeline.
Keywords: automl,machine-learning,llm,agents,mlops,api-client
Author: kitasid
Author-email: kitasid <ramsiddu2002@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.7
Requires-Dist: typing-extensions>=4.7
Requires-Python: >=3.10
Project-URL: Homepage, https://agentml.kitasid.dev
Description-Content-Type: text/markdown

# automl-agent-client

Python client and CLI for **[AutoML-Agent](https://agentml.kitasid.dev)**. Describe an ML task in one sentence,
add your data, and five AI agents do the rest:
- plan the approach;
- search models and hyperparameters;
- write the pipeline and verify it;
- hand you a deployable script.

```bash
pip install automl-agent-client
```

## 1. Get an API key
Sign in at [agentml.kitasid.dev](https://agentml.kitasid.dev). Open **Settings → API keys**, then create a key.
It's shown once, so copy it. Then use either option:

```bash
agentml login                      # paste the key; it's saved for your user only
# or
export AUTOML_AGENT_API_KEY=amk_…
```

## 2. Python

```python
from automl_agent_client import AutoMLClient

client = AutoMLClient()

run = client.runs.create(
    "Classify banana quality as Good or Bad. Accuracy must be at least 0.98.",
    files=["banana_quality.csv"],
)
for event in client.runs.stream(run.run_id):  # live, stage by stage
    print(event.stage, event.status, event.message)

record = client.runs.get(run.run_id)
print(record.status)  # completed
open("pipeline.py", "w").write(client.runs.code(run.run_id))

for chunk in client.runs.ask(run.run_id, "Why was this model chosen?"):
    print(chunk, end="")
```

Or in one call: `record = client.runs.run("…", files=[…], timeout=900)`.

**Async:** the same methods, awaitable, on `AsyncAutoMLClient`:

```python
async with AsyncAutoMLClient() as client:
    run = await client.runs.create("Forecast daily sales for 14 days", files=["sales.csv"])
    async for event in client.runs.stream(run.run_id):
        ...
```

### Drift
Check fresh data against what a run learned from. If you include the target column, executed runs also re-score
the trained model.

```python
analysis = client.drift.analyze(run.run_id, "bananas_this_week.csv")
analysis = client.drift.wait(run.run_id, analysis.id)  # the model check finishes in the background
print(analysis.result.data.status)  # stable / moderate / drifted
```

### Deployed models
Deploy an executed tabular run's trained model, then predict, explain and keep it fresh. Retraining reuses the
run's pipeline and best hyperparameters on your new labelled data, with no LLM involved, and every retrained
version waits for your approval.

```python
dep = client.deployments.create(run.run_id, name="Banana quality")
client.deployments.wait_ready(dep.deployment.id)

out = client.deployments.predict(dep.deployment.id, [{"Size": -1.9, "Weight": 0.4, "Sweetness": 0.6}], explain=True)
print(out.predictions, out.probabilities, out.explanation.contributions)

client.deployments.feedback(dep.deployment.id, out.prediction_id, labels=["Good"])  # ground truth
client.deployments.add_data(dep.deployment.id, "labelled_this_week.csv")            # more labelled rows

for v in client.deployments.versions(dep.deployment.id):  # retrains appear as candidates
    print(v.version, v.status, v.trigger.reason, v.metrics.comparison)
client.deployments.promote(dep.deployment.id, version_id)  # or .reject(...), .rollback(...)
```

## 3. CLI

```bash
agentml run "Classify banana quality, accuracy >= 0.98" -f banana_quality.csv --follow
agentml list
agentml code <run-id> -o pipeline.py
agentml ask <run-id> "Which features matter most?"
agentml drift <run-id> new_data.csv --wait

agentml deploy <run-id> --wait
agentml predict <deployment-id> -f rows.csv --explain
agentml feedback <deployment-id> <prediction-id> Good,Bad,Good
agentml add-data <deployment-id> labelled.csv
agentml versions <deployment-id>
agentml promote <deployment-id> <version-id>
agentml rollback <deployment-id>
```

## Errors and limits

| Situation | Exception |
|---|---|
| Missing, invalid or revoked key | `AuthenticationError` |
| Not your run, or no such run | `NotFoundError` |
| Daily run limit reached (`retry_after` gives the seconds until it resets) | `RateLimitError` |
| Run or analysis not in a state that allows the request | `ConflictError` |
| Uploads too large | `PayloadTooLargeError` |
| `wait()` gave up (the run continues on the server) | `RunTimeoutError` |

All of these inherit from `AutoMLError`. Requests that only read data are retried automatically on network
errors and 502/503/504.

Configuration:
- `AUTOML_AGENT_API_KEY`: the API key.
- `AUTOML_AGENT_BASE_URL`: the API root, default `https://agentml.kitasid.dev/api`.
- `AUTOML_AGENT_CONFIG_DIR`: where `agentml login` saves the key.

The pipelines, agents and models run on the AutoML-Agent service. This package is only the client.
