Skip to main content

SDK and client libraries

You can use Midcore programmatically by invoking the CLI as a subprocess or by calling the HTTP API when your deployment exposes it. Prefer the OpenAPI document from your running API for exact paths and request bodies.

CLI as subprocess

From any language, run the Midcore CLI in a subprocess (e.g. midcore agent "task", midcore gates run). Parse stdout/stderr and exit codes to detect success or failure. See CLI reference for commands and exit codes.

HTTP API

Call the API host directly (server-to-server or tools like curl) using the paths in OpenAPI—typically under /api/v1/… including /api/v1/autonomy/…. From a browser against the Next.js app, same-origin calls use the BFF prefixes /api/backend/… or /api/autonomy/… as described in Web app & API proxies.

Auth is via API keys, cookies, or SSO depending on your deployment. See API overview and Authentication.

Note

Replace API_HOST with your real base URL. The examples are illustrative; use openapi.json to confirm method, path, and body for each operation.

Direct to FastAPI (typical for scripts)

bash
# Health and spec (unauthenticated on many dev setups — confirm yours)
curl -sS "${API_HOST}/health"
curl -sS "${API_HOST}/openapi.json" -o openapi.json

# Example automation path shape (see OpenAPI for the real operation)
curl -sS -X POST "${API_HOST}/api/v1/autonomy/run" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"example"}'

Through the Next.js app (browser or same-origin tools)

bash
# Rewritten to /api/v1/autonomy/... on the API service
curl -sS "https://your-web.example.com/api/autonomy/smart-gates"

Future SDK packages

Dedicated SDK packages (e.g. npm, PyPI) may be offered in the future for a more idiomatic way to call the API and run the CLI. For now, use the CLI or HTTP API as above, or generate a client from the OpenAPI guide.

API overview · Web proxies · CLI reference · Glossary