|
| 1 | +# API for agents and automation |
| 2 | + |
| 3 | +OpenModelStudio is **API-first**: the UI, OpenClaw, a future CLI, and any coding agent all use the **same REST API**. Whatever works for OpenClaw works for every other client. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## One interface, many clients |
| 8 | + |
| 9 | +| Client | How it uses the API | |
| 10 | +|--------|----------------------| |
| 11 | +| **Web UI** | Browser → same API (with user session / JWT) | |
| 12 | +| **OpenClaw plugin** | Agent tools → HTTP requests with API key | |
| 13 | +| **Future CLI** | Commands → HTTP requests with API key | |
| 14 | +| **Cursor / any coding agent** | Code or tools → HTTP requests with API key | |
| 15 | +| **Python SDK** | Wraps the same API with an API key or JWT | |
| 16 | + |
| 17 | +There is no special “OpenClaw-only” path. The OpenClaw plugin is just one client that calls the REST API with a base URL and an API key. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Contract for any coding agent or CLI |
| 22 | + |
| 23 | +To control OpenModelStudio from **any** agent (OpenClaw, Cursor, a script, or a CLI): |
| 24 | + |
| 25 | +1. **Base URL** — OpenModelStudio API root, e.g. `http://localhost:31001` or `https://api.your-oms.com`. |
| 26 | +2. **Auth** — API key (recommended) or JWT in the `Authorization` header: |
| 27 | + - `Authorization: Bearer oms_xxxxxxxx...` (API key from Settings → API Keys) |
| 28 | + - or `Authorization: Bearer <jwt>` (from `POST /auth/login`). |
| 29 | +3. **Endpoints** — Same REST routes the UI and OpenClaw use: projects, models, datasets, training, experiments, workspaces, search, etc. |
| 30 | + |
| 31 | +Example (curl): |
| 32 | + |
| 33 | +```bash |
| 34 | +export OMS_BASE_URL="http://localhost:31001" |
| 35 | +export OMS_API_KEY="oms_xxxxxxxx..." |
| 36 | + |
| 37 | +curl -s -H "Authorization: Bearer $OMS_API_KEY" "$OMS_BASE_URL/projects" |
| 38 | +curl -s -X POST -H "Authorization: Bearer $OMS_API_KEY" \ |
| 39 | + -H "Content-Type: application/json" \ |
| 40 | + -d '{"name":"My Project"}' "$OMS_BASE_URL/projects" |
| 41 | +``` |
| 42 | + |
| 43 | +Any coding agent that can send HTTP requests and store a base URL + API key can do the same (e.g. in Python with `requests`, in Node with `fetch`, or via a small CLI that wraps these calls). |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## API surface (overview) |
| 48 | + |
| 49 | +The API already covers the system. Main areas: |
| 50 | + |
| 51 | +- **Auth** — `/auth/login`, `/auth/refresh`, `/auth/me`; API keys via `/api-keys`. |
| 52 | +- **Projects** — `/projects` (list, create, get, update, delete, collaborators, activity). |
| 53 | +- **Datasets** — `/datasets`, `/projects/{id}/datasets` (list, create, get, delete, upload). |
| 54 | +- **Data sources** — `/data-sources` (list, create, delete, test). |
| 55 | +- **Models** — `/models`, `/projects/{id}/models` (list, create, get, update, delete, code, run, versions). |
| 56 | +- **Training** — `/training/start`, `/training/jobs`, `/training/{id}`, metrics, logs, cancel. |
| 57 | +- **Inference** — `/inference/run`, `/inference/{id}`, output. |
| 58 | +- **Experiments** — `/experiments` (list, create, get, delete, runs, add run, compare). |
| 59 | +- **Artifacts** — `/jobs/{id}/artifacts`, `/artifacts` (create, get, delete, download). |
| 60 | +- **Workspaces** — `/workspaces`, `/workspaces/launch`, get, stop. |
| 61 | +- **Environments** — `/environments` (list, create, get, update, delete). |
| 62 | +- **Features** — `/features`, `/projects/{id}/features`, groups. |
| 63 | +- **Search** — `/search?q=...`. |
| 64 | +- **LLM** — `/llm/chat`, `/llm/conversations`. |
| 65 | +- **SDK-style** — `/sdk/*` (register-model, datasets, features, hyperparameters, start-training, start-inference, jobs, pipelines, sweeps). |
| 66 | +- **Admin** — `/admin/users`, `/admin/stats` (admin role). |
| 67 | + |
| 68 | +So the system is already **API-enabled**; a CLI would be another client on top of this surface. |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## OpenClaw vs other agents |
| 73 | + |
| 74 | +- **OpenClaw:** Plugin registers tools (e.g. `oms_list_projects`, `oms_create_project`); each tool runs an HTTP request to the API with the configured `baseUrl` and `accessToken` (API key or JWT). No magic—just REST. |
| 75 | +- **Other agents (e.g. Cursor, custom scripts):** Use the same `baseUrl` + API key and the same endpoints. You can: |
| 76 | + - Give the agent the base URL and API key (via env or a config file) and instructions to call the REST API, or |
| 77 | + - Build a small CLI (e.g. `oms projects list`, `oms training start ...`) that calls the API and let the agent run CLI commands, or |
| 78 | + - Use the Python SDK with an API key. |
| 79 | + |
| 80 | +So: **yes, whatever you do for OpenClaw works for all coding agents**—same API, same auth. Making the system “API-enabled” is already done; adding a CLI is another client that reuses this same interface. |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## See also |
| 85 | + |
| 86 | +- [OpenClaw Integration](OPENCLAW-INTEGRATION.md) — Plugin setup and tools. |
| 87 | +- [OpenClaw Quickstart](OPENCLAW-QUICKSTART.md) — Full flow and config (API key, base URL). |
| 88 | +- [Python SDK](../sdk/python/README.md) — Programmatic access from Python (e.g. notebooks, scripts). |
0 commit comments