openinstinctdocs

Quickstart

Create an API key and make your first request.

1. Get an API key

Sign in to the console, open API keys and create a key. The secret starts with oi- and is shown once: copy it then.

Keep it in an environment variable, not in your code:

export OPENINSTINCT_API_KEY="oi-..."

You can try requests without a key in the console's playground. It shows the same request as cURL, Python and JavaScript.

2. Ask a question

Send a state and one or more questions to POST /v1/systemone.

curl https://api.openinstinct.dev/v1/systemone \
  -H "Authorization: Bearer $OPENINSTINCT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "instinct-one-latest",
    "state": {
      "service": "checkout-api",
      "alert": "p99 latency above 2 s for 12 minutes",
      "error_rate": "0.4%",
      "recent_deploy": "38 minutes ago"
    },
    "questions": {
      "severity": {
        "type": "score",
        "instructions": "How severe is this alert?",
        "criteria": [
          "Informational. Nothing for anyone to do.",
          "Minor. Look at it during working hours.",
          "Serious. Customers notice; act today.",
          "Critical. Page the on-call engineer now."
        ]
      },
      "rollback": {
        "type": "noul",
        "instructions": "Should the most recent deploy be rolled back?"
      }
    }
  }'

3. Read the answer

Each question gets an answer under the name you gave it. The numbers below show the shape; yours will differ.

{
  "model": "instinct-one-latest",
  "answers": {
    "severity": {
      "type": "score",
      "score": 2.1,
      "confidence": 0.62,
      "legend": {
        "0": "Informational. Nothing for anyone to do.",
        "1": "Minor. Look at it during working hours.",
        "2": "Serious. Customers notice; act today.",
        "3": "Critical. Page the on-call engineer now."
      },
      "probabilities": { "0": 0.01, "1": 0.12, "2": 0.63, "3": 0.24 }
    },
    "rollback": { "type": "noul", "noul": 0.58 }
  },
  "usage": { "input_tokens": 142, "output_tokens": 96 },
  "latency_ms": 101
}
  • severity.score is the expected level, counted from 0: between "Serious" and "Critical", closer to "Serious".
  • rollback.noul is the probability that the answer is yes. 0.58 is not a confident yes: decide in your code what threshold is enough to act on.

The first request may be slow

The model runs on GPUs that sleep when nobody uses them. A request that wakes one can wait a minute or two, or come back with 503 model_loading or 504 timeout. Retry it; later requests answer in well under a second. See Errors.

Add an image

Put an image object anywhere in the state. The field name becomes its label.

import base64
import os
import requests

with open("screenshot.png", "rb") as f:
    screenshot = base64.b64encode(f.read()).decode()

response = requests.post(
    "https://api.openinstinct.dev/v1/systemone",
    headers={"Authorization": f"Bearer {os.environ['OPENINSTINCT_API_KEY']}"},
    json={
        "state": {
            "screen": {
                "type": "image",
                "source": {"type": "base64", "media_type": "image/png", "data": screenshot},
            },
        },
        "questions": {
            "form_error": {
                "type": "noul",
                "instructions": "Is the form showing a validation error?",
            },
        },
    },
)
print(response.json()["answers"]["form_error"]["noul"])

More in Images.

Where to go next

On this page