DrexDocs

Quickstart

Sign in, create an API key, and get your first calibrated answer from Drex.

In this tutorial we sign in, create an API key, and ask Drex two questions about one support message. By the end you have a working call in curl, TypeScript, or Python and know how to read the answer.

Sign in and claim your credit

Open console.nace.ai/login. Enter your email, click Send code, and enter the code from your inbox.

A new account gets $25.00 of signup credit. The credit expires 3 months after the account is created, and each person gets it once. The rest of the price sheet is on Pricing.

Create an API key

In the dashboard, open API Keys and click Create key. Name the key after the app or environment that will use it, then click Create key again.

The dialog shows the full key once. Copy it now. If you lose it, revoke it and create a new one.

Now export it in your shell:

export DREX_API_KEY="nace_sk_..."

Ask your first question

We send one line of customer text as state and one noul (yes or no) question about it.

curl https://console.nace.ai/v1/systemone \
  -H "Authorization: Bearer $DREX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "drex-v1.0",
    "state": "Help! My payouts have been failing for 3 days.",
    "questions": {
      "is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" }
    }
  }'

The curl call prints the full response. The TypeScript and Python calls print only the noul value. This is an example output. Numbers vary slightly per call.

Response
{
  "model": "drex-v1.0",
  "answers": {
    "is_urgent": { "type": "noul", "noul": 0.8401 }
  },
  "usage": { "input_tokens": 26, "output_tokens": 24 },
  "evaluation_time_ms": 6.8,
  "request_id": "req_9d4e1b2c7a3f4e0d8b6c5a4f3e2d1c0b"
}

noul is the probability of yes, from 0 to 1. Here Drex puts 84% on the message being urgent. You choose the threshold. Route on noul > 0.5 for a plain yes or no, or on a higher cutoff when a false yes is expensive.

Add a choice question to the same call

Drex answers many questions about one state in one call. We add a choice question with three labels. The description next to each label tells Drex what the label means.

questions
{
  "is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" },
  "team": {
    "type": "choice",
    "instructions": "Which team should handle this?",
    "criteria": {
      "payments": "Payouts, charges, or refunds",
      "support": "General questions and how-to",
      "engineering": "Bugs and outages"
    }
  }
}

In TypeScript, the same question is choice("Which team should handle this?", { payments: "Payouts, charges, or refunds", support: "General questions and how-to", engineering: "Bugs and outages" }), imported from @typesafe-ai/sdk.

Run the call again with both questions. The answers object now has two entries:

Response
{
  "model": "drex-v1.0",
  "answers": {
    "is_urgent": { "type": "noul", "noul": 0.8383 },
    "team": {
      "type": "choice",
      "choice": "payments",
      "confidence": 0.884,
      "probabilities": {
        "payments": 0.9227,
        "support": 0.0296,
        "engineering": 0.0477
      }
    }
  },
  "usage": { "input_tokens": 63, "output_tokens": 86 },
  "evaluation_time_ms": 85.9,
  "request_id": "req_5b7a9c1e3d2f4a6b8c0d1e2f3a4b5c6d"
}

choice is the label with the highest probability. probabilities has one entry per label you defined, so you can see how far behind the other labels were before you act.

Next steps

You have a working call. The guides below cover the parts a real integration needs.

On this page