> ## Documentation Index
> Fetch the complete documentation index at: https://exa.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Exa API is served at https://api.exa.ai. Authenticate with `Authorization: Bearer $EXA_API_KEY` (or `x-api-key: $EXA_API_KEY`); create keys at https://dashboard.exa.ai/api-keys?utm_source=docs&utm_medium=docs&utm_campaign=markdown_instructions. Every way an agent can get access to Exa is described at https://exa.ai/auth.md.
> Prefer the official SDKs, `exa-py` (`pip install exa-py`) and `exa-js` (`npm install exa-js`); both read `EXA_API_KEY` from the environment.
> Tool-using agents can call Exa without writing code through the hosted MCP server at https://mcp.exa.ai/mcp, or install the Exa agent skill with `npx skills add exa-labs/agent-skills` (skill file: https://exa.ai/docs/skill.md).
> The OpenAPI specs at https://exa.ai/docs/exa-spec.yaml and https://exa.ai/docs/team-management-spec.yaml are the source of truth for request and response schemas.

# Exa Decisions

> Ask structured questions about the results a search retrieves and get typed answers your code can act on.

Exa Decisions lets you ask structured questions about the results a search retrieves and get typed answers your code can act on. Add `decisions` to a `/search` request with up to 100 named questions. Each answer comes back as a probability or a pick with probabilities, not generated text.

Use it to qualify sales accounts, triage insurance claims and applications, or route business and identity verification (KYB and KYC) cases, with one request per subject.

Exa Decisions is powered by Jev from [TypeSafe](https://typesafe.ai).

> [!NOTE]
>
> Decisions add no charge beyond standard Search pricing. A request is billed at its search type's price.

## Ask your first questions

Put your questions in `decisions.questions`, keyed by a name you choose. Each question has a `type`, `instructions` that say what to decide, and `criteria` for its options or levels.

```python Python theme={null}
from exa_py import Exa

exa = Exa()

result = exa.search(
    "Mailgun (https://www.mailgun.com) company",
    num_results=10,
    contents={"highlights": True},
    decisions={
        "decision_prompt": "Answer about Mailgun, the company at https://www.mailgun.com. Ignore other companies with a similar name.",
        "questions": {
            "status": {
                "type": "choice",
                "instructions": "What is Mailgun's status today?",
                "criteria": {
                    "operating": "Still operating as an independent company, private or public",
                    "acquired": "Acquired by or merged into another company",
                    "shut_down": "Shut down or stopped operating",
                },
            },
            "sells_to_businesses": {
                "type": "noul",
                "instructions": "Does Mailgun sell mainly to businesses rather than to consumers?",
            },
            "fit": {
                "type": "score",
                "instructions": "How well does Mailgun match our customer, a company that builds software for developers or data teams?",
                "criteria": [
                    "Not a software company",
                    "Software, but not for developers or data teams",
                    "Software partly for developers or data teams",
                    "Builds software for developers or data teams",
                ],
            },
        },
    },
)

assert result.decisions is not None
answers = result.decisions.answers

status = answers["status"]
if status.type == "choice":
    print(status.choice, status.probabilities[status.choice], status.confidence)

sells_to_businesses = answers["sells_to_businesses"]
if sells_to_businesses.type == "noul":
    print(sells_to_businesses.noul)

fit = answers["fit"]
if fit.type == "score":
    print(fit.score, fit.legend["3"], fit.probabilities["3"], fit.confidence)
```

```javascript JavaScript theme={null}
import Exa from "exa-js";

const exa = new Exa();

const result = await exa.search("Mailgun (https://www.mailgun.com) company", {
  numResults: 10,
  contents: { highlights: true },
  decisions: {
    decisionPrompt:
      "Answer about Mailgun, the company at https://www.mailgun.com. Ignore other companies with a similar name.",
    questions: {
      status: {
        type: "choice",
        instructions: "What is Mailgun's status today?",
        criteria: {
          operating: "Still operating as an independent company, private or public",
          acquired: "Acquired by or merged into another company",
          shut_down: "Shut down or stopped operating"
        }
      },
      sells_to_businesses: {
        type: "noul",
        instructions: "Does Mailgun sell mainly to businesses rather than to consumers?"
      },
      fit: {
        type: "score",
        instructions:
          "How well does Mailgun match our customer, a company that builds software for developers or data teams?",
        criteria: [
          "Not a software company",
          "Software, but not for developers or data teams",
          "Software partly for developers or data teams",
          "Builds software for developers or data teams"
        ]
      }
    }
  }
});

const status = result.decisions?.answers.status;
if (status?.type === "choice") {
  console.log(status.choice, status.probabilities[status.choice], status.confidence);
}

const sellsToBusinesses = result.decisions?.answers.sells_to_businesses;
if (sellsToBusinesses?.type === "noul") {
  console.log(sellsToBusinesses.noul);
}

const fit = result.decisions?.answers.fit;
if (fit?.type === "score") {
  console.log(fit.score, fit.legend["3"], fit.probabilities["3"], fit.confidence);
}
```

```bash cURL theme={null}
curl -s -X POST "https://api.exa.ai/search" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $EXA_API_KEY" \
  -d '{
    "query": "Mailgun (https://www.mailgun.com) company",
    "numResults": 10,
    "contents": { "highlights": true },
    "decisions": {
      "decisionPrompt": "Answer about Mailgun, the company at https://www.mailgun.com. Ignore other companies with a similar name.",
      "questions": {
        "status": {
          "type": "choice",
          "instructions": "What is Mailgun'"'"'s status today?",
          "criteria": {
            "operating": "Still operating as an independent company, private or public",
            "acquired": "Acquired by or merged into another company",
            "shut_down": "Shut down or stopped operating"
          }
        },
        "sells_to_businesses": {
          "type": "noul",
          "instructions": "Does Mailgun sell mainly to businesses rather than to consumers?"
        },
        "fit": {
          "type": "score",
          "instructions": "How well does Mailgun match our customer, a company that builds software for developers or data teams?",
          "criteria": [
            "Not a software company",
            "Software, but not for developers or data teams",
            "Software partly for developers or data teams",
            "Builds software for developers or data teams"
          ]
        }
      }
    }
  }'
```

Exa runs the search, then answers every question from the highlights of the top results. The response carries the usual `results` and adds `decisions.answers`, with one entry per question, keyed by its name.

> [accordion] Example response
>
> ```json theme={null}
> {
>   "requestId": "8d3933560264fde528a2e4fad3a96955",
>   "results": [
>     {
>       "title": "Transactional Email API Service For Developers | Mailgun",
>       "url": "https://www.mailgun.com/"
>     },
>     {
>       "title": "About - Mailgun",
>       "url": "https://www.mailgun.com/about/"
>     }
>   ],
>   "decisions": {
>     "answers": {
>       "status": {
>         "type": "choice",
>         "choice": "acquired",
>         "probabilities": { "operating": 0.02, "acquired": 0.98, "shut_down": 0 },
>         "confidence": 0.97
>       },
>       "sells_to_businesses": { "type": "noul", "noul": 0.97 },
>       "fit": {
>         "type": "score",
>         "score": 2.98,
>         "legend": {
>           "0": "Not a software company",
>           "1": "Software, but not for developers or data teams",
>           "2": "Software partly for developers or data teams",
>           "3": "Builds software for developers or data teams"
>         },
>         "probabilities": { "0": 0, "1": 0, "2": 0.02, "3": 0.98 },
>         "confidence": 0.98
>       }
>     }
>   }
> }
> ```
>
> The results are shortened here. A full response returns up to 10 results with their usual fields.

## Question types

| `type` | Use it for | `criteria` | Answer fields |
| - | - | - | - |
| `noul` | A yes/no statement | Optional. An object with `true` and `false` keys, each saying when it applies | `noul`, the probability from 0 to 1 that the answer is yes |
| `choice` | Picking one of named options | 2 to 255 options. Each key is an option and its value says when it applies | `choice`, the most likely option, `probabilities` for every option, and `confidence` |
| `score` | Rating against ordered levels | 2 to 10 levels, lowest first | `score`, the probability-weighted level from 0 (the first level), `legend` with each level's description, `probabilities` for each level, and `confidence`. `legend` and `probabilities` are keyed by the level's index from 0 as a string |

`confidence` is the model's confidence in the answer, from 0 to 1. Probabilities, scores and confidences have at most 4 decimal places.

## Guide every question

Add `decisions.decisionPrompt` (`decision_prompt` in the Python SDK) for guidance that applies to every question, such as which company or person the questions are about, or which sources count as evidence. Naming the subject by its website, as the example does, keeps answers about the right entity when other companies share its name.

`systemPrompt` does not affect decisions. Questions about recency are judged against the current date in UTC.

## Act on the answers

Route on the probabilities. Act when the top answer clears a threshold you choose, and handle everything below it as unsettled, with the response's `results` as context. The example uses 0.9. Pick your own threshold from how much a wrong automatic action costs you, and check it against a sample of your own subjects.

```python Python theme={null}
route = "unsettled"
if result.decisions is not None:
    status_answer = result.decisions.answers["status"]
    if status_answer.type == "choice" and status_answer.probabilities[status_answer.choice] >= 0.9:
        route = "contact" if status_answer.choice == "operating" else "drop"
```

```javascript JavaScript theme={null}
const statusAnswer = result.decisions?.answers.status;

let route = "unsettled";
if (statusAnswer?.type === "choice" && statusAnswer.probabilities[statusAnswer.choice] >= 0.9) {
  route = statusAnswer.choice === "operating" ? "contact" : "drop";
}
```

A refusal also routes to unsettled.

When the results say little about the subject, the probabilities spread across the options instead of landing on one. A threshold on the top probability catches those cases. An option such as `unknown` does not reliably catch them.

## Limits and compatibility

> [accordion] Search types and other parameters
>
> Decisions work with every search type, including `auto`, `lite`, and `deep`.
>
> You can send `decisions` and `outputSchema` in the same request.

> [accordion] Request limits
>
> | Setting | Limit |
> | - | - |
> | Questions per request | 1 to 100 |
> | Question names | 1 to 64 letters, digits, underscores or hyphens |
> | Options per `choice` question | 2 to 255 |
> | Levels per `score` question | 2 to 10 |
> | One question's name, instructions and criteria | 5,000 characters |
> | All questions' names, instructions and criteria | 15,000 characters |
> | `decisions.decisionPrompt` | 5,000 characters |

> [accordion] Compliance and regions
>
> Decisions work with [Zero Data Retention](https://exa.ai/docs/admin/security/zero-data-retention.md).
>
> Decisions are not available under [HIPAA](https://exa.ai/docs/admin/security/hipaa.md). A request that sets `decisions` with `compliance: "hipaa"` returns `400 INVALID_REQUEST_BODY`.
>
> Decisions are not available in the EU region. A request there that sets `decisions` returns `400 FEATURE_UNAVAILABLE_IN_REGION`.

> [accordion] Refusals
>
> A question that cannot be answered returns `{ "type": "refusal" }`. A refusal usually means the results don't cover the question, so send a more specific query or raise `numResults`.
>
> The Python and JavaScript SDKs return an answer whose `type` they do not recognize as `type: "unknown"`, with the API's answer in `raw`.
