Skip to content

REST Workflow Guide

REST is not part of the hosted product today

The hosted product is reached over MCP. Every /api/v1/* route documented on this page is closed at the edge: the production nginx config answers location /api/ with 404 (see infra/nginx/conf.d.prod/g6solver.conf). The examples below will not work against g6solver.com — they are kept as engineering reference for the REST base in this repository, not as customer instructions.

Run the Business Document Classifier programmatically via G6's REST API.

Prerequisites

  • G6 REST server running — self-hosted (see REST Base)
  • API key configured (see Setup)

Base URL

http://localhost:8010/api/v1

Step-by-step

Step 1: Health check

curl http://localhost:8010/api/v1/health
import httpx
r = httpx.get("http://localhost:8010/api/v1/health")
print(r.json())
const r = await fetch("http://localhost:8010/api/v1/health");
console.log(await r.json());

Expected response:

{"status": "healthy", "components": 270, "services": {"redis": "...", "database": "..."}}

Step 2: Decompose goal

curl -X POST http://localhost:8010/api/v1/goals/decompose \
  -H "Content-Type: application/json" \
  -d '{
    "goal": "Classify support tickets into categories",
    "context": "5 categories: billing, technical_support, account_access, feature_request, complaint",
    "constraints": ["Target accuracy: 80%", "Use held-out evaluation"]
  }'
r = httpx.post("http://localhost:8010/api/v1/goals/decompose", json={
    "goal": "Classify support tickets into categories",
    "context": "5 categories: billing, technical_support, account_access, feature_request, complaint",
    "constraints": ["Target accuracy: 80%", "Use held-out evaluation"],
})
plan = r.json()

Step 3: Invoke evaluation component

curl -X POST http://localhost:8010/api/v1/invoke \
  -H "Content-Type: application/json" \
  -d '{
    "component": "align_evals",
    "op": "infer",
    "params": {
      "predictions": ["billing", "complaint", "technical_support"],
      "ground_truth": ["billing", "billing", "technical_support"],
      "metrics": ["accuracy", "precision", "recall", "f1"],
      "threshold": 0.8
    }
  }'
r = httpx.post("http://localhost:8010/api/v1/invoke", json={
    "component": "align_evals",
    "op": "infer",
    "params": {
        "predictions": ["billing", "complaint", "technical_support"],
        "ground_truth": ["billing", "billing", "technical_support"],
        "metrics": ["accuracy", "precision", "recall", "f1"],
        "threshold": 0.8,
    },
})
eval_result = r.json()
# {"scores": {"accuracy": 0.67, ...}, "passed": false, "degraded": false}

Step 4: Run a pipeline

curl -X POST http://localhost:8010/api/v1/pipeline \
  -H "Content-Type: application/json" \
  -d '{
    "steps": [
      {"component": "adapt_pandas", "op": "load_csv", "params": {"path": "data.csv"}},
      {"component": "align_evals", "op": "infer", "params": {"metrics": ["accuracy", "f1"]}}
    ],
    "budget": {"max_tokens": 10000, "max_seconds": 60}
  }'
r = httpx.post("http://localhost:8010/api/v1/pipeline", json={
    "steps": [
        {"component": "adapt_pandas", "op": "load_csv", "params": {"path": "data.csv"}},
        {"component": "align_evals", "op": "infer", "params": {"metrics": ["accuracy", "f1"]}},
    ],
    "budget": {"max_tokens": 10000, "max_seconds": 60},
})
pipeline_result = r.json()

Step 5: Get recommendations

curl -X POST http://localhost:8010/api/v1/nav/recommend \
  -H "Content-Type: application/json" \
  -d '{
    "context": "Classification accuracy is 65%, failures are mostly ambiguous_input and edge_case categories"
  }'
r = httpx.post("http://localhost:8010/api/v1/nav/recommend", json={
    "context": "Classification accuracy is 65%, failures are mostly ambiguous_input and edge_case categories",
})
recommendations = r.json()

Step 6: Run self-training audit

curl -X POST http://localhost:8010/api/v1/invoke \
  -H "Content-Type: application/json" \
  -d '{
    "component": "self_training",
    "op": "audit",
    "params": {"targets": ["align_evals"], "max_cycles": 3}
  }'
r = httpx.post("http://localhost:8010/api/v1/invoke", json={
    "component": "self_training",
    "op": "audit",
    "params": {"targets": ["align_evals"], "max_cycles": 3},
})
audit_result = r.json()

Response format

All responses follow:

{
  "ok": true,
  "result": { ... },
  "meta": {
    "duration_ms": 142,
    "tokens_used": 0,
    "degraded": false
  }
}

Error responses:

{
  "ok": false,
  "error": "Component not found: invalid_name",
  "code": "NOT_FOUND"
}

Authentication

For production deployments, include your API key:

curl -H "Authorization: Bearer YOUR_API_KEY" ...

See Configuration for auth setup.

Rate limits

Tier Requests/min Tokens/hour
Free Trial 10 5,000
Researcher 60 50,000
Builder 300 500,000

Next steps