> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.empiriolabs.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.empiriolabs.ai/_mcp/server.

# Create a decision

POST https://api.empiriolabs.ai/v1/decisions
Content-Type: application/json

Answer typed questions about a `state` with calibrated probabilities.
A decision model reads the state (text, a JSON object or array, and any
images, audio, or video inside it) and answers each entry in
`questions` independently. Every answer carries probabilities and a
confidence value; decision models never generate text.

- `noul`: a yes/no question. Returns the probability of yes.
- `choice`: 2 to 255 named options. Returns the most likely option and
  the probability of each.
- `score`: 2 to 10 ordered levels. Returns the expected level and the
  probability of each level.
- `tool`: 1 to 254 function definitions. Returns the function to call,
  the probability of each, and a distribution for every `enum` and
  `boolean` argument.

Usage counts input tokens only: the state once, the text of each
question, and each media item. `output_tokens` is always 0.

For a state longer than 131,072 tokens, `long_context` sets how it is
read: `fast` (the default) answers faster, and `full` reads every
token. Usage counts the whole state in both modes, and `long_context`
in the response shows which one was used.


Reference: https://docs.empiriolabs.ai/api-reference/api-reference/decisions/create-decision

## Authentication

- `Authorization` header (bearer token, required) — Pass your EmpirioLabs API key as a bearer token. The Anthropic-style `x-api-key` header is also accepted on every endpoint.

## Request

### Body (application/json)

This endpoint expects a DecisionRequest.

- `model` (string, required) — Decision model ID, for example `aplomb-1`. An unknown ID returns `404 model_not_found`.
- `state` (DecisionRequestState, required) — The content to decide about: text, a JSON object, or a JSON array. Put images, audio, or video anywhere inside it as media nodes, for example `{"type": "image", "url": "https://example.com/photo.png"}`. The state is counted once per request, however many questions refer to it.
- `questions` (map from string to DecisionQuestion, required) — Questions keyed by an ID you choose, 1 to 128 per request. Each question has a `type` (`noul`, `choice`, `score`, or `tool`) and `instructions`. A `choice` question takes `criteria` as an object of option name to description or null, a `score` question takes `criteria` as an array of 2 to 10 ordered levels, and a `tool` question takes `tools`, a list of function definitions. IDs cannot contain control characters. A request evaluates at most 512 questions in total, where each `tool` question counts as one plus one per `enum` or `boolean` argument. Each question is answered independently, and answers come back under the same IDs. IDs are not shown to the model.
- `long_context` (enum, optional, default: fast) — How a state longer than 131,072 tokens is read. `fast` answers faster. `full` reads every token of the state; use it when an answer can depend on details anywhere in a long state. Images, audio, and video are read in full in both modes. A state of 131,072 tokens or fewer is always read in full. Usage counts the whole state in both modes.
  - Allowed values: `fast`, `full`

## Response

### 200

One answer per question, keyed by the question IDs from the request.

- `model` (string, required) — The model ID from the request.
- `answers` (map from string to DecisionAnswer, required) — One answer per question, keyed by the question IDs from the request.
- `usage` (DecisionUsage, required) — Tokens counted for a decision request. Only input is counted: the state once, the text of each question, and each media item. There are no output tokens.
- `long_context` (enum, required) — How the state was read: `fast` or `full`. A state of 131,072 tokens or fewer is always read in full, and a `fast` request can also be read in full.
  - Allowed values: `fast`, `full`

## Errors

### 400 Bad Request Error

A media URL cannot be used (`invalid_media_url`), or the model does not accept a media type in the state (`unsupported_media`).

- `error` (DecisionErrorError, required)

### 401 Unauthorized Error

The API key is missing, invalid, inactive, or expired.

- `error` (ErrorError, required)

### 402 Payment Required Error

The account cannot cover the pay-as-you-go amount required by the request (`insufficient_credits`), or the account's spending limit is reached (`spending_limit_reached`). An active plan can run a request at zero balance only when the entire request is covered by remaining allowance. Partly covered requests require enough balance for the full remainder before work starts.

- `error` (ErrorError, required)

### 404 Not Found Error

The `model` ID is unknown (`model_not_found`).

- `error` (DecisionErrorError, required)

### 413 Content Too Large Error

The request body is too large (`request_too_large`). Send large media as a `url` instead of inline `data`.

- `error` (DecisionErrorError, required)

### 422 Unprocessable Entity Error

The request failed validation. `code` is `invalid_request`, `state_too_large`, `too_many_questions`, or `invalid_media`, and the message names the field.

- `error` (DecisionErrorError, required)

### 429 Too Many Requests Error

An account rate limit was reached (`rate_limit_exceeded`). Retry after the number of seconds in the `Retry-After` header.

- `error` (DecisionErrorError, required)

### 503 Service Unavailable Error

The model is temporarily unavailable (`model_unavailable`). Retry after the number of seconds in the `Retry-After` header; the request is safe to retry.

- `error` (DecisionErrorError, required)

## Types

### DecisionRequestState

The content to decide about: text, a JSON object, or a JSON array. Put images, audio, or video anywhere inside it as media nodes, for example `{"type": "image", "url": "https://example.com/photo.png"}`. The state is counted once per request, however many questions refer to it.

- string
- Media node: DecisionMediaNode
- map from string to any
- list of any

### DecisionQuestion

A question about the state. `type` selects the question variant.

- `type`: `noul` (noul)
  - `instructions` (DecisionInstructions, required) — The question to answer. Usually text; an object or array can hold the question in one field and the data it refers to in others.
  - `abstain` (boolean, optional, default: false) — When true, the answer also carries `abstain`, the probability that the state does not contain what the question needs; the rest of the answer assumes that it does.
  - `criteria` (DecisionNoulQuestionCriteria, optional) — Optional descriptions of what counts as yes and what counts as no.
- `type`: `choice` (choice)
  - `criteria` (map from string to string, required) — 2 to 255 options. Each key is an option name, returned unchanged in the answer; each value describes the option, or is null when the name is enough. A choice between exactly two yes/no options, such as `yes` and `no`, returns the same probability as the equivalent `noul` question.
  - `instructions` (DecisionInstructions, required) — The question to answer. Usually text; an object or array can hold the question in one field and the data it refers to in others.
  - `abstain` (boolean, optional, default: false) — When true, the answer also carries `abstain`, the probability that the state does not contain what the question needs; the rest of the answer assumes that it does. A `choice` with `abstain` takes at most 254 options.
- `type`: `score` (score)
  - `criteria` (list of string, required) — 2 to 10 level descriptions, lowest first. Levels are numbered from 0 in this order.
  - `instructions` (DecisionInstructions, required) — The question to answer. Usually text; an object or array can hold the question in one field and the data it refers to in others.
  - `abstain` (boolean, optional, default: false) — When true, the answer also carries `abstain`, the probability that the state does not contain what the question needs; the rest of the answer assumes that it does.
- `type`: `tool` (tool)
  - `instructions` (DecisionInstructions, required) — The question to answer. Usually text; an object or array can hold the question in one field and the data it refers to in others.
  - `tools` (list of DecisionFunctionTool, required) — 1 to 254 function definitions, in the same format as `tools` on the Chat Completions endpoint.
  - `allow_none` (boolean, optional, default: true) — When true, `none` is added as an option, and `tool` in the answer is null when `none` is the most likely option.

### DecisionAnswer

The answer to one question. `type` matches the question type.

- `type`: `noul` (noul)
  - `confidence` (double, required) — How concentrated the distribution is, from 0 (every option equally likely) to 1 (all probability on one option). For n options whose highest probability is p, confidence is `(n * p - 1) / (n - 1)`; for a `noul` answer it is `|2p - 1|`.
  - `noul` (double, required) — Probability that the answer is yes.
  - `abstain` (double, optional) — Present when the question set `abstain` to true: the probability that the state does not contain what the question needs.
- `type`: `choice` (choice)
  - `choice` (string, required) — The most likely option.
  - `confidence` (double, required) — How concentrated the distribution is, from 0 (every option equally likely) to 1 (all probability on one option). For n options whose highest probability is p, confidence is `(n * p - 1) / (n - 1)`; for a `noul` answer it is `|2p - 1|`.
  - `probabilities` (map from string to double, required) — Probability of each option, keyed by option. Values are rounded to at most 8 decimal places. The total is 1, including any separate `none_probability` on a tool answer.
  - `abstain` (double, optional) — Present when the question set `abstain` to true: the probability that the state does not contain what the question needs.
- `type`: `score` (score)
  - `confidence` (double, required) — How concentrated the distribution is, from 0 (every option equally likely) to 1 (all probability on one option). For n options whose highest probability is p, confidence is `(n * p - 1) / (n - 1)`; for a `noul` answer it is `|2p - 1|`.
  - `legend` (map from string to string, required) — Each level number mapped to its description from `criteria`.
  - `probabilities` (map from string to double, required) — Probability of each option, keyed by option. Values are rounded to at most 8 decimal places. The total is 1, including any separate `none_probability` on a tool answer.
  - `score` (double, required) — Expected level, from 0 up to the number of levels minus 1.
  - `abstain` (double, optional) — Present when the question set `abstain` to true: the probability that the state does not contain what the question needs.
- `type`: `tool` (tool)
  - `arguments` (map from string to map from string to DecisionArgumentAnswer, required) — For each function, a distribution for every `enum` and `boolean` argument: which value the argument should take if that function is called. Keyed by function name, then argument name.
  - `confidence` (double, required) — How concentrated the distribution is, from 0 (every option equally likely) to 1 (all probability on one option). For n options whose highest probability is p, confidence is `(n * p - 1) / (n - 1)`; for a `noul` answer it is `|2p - 1|`.
  - `open_arguments` (map from string to list of string, required) — For each function, the arguments that are not `enum` or `boolean`, such as free text. Decision models do not fill these; produce them separately if you need them.
  - `probabilities` (map from string to double, required) — Probability of each option, keyed by option. Values are rounded to at most 8 decimal places. The total is 1, including any separate `none_probability` on a tool answer.
  - `tool` (string, required, nullable) — The most likely function name, returned unchanged, or null when no function applies. A function may be named `none`.
  - `none_probability` (double, optional) — Present when a supplied function is named `none` and `allow_none` is true. This is the probability that no function applies; `probabilities.none` then belongs to the actual function. Together these probabilities sum to 1.

### DecisionUsage

Tokens counted for a decision request. Only input is counted: the state once, the text of each question, and each media item. There are no output tokens.

- `input_tokens` (integer, required) — Total input tokens for the request, the sum of `input_tokens_details`.
- `output_tokens` (integer, required) — Always 0. Decision models do not generate text.
- `input_tokens_details` (DecisionUsageInputTokensDetails, required) — Input tokens by modality.

### DecisionErrorError

- `code` (string, required) — Machine-readable error code, for example `invalid_request` or `model_unavailable`.
- `message` (string, required) — Explanation of the error. Validation errors name the offending field.

### ErrorError

- `message` (string, required) — What went wrong. For a request error it names the field to fix.
- `type` (string, required) — Error category, which follows the HTTP status: `insufficient_quota` for `402`, `requests` or `tokens` for a `429` (the limit that was reached), and `server_error` for a `5xx`. Other errors are `invalid_request_error`, or a more specific category such as `authentication_error`, `permission_error`, or `not_found_error`.
- `param` (string, required, nullable) — The request field the error is about, or null.
- `code` (string, required, nullable) — Machine-readable error code, for example `invalid_value`, `missing_required_parameter`, `invalid_api_key`, `insufficient_credits`, `model_not_found`, or `rate_limit_exceeded`. Null when the error has no code.
- `request_id` (string, required) — Request identifier. Include it when you contact support.

### DecisionMediaNode

An image, audio clip, or video inside `state`. Send a public `https://` URL in `url`, or the file as base64 in `data` with its MIME type in `mime`.

- `type` (enum, required)
  - Allowed values: `image`, `audio`, `video`
- `url` (string, optional) — Public `https://` URL of the file. Send either `url`, or `data` with `mime`.
- `data` (string, optional) — The file as base64. Requires `mime`.
- `mime` (string, optional) — MIME type of `data`, for example `image/png`.

### DecisionInstructions

The question to answer. Usually text; an object or array can hold the question in one field and the data it refers to in others.

- string
- map from string to any
- list of any

### DecisionNoulQuestionCriteria

Optional descriptions of what counts as yes and what counts as no.

- `true` (string, optional) — What counts as yes.
- `false` (string, optional) — What counts as no.

### DecisionFunctionTool

- `type` (enum, required)
  - Allowed values: `function`
- `function` (DecisionFunctionToolFunction, required)

### DecisionArgumentAnswer

The answer for one argument. `enum` arguments carry `probabilities`; `boolean` arguments carry `probability_true`.

- `value` (DecisionArgumentAnswerValue, required) — The most likely value.
- `confidence` (double, required) — How concentrated the distribution is, from 0 (every option equally likely) to 1 (all probability on one option). For n options whose highest probability is p, confidence is `(n * p - 1) / (n - 1)`; for a `noul` answer it is `|2p - 1|`.
- `probabilities` (map from string to double, optional) — Probability of each option, keyed by option. Values are rounded to at most 8 decimal places. The total is 1, including any separate `none_probability` on a tool answer.
- `probability_true` (double, optional) — Probability that the argument is true. Present for `boolean` arguments.

### DecisionUsageInputTokensDetails

Input tokens by modality.

- `text_tokens` (integer, optional) — Tokens for the text of the state and the questions.
- `image_tokens` (integer, optional) — Tokens for images, at most 640 per image.
- `audio_tokens` (integer, optional) — Tokens for audio, about 13 per second.
- `video_tokens` (integer, optional) — Tokens for video, at most 256 per frame.

### DecisionFunctionToolFunction

- `name` (string, required) — Function name. Answers refer to the function by this name.
- `description` (string, optional) — What the function does. Used when choosing between functions.
- `parameters` (DecisionFunctionToolFunctionParameters, optional) — JSON Schema for the function arguments. Every `enum` and `boolean` argument gets its own distribution in the answer; other arguments are listed in `open_arguments`.

### DecisionArgumentAnswerValue

The most likely value.

- string
- boolean

### DecisionFunctionToolFunctionParameters

JSON Schema for the function arguments. Every `enum` and `boolean` argument gets its own distribution in the answer; other arguments are listed in `open_arguments`.

## Examples

### Route a support message

**Request**

```json
{
  "model": "aplomb-1",
  "state": {
    "channel": "email",
    "message": "I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today."
  },
  "questions": {
    "is_urgent": {
      "type": "noul",
      "instructions": "Does the customer need a resolution today?"
    },
    "department": {
      "type": "choice",
      "criteria": {
        "billing": "Charges, refunds, and invoices",
        "technical": "Bugs, errors, and outages",
        "sales": "Plans, pricing, and upgrades"
      },
      "instructions": "Which team should handle this message?"
    },
    "frustration": {
      "type": "score",
      "criteria": [
        "Calm",
        "Frustrated",
        "Very angry"
      ],
      "instructions": "How frustrated is the customer?"
    }
  }
}
```

**Response**

```json
{
  "model": "aplomb-1",
  "answers": {
    "is_urgent": {
      "type": "noul",
      "confidence": 0.8824,
      "noul": 0.9412
    },
    "department": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.82,
      "probabilities": {
        "billing": 0.88,
        "technical": 0.11,
        "sales": 0.01
      }
    },
    "frustration": {
      "type": "score",
      "confidence": 0.865,
      "legend": {
        "0": "Calm",
        "1": "Frustrated",
        "2": "Very angry"
      },
      "probabilities": {
        "0": 0.02,
        "1": 0.91,
        "2": 0.07
      },
      "score": 1.05
    }
  },
  "usage": {
    "input_tokens": 212,
    "output_tokens": 0,
    "input_tokens_details": {
      "text_tokens": 212,
      "image_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "long_context": "full"
}
```

**SDK Code**

```python Route a support message
import requests

url = "https://api.empiriolabs.ai/v1/decisions"

payload = {
    "model": "aplomb-1",
    "state": {
        "channel": "email",
        "message": "I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today."
    },
    "questions": {
        "is_urgent": {
            "type": "noul",
            "instructions": "Does the customer need a resolution today?"
        },
        "department": {
            "type": "choice",
            "criteria": {
                "billing": "Charges, refunds, and invoices",
                "technical": "Bugs, errors, and outages",
                "sales": "Plans, pricing, and upgrades"
            },
            "instructions": "Which team should handle this message?"
        },
        "frustration": {
            "type": "score",
            "criteria": ["Calm", "Frustrated", "Very angry"],
            "instructions": "How frustrated is the customer?"
        }
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Route a support message
const url = 'https://api.empiriolabs.ai/v1/decisions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"aplomb-1","state":{"channel":"email","message":"I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today."},"questions":{"is_urgent":{"type":"noul","instructions":"Does the customer need a resolution today?"},"department":{"type":"choice","criteria":{"billing":"Charges, refunds, and invoices","technical":"Bugs, errors, and outages","sales":"Plans, pricing, and upgrades"},"instructions":"Which team should handle this message?"},"frustration":{"type":"score","criteria":["Calm","Frustrated","Very angry"],"instructions":"How frustrated is the customer?"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Route a support message
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.empiriolabs.ai/v1/decisions"

	payload := strings.NewReader("{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"channel\": \"email\",\n    \"message\": \"I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today.\"\n  },\n  \"questions\": {\n    \"is_urgent\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the customer need a resolution today?\"\n    },\n    \"department\": {\n      \"type\": \"choice\",\n      \"criteria\": {\n        \"billing\": \"Charges, refunds, and invoices\",\n        \"technical\": \"Bugs, errors, and outages\",\n        \"sales\": \"Plans, pricing, and upgrades\"\n      },\n      \"instructions\": \"Which team should handle this message?\"\n    },\n    \"frustration\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Calm\",\n        \"Frustrated\",\n        \"Very angry\"\n      ],\n      \"instructions\": \"How frustrated is the customer?\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Route a support message
require 'uri'
require 'net/http'

url = URI("https://api.empiriolabs.ai/v1/decisions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"channel\": \"email\",\n    \"message\": \"I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today.\"\n  },\n  \"questions\": {\n    \"is_urgent\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the customer need a resolution today?\"\n    },\n    \"department\": {\n      \"type\": \"choice\",\n      \"criteria\": {\n        \"billing\": \"Charges, refunds, and invoices\",\n        \"technical\": \"Bugs, errors, and outages\",\n        \"sales\": \"Plans, pricing, and upgrades\"\n      },\n      \"instructions\": \"Which team should handle this message?\"\n    },\n    \"frustration\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Calm\",\n        \"Frustrated\",\n        \"Very angry\"\n      ],\n      \"instructions\": \"How frustrated is the customer?\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Route a support message
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.empiriolabs.ai/v1/decisions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"channel\": \"email\",\n    \"message\": \"I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today.\"\n  },\n  \"questions\": {\n    \"is_urgent\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the customer need a resolution today?\"\n    },\n    \"department\": {\n      \"type\": \"choice\",\n      \"criteria\": {\n        \"billing\": \"Charges, refunds, and invoices\",\n        \"technical\": \"Bugs, errors, and outages\",\n        \"sales\": \"Plans, pricing, and upgrades\"\n      },\n      \"instructions\": \"Which team should handle this message?\"\n    },\n    \"frustration\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Calm\",\n        \"Frustrated\",\n        \"Very angry\"\n      ],\n      \"instructions\": \"How frustrated is the customer?\"\n    }\n  }\n}")
  .asString();
```

```php Route a support message
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.empiriolabs.ai/v1/decisions', [
  'body' => '{
  "model": "aplomb-1",
  "state": {
    "channel": "email",
    "message": "I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today."
  },
  "questions": {
    "is_urgent": {
      "type": "noul",
      "instructions": "Does the customer need a resolution today?"
    },
    "department": {
      "type": "choice",
      "criteria": {
        "billing": "Charges, refunds, and invoices",
        "technical": "Bugs, errors, and outages",
        "sales": "Plans, pricing, and upgrades"
      },
      "instructions": "Which team should handle this message?"
    },
    "frustration": {
      "type": "score",
      "criteria": [
        "Calm",
        "Frustrated",
        "Very angry"
      ],
      "instructions": "How frustrated is the customer?"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Route a support message
using RestSharp;

var client = new RestClient("https://api.empiriolabs.ai/v1/decisions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"channel\": \"email\",\n    \"message\": \"I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today.\"\n  },\n  \"questions\": {\n    \"is_urgent\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the customer need a resolution today?\"\n    },\n    \"department\": {\n      \"type\": \"choice\",\n      \"criteria\": {\n        \"billing\": \"Charges, refunds, and invoices\",\n        \"technical\": \"Bugs, errors, and outages\",\n        \"sales\": \"Plans, pricing, and upgrades\"\n      },\n      \"instructions\": \"Which team should handle this message?\"\n    },\n    \"frustration\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Calm\",\n        \"Frustrated\",\n        \"Very angry\"\n      ],\n      \"instructions\": \"How frustrated is the customer?\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Route a support message
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "aplomb-1",
  "state": [
    "channel": "email",
    "message": "I was charged twice for my subscription this month. This is the third time I have written about it. Please refund the duplicate charge today."
  ],
  "questions": [
    "is_urgent": [
      "type": "noul",
      "instructions": "Does the customer need a resolution today?"
    ],
    "department": [
      "type": "choice",
      "criteria": [
        "billing": "Charges, refunds, and invoices",
        "technical": "Bugs, errors, and outages",
        "sales": "Plans, pricing, and upgrades"
      ],
      "instructions": "Which team should handle this message?"
    ],
    "frustration": [
      "type": "score",
      "criteria": ["Calm", "Frustrated", "Very angry"],
      "instructions": "How frustrated is the customer?"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.empiriolabs.ai/v1/decisions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Check a photo against a listing

**Request**

```json
{
  "model": "aplomb-1",
  "state": {
    "listing_title": "Three-seat leather sofa, like new",
    "photo": {
      "type": "image",
      "url": "https://example.com/listing-photo.png"
    }
  },
  "questions": {
    "matches_title": {
      "type": "noul",
      "instructions": "Does the photo show the item described in listing_title?"
    },
    "condition": {
      "type": "score",
      "criteria": [
        "Damaged",
        "Worn",
        "Good",
        "Like new"
      ],
      "instructions": "Rate the condition of the item in the photo."
    }
  }
}
```

**Response**

```json
{
  "model": "aplomb-1",
  "answers": {
    "matches_title": {
      "type": "noul",
      "confidence": 0.946,
      "noul": 0.973
    },
    "condition": {
      "type": "score",
      "confidence": 0.7067,
      "legend": {
        "0": "Damaged",
        "1": "Worn",
        "2": "Good",
        "3": "Like new"
      },
      "probabilities": {
        "0": 0.01,
        "1": 0.03,
        "2": 0.18,
        "3": 0.78
      },
      "score": 2.73
    }
  },
  "usage": {
    "input_tokens": 694,
    "output_tokens": 0,
    "input_tokens_details": {
      "text_tokens": 54,
      "image_tokens": 640,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "long_context": "full"
}
```

**SDK Code**

```python Check a photo against a listing
import requests

url = "https://api.empiriolabs.ai/v1/decisions"

payload = {
    "model": "aplomb-1",
    "state": {
        "listing_title": "Three-seat leather sofa, like new",
        "photo": {
            "type": "image",
            "url": "https://example.com/listing-photo.png"
        }
    },
    "questions": {
        "matches_title": {
            "type": "noul",
            "instructions": "Does the photo show the item described in listing_title?"
        },
        "condition": {
            "type": "score",
            "criteria": ["Damaged", "Worn", "Good", "Like new"],
            "instructions": "Rate the condition of the item in the photo."
        }
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Check a photo against a listing
const url = 'https://api.empiriolabs.ai/v1/decisions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"aplomb-1","state":{"listing_title":"Three-seat leather sofa, like new","photo":{"type":"image","url":"https://example.com/listing-photo.png"}},"questions":{"matches_title":{"type":"noul","instructions":"Does the photo show the item described in listing_title?"},"condition":{"type":"score","criteria":["Damaged","Worn","Good","Like new"],"instructions":"Rate the condition of the item in the photo."}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Check a photo against a listing
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.empiriolabs.ai/v1/decisions"

	payload := strings.NewReader("{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"listing_title\": \"Three-seat leather sofa, like new\",\n    \"photo\": {\n      \"type\": \"image\",\n      \"url\": \"https://example.com/listing-photo.png\"\n    }\n  },\n  \"questions\": {\n    \"matches_title\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the photo show the item described in listing_title?\"\n    },\n    \"condition\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Damaged\",\n        \"Worn\",\n        \"Good\",\n        \"Like new\"\n      ],\n      \"instructions\": \"Rate the condition of the item in the photo.\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Check a photo against a listing
require 'uri'
require 'net/http'

url = URI("https://api.empiriolabs.ai/v1/decisions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"listing_title\": \"Three-seat leather sofa, like new\",\n    \"photo\": {\n      \"type\": \"image\",\n      \"url\": \"https://example.com/listing-photo.png\"\n    }\n  },\n  \"questions\": {\n    \"matches_title\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the photo show the item described in listing_title?\"\n    },\n    \"condition\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Damaged\",\n        \"Worn\",\n        \"Good\",\n        \"Like new\"\n      ],\n      \"instructions\": \"Rate the condition of the item in the photo.\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Check a photo against a listing
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.empiriolabs.ai/v1/decisions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"listing_title\": \"Three-seat leather sofa, like new\",\n    \"photo\": {\n      \"type\": \"image\",\n      \"url\": \"https://example.com/listing-photo.png\"\n    }\n  },\n  \"questions\": {\n    \"matches_title\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the photo show the item described in listing_title?\"\n    },\n    \"condition\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Damaged\",\n        \"Worn\",\n        \"Good\",\n        \"Like new\"\n      ],\n      \"instructions\": \"Rate the condition of the item in the photo.\"\n    }\n  }\n}")
  .asString();
```

```php Check a photo against a listing
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.empiriolabs.ai/v1/decisions', [
  'body' => '{
  "model": "aplomb-1",
  "state": {
    "listing_title": "Three-seat leather sofa, like new",
    "photo": {
      "type": "image",
      "url": "https://example.com/listing-photo.png"
    }
  },
  "questions": {
    "matches_title": {
      "type": "noul",
      "instructions": "Does the photo show the item described in listing_title?"
    },
    "condition": {
      "type": "score",
      "criteria": [
        "Damaged",
        "Worn",
        "Good",
        "Like new"
      ],
      "instructions": "Rate the condition of the item in the photo."
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Check a photo against a listing
using RestSharp;

var client = new RestClient("https://api.empiriolabs.ai/v1/decisions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"aplomb-1\",\n  \"state\": {\n    \"listing_title\": \"Three-seat leather sofa, like new\",\n    \"photo\": {\n      \"type\": \"image\",\n      \"url\": \"https://example.com/listing-photo.png\"\n    }\n  },\n  \"questions\": {\n    \"matches_title\": {\n      \"type\": \"noul\",\n      \"instructions\": \"Does the photo show the item described in listing_title?\"\n    },\n    \"condition\": {\n      \"type\": \"score\",\n      \"criteria\": [\n        \"Damaged\",\n        \"Worn\",\n        \"Good\",\n        \"Like new\"\n      ],\n      \"instructions\": \"Rate the condition of the item in the photo.\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Check a photo against a listing
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "aplomb-1",
  "state": [
    "listing_title": "Three-seat leather sofa, like new",
    "photo": [
      "type": "image",
      "url": "https://example.com/listing-photo.png"
    ]
  ],
  "questions": [
    "matches_title": [
      "type": "noul",
      "instructions": "Does the photo show the item described in listing_title?"
    ],
    "condition": [
      "type": "score",
      "criteria": ["Damaged", "Worn", "Good", "Like new"],
      "instructions": "Rate the condition of the item in the photo."
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.empiriolabs.ai/v1/decisions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Choose a function to call

**Request**

```json
{
  "model": "aplomb-1",
  "state": "Customer: Can you move my Thursday appointment to Friday morning?",
  "questions": {
    "next_action": {
      "type": "tool",
      "instructions": "Which function should handle this request?",
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "reschedule_appointment",
            "description": "Move an existing appointment to a new day and time.",
            "parameters": {
              "type": "object",
              "properties": {
                "day": {
                  "type": "string",
                  "enum": [
                    "monday",
                    "tuesday",
                    "wednesday",
                    "thursday",
                    "friday"
                  ]
                },
                "time_of_day": {
                  "type": "string",
                  "enum": [
                    "morning",
                    "afternoon",
                    "evening"
                  ]
                },
                "notify_by_sms": {
                  "type": "boolean"
                },
                "note": {
                  "type": "string"
                }
              },
              "required": [
                "day",
                "time_of_day"
              ]
            }
          }
        },
        {
          "type": "function",
          "function": {
            "name": "cancel_appointment",
            "description": "Cancel an existing appointment.",
            "parameters": {
              "type": "object",
              "properties": {}
            }
          }
        }
      ]
    }
  }
}
```

**Response**

```json
{
  "model": "aplomb-1",
  "answers": {
    "next_action": {
      "type": "tool",
      "arguments": {
        "reschedule_appointment": {
          "day": {
            "value": "friday",
            "confidence": 0.9375,
            "probabilities": {
              "monday": 0.001,
              "tuesday": 0.002,
              "wednesday": 0.007,
              "thursday": 0.04,
              "friday": 0.95
            }
          },
          "time_of_day": {
            "value": "morning",
            "confidence": 0.895,
            "probabilities": {
              "morning": 0.93,
              "afternoon": 0.05,
              "evening": 0.02
            }
          },
          "notify_by_sms": {
            "value": false,
            "confidence": 0.76,
            "probability_true": 0.12
          }
        }
      },
      "confidence": 0.94,
      "open_arguments": {
        "reschedule_appointment": [
          "note"
        ]
      },
      "probabilities": {
        "reschedule_appointment": 0.96,
        "cancel_appointment": 0.01,
        "none": 0.03
      },
      "tool": "reschedule_appointment"
    }
  },
  "usage": {
    "input_tokens": 187,
    "output_tokens": 0,
    "input_tokens_details": {
      "text_tokens": 187,
      "image_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "long_context": "full"
}
```

**SDK Code**

```python Choose a function to call
import requests

url = "https://api.empiriolabs.ai/v1/decisions"

payload = {
    "model": "aplomb-1",
    "state": "Customer: Can you move my Thursday appointment to Friday morning?",
    "questions": { "next_action": {
            "type": "tool",
            "instructions": "Which function should handle this request?",
            "tools": [
                {
                    "type": "function",
                    "function": {
                        "name": "reschedule_appointment",
                        "description": "Move an existing appointment to a new day and time.",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "day": {
                                    "type": "string",
                                    "enum": ["monday", "tuesday", "wednesday", "thursday", "friday"]
                                },
                                "time_of_day": {
                                    "type": "string",
                                    "enum": ["morning", "afternoon", "evening"]
                                },
                                "notify_by_sms": { "type": "boolean" },
                                "note": { "type": "string" }
                            },
                            "required": ["day", "time_of_day"]
                        }
                    }
                },
                {
                    "type": "function",
                    "function": {
                        "name": "cancel_appointment",
                        "description": "Cancel an existing appointment.",
                        "parameters": {
                            "type": "object",
                            "properties": {}
                        }
                    }
                }
            ]
        } }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Choose a function to call
const url = 'https://api.empiriolabs.ai/v1/decisions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"aplomb-1","state":"Customer: Can you move my Thursday appointment to Friday morning?","questions":{"next_action":{"type":"tool","instructions":"Which function should handle this request?","tools":[{"type":"function","function":{"name":"reschedule_appointment","description":"Move an existing appointment to a new day and time.","parameters":{"type":"object","properties":{"day":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday"]},"time_of_day":{"type":"string","enum":["morning","afternoon","evening"]},"notify_by_sms":{"type":"boolean"},"note":{"type":"string"}},"required":["day","time_of_day"]}}},{"type":"function","function":{"name":"cancel_appointment","description":"Cancel an existing appointment.","parameters":{"type":"object","properties":{}}}}]}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Choose a function to call
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.empiriolabs.ai/v1/decisions"

	payload := strings.NewReader("{\n  \"model\": \"aplomb-1\",\n  \"state\": \"Customer: Can you move my Thursday appointment to Friday morning?\",\n  \"questions\": {\n    \"next_action\": {\n      \"type\": \"tool\",\n      \"instructions\": \"Which function should handle this request?\",\n      \"tools\": [\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"reschedule_appointment\",\n            \"description\": \"Move an existing appointment to a new day and time.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"monday\",\n                    \"tuesday\",\n                    \"wednesday\",\n                    \"thursday\",\n                    \"friday\"\n                  ]\n                },\n                \"time_of_day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"morning\",\n                    \"afternoon\",\n                    \"evening\"\n                  ]\n                },\n                \"notify_by_sms\": {\n                  \"type\": \"boolean\"\n                },\n                \"note\": {\n                  \"type\": \"string\"\n                }\n              },\n              \"required\": [\n                \"day\",\n                \"time_of_day\"\n              ]\n            }\n          }\n        },\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"cancel_appointment\",\n            \"description\": \"Cancel an existing appointment.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {}\n            }\n          }\n        }\n      ]\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Choose a function to call
require 'uri'
require 'net/http'

url = URI("https://api.empiriolabs.ai/v1/decisions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"aplomb-1\",\n  \"state\": \"Customer: Can you move my Thursday appointment to Friday morning?\",\n  \"questions\": {\n    \"next_action\": {\n      \"type\": \"tool\",\n      \"instructions\": \"Which function should handle this request?\",\n      \"tools\": [\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"reschedule_appointment\",\n            \"description\": \"Move an existing appointment to a new day and time.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"monday\",\n                    \"tuesday\",\n                    \"wednesday\",\n                    \"thursday\",\n                    \"friday\"\n                  ]\n                },\n                \"time_of_day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"morning\",\n                    \"afternoon\",\n                    \"evening\"\n                  ]\n                },\n                \"notify_by_sms\": {\n                  \"type\": \"boolean\"\n                },\n                \"note\": {\n                  \"type\": \"string\"\n                }\n              },\n              \"required\": [\n                \"day\",\n                \"time_of_day\"\n              ]\n            }\n          }\n        },\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"cancel_appointment\",\n            \"description\": \"Cancel an existing appointment.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {}\n            }\n          }\n        }\n      ]\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Choose a function to call
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.empiriolabs.ai/v1/decisions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"aplomb-1\",\n  \"state\": \"Customer: Can you move my Thursday appointment to Friday morning?\",\n  \"questions\": {\n    \"next_action\": {\n      \"type\": \"tool\",\n      \"instructions\": \"Which function should handle this request?\",\n      \"tools\": [\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"reschedule_appointment\",\n            \"description\": \"Move an existing appointment to a new day and time.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"monday\",\n                    \"tuesday\",\n                    \"wednesday\",\n                    \"thursday\",\n                    \"friday\"\n                  ]\n                },\n                \"time_of_day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"morning\",\n                    \"afternoon\",\n                    \"evening\"\n                  ]\n                },\n                \"notify_by_sms\": {\n                  \"type\": \"boolean\"\n                },\n                \"note\": {\n                  \"type\": \"string\"\n                }\n              },\n              \"required\": [\n                \"day\",\n                \"time_of_day\"\n              ]\n            }\n          }\n        },\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"cancel_appointment\",\n            \"description\": \"Cancel an existing appointment.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {}\n            }\n          }\n        }\n      ]\n    }\n  }\n}")
  .asString();
```

```php Choose a function to call
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.empiriolabs.ai/v1/decisions', [
  'body' => '{
  "model": "aplomb-1",
  "state": "Customer: Can you move my Thursday appointment to Friday morning?",
  "questions": {
    "next_action": {
      "type": "tool",
      "instructions": "Which function should handle this request?",
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "reschedule_appointment",
            "description": "Move an existing appointment to a new day and time.",
            "parameters": {
              "type": "object",
              "properties": {
                "day": {
                  "type": "string",
                  "enum": [
                    "monday",
                    "tuesday",
                    "wednesday",
                    "thursday",
                    "friday"
                  ]
                },
                "time_of_day": {
                  "type": "string",
                  "enum": [
                    "morning",
                    "afternoon",
                    "evening"
                  ]
                },
                "notify_by_sms": {
                  "type": "boolean"
                },
                "note": {
                  "type": "string"
                }
              },
              "required": [
                "day",
                "time_of_day"
              ]
            }
          }
        },
        {
          "type": "function",
          "function": {
            "name": "cancel_appointment",
            "description": "Cancel an existing appointment.",
            "parameters": {
              "type": "object",
              "properties": {}
            }
          }
        }
      ]
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Choose a function to call
using RestSharp;

var client = new RestClient("https://api.empiriolabs.ai/v1/decisions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"aplomb-1\",\n  \"state\": \"Customer: Can you move my Thursday appointment to Friday morning?\",\n  \"questions\": {\n    \"next_action\": {\n      \"type\": \"tool\",\n      \"instructions\": \"Which function should handle this request?\",\n      \"tools\": [\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"reschedule_appointment\",\n            \"description\": \"Move an existing appointment to a new day and time.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {\n                \"day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"monday\",\n                    \"tuesday\",\n                    \"wednesday\",\n                    \"thursday\",\n                    \"friday\"\n                  ]\n                },\n                \"time_of_day\": {\n                  \"type\": \"string\",\n                  \"enum\": [\n                    \"morning\",\n                    \"afternoon\",\n                    \"evening\"\n                  ]\n                },\n                \"notify_by_sms\": {\n                  \"type\": \"boolean\"\n                },\n                \"note\": {\n                  \"type\": \"string\"\n                }\n              },\n              \"required\": [\n                \"day\",\n                \"time_of_day\"\n              ]\n            }\n          }\n        },\n        {\n          \"type\": \"function\",\n          \"function\": {\n            \"name\": \"cancel_appointment\",\n            \"description\": \"Cancel an existing appointment.\",\n            \"parameters\": {\n              \"type\": \"object\",\n              \"properties\": {}\n            }\n          }\n        }\n      ]\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Choose a function to call
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "aplomb-1",
  "state": "Customer: Can you move my Thursday appointment to Friday morning?",
  "questions": ["next_action": [
      "type": "tool",
      "instructions": "Which function should handle this request?",
      "tools": [
        [
          "type": "function",
          "function": [
            "name": "reschedule_appointment",
            "description": "Move an existing appointment to a new day and time.",
            "parameters": [
              "type": "object",
              "properties": [
                "day": [
                  "type": "string",
                  "enum": ["monday", "tuesday", "wednesday", "thursday", "friday"]
                ],
                "time_of_day": [
                  "type": "string",
                  "enum": ["morning", "afternoon", "evening"]
                ],
                "notify_by_sms": ["type": "boolean"],
                "note": ["type": "string"]
              ],
              "required": ["day", "time_of_day"]
            ]
          ]
        ],
        [
          "type": "function",
          "function": [
            "name": "cancel_appointment",
            "description": "Cancel an existing appointment.",
            "parameters": [
              "type": "object",
              "properties": []
            ]
          ]
        ]
      ]
    ]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.empiriolabs.ai/v1/decisions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```