<!-- AUTO-GENERATED from the capability registry — regenerate: npm run generate:registry -->

# `ai_extract` — Orange Slice capability

> Outcome-priced capability. One price for the answer, whichever providers it took.
> Everything we expose, with prices: https://orangeslice.ai/llms.txt

Extracts structured fields from text against a JSON Schema you supply. One credit per call. This is the one to use in a pipe — it returns an object the next command can read, where `ai text` returns prose it cannot.

## Price

**$0.002, charged per call**

Billed on every call, including one that returns nothing.

The price is a property of the outcome, not of the work behind it. Whichever
vendor serves this call, and whatever it costs us, the number above is the number
quoted before the run and charged after it.


## Measured reliability

- **Hit rate:** 83% of runs resolve an answer.
- **Sample:** 4,322 runs, measured 2026-09-01.

Use these to choose between entries that both fit. Do not use them to rule
one out — a low hit rate is a fact about the world's data, not about whether the
call is worth making, and under this pricing a miss is free.


## Call it

**CLI**

```bash
orangeslice ai extract "Find the CEO and headcount" \
  --schema-json '{"type":"object","properties":{"ceo":{"type":"string"},"headcount":{"type":"number"}}}'
```

**HTTP**

```bash
curl -X POST 'https://orangeslice.ai/api/v1/run' \
  -H 'Authorization: Bearer $ORANGESLICE_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"capability":"ai_extract","input":{"prompt":"<string>","schemaJson":"<json>"}}'
```

**SDK**

```ts
await services.ai.generateObject({ prompt: "…", schemaJson: "…" });
```

## Inputs

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `enableWebSearch` | boolean | No | Let the model search the web before answering. Does not change the price. |
| `prompt` | string | Yes | What to extract, and from what |
| `schemaJson` | json | Yes | JSON Schema for the object you want back, e.g. {"type":"object","properties":{"ceo":{"type":"string"}}} |

Inputs may also be piped as NDJSON, one JSON object per line.

## Output

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "anyOf": [
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "data"
  ],
  "additionalProperties": false
}
```

The field that carries the answer is `data`. It is
`null` — or empty — when nothing was found, which is how a miss is told from a
hit without knowing anything else about this entry.

## Before you run

- **Price it first.** `orangeslice ai extract --dry-run` returns the
  exact dollar cost and spends nothing.
- **Large runs need approval.** Above the spend-gate threshold a run exits **7**
  until it carries a plan token, and only a dry run mints one.
- **Scopes:** enrich
- **Permitted uses:** research, outreach, export

## Exit codes

`0` ok · `2` bad input · `3` auth · `4` not found · `5` provider ·
`6` rate limited · `7` spend gate, nothing billed · `8` timeout ·
`9` a third-party account needs connecting
