AI

Answer typed questions with probabilities

Evaluates each question independently against the same input and returns calibrated probabilities - no generated text. Question types: predicate (probability a statement is true), choice (pick one value) and score (an ordered scale; score is the probability-weighted mean of 0-based level indices). confidence is computed by B4M with one published formula for every model. Answers come back in question order; a question the model declines is a refusal answer and does not fail the request. input is a string or a list of text, json and image parts; an image is a file_id you can read or a base64 data: URL (http(s) URLs are rejected). Platform ceilings: 50 questions, 64 choices, 2-10 levels and 8 images; each model's own caps are listed by GET /api/v1/decision-models and a request over one is a 422 naming the cap and param. Probabilities are not comparable across models: tune thresholds per model against labelled examples, and pin a versioned model id when you do. A busy provider is retried once on the same model, never another; after that the response is a 503 with Retry-After. Billed per input and output token at the model's rate, settled to the exact expected cost (most calls charge 0 credits, some 1). Authenticate with an API key (b4m_live_) carrying ai:decide or ai:generate, or a JWT.

post/api/v1/decisions

Request

  • Base URL: https://your-deployment.example.com
  • URL: https://your-deployment.example.com/api/v1/decisions
  • Auth: one of:
    • HTTP bearer
    • API key in header x-api-key

Request body

modelstring required

A decision model id from GET /api/v1/decision-models.

safety_identifierstring

A stable, non-identifying id for your end user. Defaults to a hash of the B4M user id.

Example request

{
  "model": "gpt-6-luna",
  "input": [
    {
      "type": "text",
      "text": "Help! My payouts have been failing for 3 days."
    },
    {
      "type": "json",
      "json": {
        "plan": "pro",
        "open_tickets": 2
      }
    }
  ],
  "questions": [
    {
      "type": "predicate",
      "name": "is_urgent",
      "instructions": "The customer needs a reply within 24 hours."
    },
    {
      "type": "choice",
      "name": "team",
      "instructions": "Which team should handle this?",
      "choices": [
        {
          "value": "billing",
          "description": "Payments, payouts, refunds"
        },
        {
          "value": "technical",
          "description": "Bugs, outages"
        },
        {
          "value": "sales"
        }
      ]
    },
    {
      "type": "score",
      "name": "frustration",
      "instructions": "How frustrated is the customer?",
      "levels": [
        {
          "label": "calm"
        },
        {
          "label": "frustrated"
        },
        {
          "label": "angry",
          "description": "Threatens to churn"
        }
      ]
    }
  ]
}

Response

One answer per question, in question order.

idstring required

Unique per decision.

object'decision' required
modelstring required

The resolved model version. Pin it when you tune thresholds.

Example response

{
  "id": "dec_8f14e45fceea167a5a36dedd4bea2543",
  "object": "decision",
  "model": "gpt-6-luna",
  "answers": [
    {
      "type": "predicate",
      "name": "is_urgent",
      "probability": 0.93
    },
    {
      "type": "choice",
      "name": "team",
      "choice": "billing",
      "probabilities": [
        {
          "value": "billing",
          "probability": 0.88
        },
        {
          "value": "technical",
          "probability": 0.1
        },
        {
          "value": "sales",
          "probability": 0.02
        }
      ],
      "confidence": 0.82
    },
    {
      "type": "score",
      "name": "frustration",
      "score": 1.1,
      "probabilities": [
        {
          "value": 0,
          "label": "calm",
          "probability": 0.1
        },
        {
          "value": 1,
          "label": "frustrated",
          "probability": 0.7
        },
        {
          "value": 2,
          "label": "angry",
          "probability": 0.2
        }
      ],
      "confidence": 0.55
    }
  ],
  "usage": {
    "input_tokens": 412,
    "output_tokens": 0,
    "total_tokens": 412
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.