Sparkient Docs

Quickstart

Get your API key and make your first decision in 5 minutes.

1. Get Your API Key

Sign in to the Sparkient Dashboard and navigate to Settings → API Keys. Click Create API Key, give it a name, and copy the key.

Your API key is shown only once. Copy it and store it securely.

2. Create a Decision Type

A decision type defines what you're deciding. It specifies the possible outcomes, reason codes, and any hard rules.

Create a decision type
curl -X POST https://api.sparkient.ai/api/v1/decision-types \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "content_moderation",
    "description": "Should this user-generated content be approved?",
    "options": ["approve", "flag", "reject"],
    "reason_codes": ["safe_content", "borderline", "policy_violation", "spam"],
    "rules": [
      {
        "name": "block_spam_links",
        "condition": "ctx.link_count > 5",
        "then": "reject",
        "reason_code": "spam",
        "priority": 1
      }
    ]
  }'

3. Make a Decision

Now send an input to get a structured decision:

Make a decision
curl -X POST https://api.sparkient.ai/api/v1/decide \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "decision_type": "content_moderation",
    "input": {
      "text": "Check out this great new product!",
      "link_count": 1,
      "user_reputation_score": 0.85
    }
  }'

Response

Decision response
{
  "decision": "approve",
  "confidence": 0.92,
  "reason_codes": ["safe_content"],
  "latency_ms": 4.2,
  "stage": "rules",
  "escalate": false,
  "rules_triggered": [],
  "request_id": "req_abc123"
}

4. Train a Model (Optional)

Rules handle the obvious cases. For nuanced decisions, train an ML model:

  1. Add training examples — via the dashboard or the API
  2. Generate synthetic data — Sparkient's teacher LLM creates additional examples
  3. Train — one API call triggers the full pipeline (feature engineering → model training → ONNX export)
  4. Deploy — promote the trained model to production
Trigger training
curl -X POST https://api.sparkient.ai/api/v1/decision-types/{id}/train \
  -H "Authorization: Bearer YOUR_API_KEY"

Once deployed, subsequent /decide calls automatically use the trained model for higher-quality decisions.

Verify Your Setup

You can verify your API connection by hitting the root endpoint:

Check the API
curl https://api.sparkient.ai/
Root response
{
  "service": "Sparkient API",
  "by": "Sparkient",
  "version": "1.0.0",
  "documentation": "https://docs.sparkient.ai",
  "openapi": "/openapi.json",
  "health": "/health"
}

Next Steps

On this page