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

> ## Agent Instructions
> Call https://api.feyn.ai only; the hosts behind it are not public.
> Authenticate with a workspace API key in the Authorization header: `Authorization: Bearer fn_...`. Keep keys server-side.
> For chat completions, use the official OpenAI SDK with base_url https://api.feyn.ai/v1 and a model ID from GET /v1/models.
> On 429, wait for the Retry-After header before retrying. Failed requests are not charged.

# Models

> Every model on Feyn Cloud, called with one API key: Pulpie, MultiMatte, Jiffy and the language models on your workspace.

Every model is served from `https://api.feyn.ai` and called with the same workspace API key. As in the OpenAI API, each task has one route under `/v1/`, and the body's `model` names the model; `GET /v1/models` lists the names your key may use. The older `/pulpie/v1/extract` and `/multimatte/v1/cutout` routes still work.

| Model | What it does | Price |
| - | - | - |
| [Pulpie](#pulpie) | HTML or a text PDF in, the main content out as HTML and Markdown | \$1.00 per 1,000 requests |
| [MultiMatte](#multimatte) | A photo and a prompt in, a transparent PNG of that object out | \$2.00 per 1,000 images |
| [Jiffy](#jiffy) | A state and typed questions in, calibrated probabilities out (System One API) | \$0.10 per 1M input tokens |
| [Language models](#chat-completions) | OpenAI-compatible chat completions for the models on your workspace | Per million input and output tokens, as listed for each model |

Failed requests are not charged. See [rate limits](https://docs.usefeyn.com/account/rate-limits.md) and [credits](https://docs.usefeyn.com/account/credits.md).

## Pulpie

Pulpie is a 210M-parameter extraction model. It reads a whole page and keeps only the main content: no navigation, ads, cookie banners or footers.

```
POST https://api.feyn.ai/v1/extract
```

### Pulpie request

Send JSON with exactly one of `html` or `pdf_base64`.

**model** `string`

`pulpie`. Optional while Pulpie is the only extraction model.

**html** `string`

The page HTML. Up to 7 MB.

**pdf\_base64** `string`

Instead of `html`: a text PDF, base64-encoded. Base64 adds a third to the size and request bodies are capped at 8 MB, so keep the PDF under about 6 MB before encoding. Scans without a text layer are rejected.

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.feyn.ai/v1/extract \
  -H "Authorization: Bearer $FEYN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "pulpie", "html": "<nav>Menu</nav><article><h1>Hello</h1><p>Only this stays.</p></article>"}'
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import os, requests

page = requests.get("https://example.com/post").text
response = requests.post(
    "https://api.feyn.ai/v1/extract",
    headers={"Authorization": f"Bearer {os.environ['FEYN_API_KEY']}"},
    json={"model": "pulpie", "html": page},
    timeout=120,
)
response.raise_for_status()
print(response.json()["markdown"])
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const page = await (await fetch('https://example.com/post')).text()
const response = await fetch('https://api.feyn.ai/v1/extract', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FEYN_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ model: 'pulpie', html: page }),
})
const { markdown } = await response.json()
```

To send a PDF, base64-encode the file as `pdf_base64`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
{ printf '{"pdf_base64": "'; base64 < paper.pdf | tr -d '\n'; printf '"}'; } |
curl https://api.feyn.ai/v1/extract \
  -H "Authorization: Bearer $FEYN_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @-
```

### Pulpie response

**html** `string`

The extracted content as HTML.

**markdown** `string`

The same content as Markdown.

**elapsed\_ms** `number`

Model time for this request, in milliseconds.

**diagnostics** `object`

Input and output sizes, block counts and any recovery warnings.

### Pulpie pricing and limits

| | |
| - | - |
| Price | $1.00 per 1,000 requests; $0.50 per 1,000 past 1M requests in a month |
| Rate limit | 1 request per second, 5 concurrent, per workspace |
| Input | Up to 7 MB of HTML; PDFs up to about 6 MB before base64 (8 MB request body cap) |

## MultiMatte

MultiMatte is an 860M-parameter promptable matting model (SAM 3 with a LoRA). It returns an alpha matte, so hair, fur and soft edges stay soft.

```
POST https://api.feyn.ai/v1/cutout
```

### MultiMatte request

**model** `string`

`multimatte`. Optional while MultiMatte is the only cutout model.

**image\_base64** `string` *required*

The photo (JPEG, PNG, WebP or HEIC), base64-encoded. Up to 5 MB before encoding. Images with a side longer than 2048 px are downscaled first.

**prompt** `string`

The object to keep, for example `"the dog"`. Defaults to the main foreground subject.

A photo's base64 is too long for one shell argument, so build the body on stdin:

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
{ printf '{"model": "multimatte", "prompt": "the dog", "image_base64": "'; base64 < dog.jpg | tr -d '\n'; printf '"}'; } |
curl https://api.feyn.ai/v1/cutout \
  -H "Authorization: Bearer $FEYN_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- \
  -o dog-cutout.png
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import base64, os, requests

with open("dog.jpg", "rb") as file:
    image = base64.b64encode(file.read()).decode()

response = requests.post(
    "https://api.feyn.ai/v1/cutout",
    headers={"Authorization": f"Bearer {os.environ['FEYN_API_KEY']}"},
    json={"model": "multimatte", "image_base64": image, "prompt": "the dog"},
    timeout=120,
)
response.raise_for_status()
with open("dog-cutout.png", "wb") as file:
    file.write(response.content)
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { readFile, writeFile } from 'node:fs/promises'

const image = (await readFile('dog.jpg')).toString('base64')
const response = await fetch('https://api.feyn.ai/v1/cutout', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FEYN_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ model: 'multimatte', image_base64: image, prompt: 'the dog' }),
})
await writeFile('dog-cutout.png', Buffer.from(await response.arrayBuffer()))
```

### MultiMatte response

The body is an RGBA PNG (`image/png`) at the input size, after any downscale.

**X-Feyn-Inference-Ms** `header`

Model time for this image, in milliseconds.

**X-Feyn-Prompt** `header`

The prompt that was used, percent-encoded. Useful when you let it default.

### MultiMatte pricing and limits

| | |
| - | - |
| Price | \$2.00 per 1,000 images |
| Rate limit | 1 request every 4 seconds, 2 concurrent, per workspace |
| Input | Up to 5 MB, longest side downscaled to 2048 px |

## Jiffy

Jiffy 1.0 is a 27B decision model. Give it a state (an email, a ticket, a page, a JSON record) and any number of typed questions about it; it answers each one with a probability, not generated text.

Jiffy speaks the System One API (`POST /v1/systemone`), the request and response shape TypeSafe's Jev uses, so System One clients and SDKs work by changing the base URL to `https://api.feyn.ai` and the key. `GET /v1/models` lists `jiffy-1.0` and `jiffy-latest`, in a TypeSafe-style `models` array as well as the OpenAI `data` list.

```
POST https://api.feyn.ai/v1/systemone
```

### Jiffy request

**model** `string`

`jiffy-1.0`, or `jiffy-latest` for the newest version. Defaults to `jiffy-1.0`.

**state** `string | object | array`

What the questions are about. Text is used as it is; JSON is read in its compact form.

**questions** `object` *required*

Up to 64 questions, keyed by your own names. Each one has a `type` and `instructions` (a string, object or array):

* `noul`: a yes/no question or statement. Optional `criteria` `{"true": "...", "false": "..."}` say what each answer means.
* `choice`: `criteria` maps each option's name to its description (or `null`), 2 to 255 mutually exclusive options.
* `score`: `criteria` is an array of 2 to 10 ordered levels, from the low end of the scale to the high end.

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.feyn.ai/v1/systemone \
  -H "Authorization: Bearer $FEYN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "jiffy-1.0",
    "state": "I was charged twice for my subscription this month. Please refund the extra charge.",
    "questions": {
      "refund": {"type": "noul", "instructions": "Does this message request a refund?"},
      "team": {
        "type": "choice",
        "instructions": "Which team should handle this ticket?",
        "criteria": {"billing": "Charges, invoices and refunds", "technical": "Bugs and outages", "account": "Login and settings"}
      },
      "urgency": {
        "type": "score",
        "instructions": "How urgent is this message?",
        "criteria": ["Can wait", "Needs attention this week", "Needs attention today"]
      }
    }
  }'
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import os
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

client = TypeSafeClient(
    api_key=os.environ["FEYN_API_KEY"],
    base_url="https://api.feyn.ai",
    model="jiffy-1.0",
)
response = client.system_one(
    state="I was charged twice for my subscription this month. Please refund the extra charge.",
    questions={
        "refund": Noul(instructions="Does this message request a refund?"),
        "team": Choice(
            instructions="Which team should handle this ticket?",
            criteria={"billing": "Charges, invoices and refunds", "technical": "Bugs and outages", "account": "Login and settings"},
        ),
        "urgency": Score(
            instructions="How urgent is this message?",
            criteria=["Can wait", "Needs attention this week", "Needs attention today"],
        ),
    },
)
print(response.answers["refund"].noul, response.answers["team"].choice)
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const response = await fetch('https://api.feyn.ai/v1/systemone', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FEYN_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'jiffy-1.0',
    state: 'I was charged twice for my subscription this month. Please refund the extra charge.',
    questions: {
      refund: { type: 'noul', instructions: 'Does this message request a refund?' },
      team: {
        type: 'choice',
        instructions: 'Which team should handle this ticket?',
        criteria: { billing: 'Charges, invoices and refunds', technical: 'Bugs and outages', account: 'Login and settings' },
      },
    },
  }),
})
const { answers } = await response.json()
```

### Jiffy response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "model": "jiffy-1.0",
  "answers": {
    "refund": {"type": "noul", "noul": 0.963},
    "team": {"type": "choice", "choice": "billing", "confidence": 0.921, "probabilities": {"billing": 0.947, "technical": 0.027, "account": 0.025}},
    "urgency": {"type": "score", "score": 0.925, "confidence": 0.402, "legend": {"0": "Can wait", "1": "Needs attention this week", "2": "Needs attention today"}, "probabilities": {"0": 0.237, "1": 0.601, "2": 0.162}}
  },
  "usage": {"input_tokens": 235, "output_tokens": 0}
}
```

**answers** `object`

One answer per question, under the same name. `noul` is the probability of yes. `choice` is the most likely option and `probabilities` sums to 1 over your options. `score` is the probability-weighted level number, with `legend` mapping levels back to your descriptions. `confidence` (Choice and Score) is computed from how spread out `probabilities` is, with the same formulas as TypeSafe's.

**usage.input\_tokens** `number`

The tokens you are charged for. Jiffy reads the state together with each question, so the state counts once per question. Output tokens are always 0.

**X-Feyn-Inference-Ms** `header`

Model time for this request, in milliseconds.

### Jiffy pricing and limits

| | |
| - | - |
| Price | \$0.10 per 1M input tokens (`usage.input_tokens`) |
| Rate limit | 2 requests per second, 8 concurrent, per workspace |
| Input | Up to 64 questions; 32,768 tokens of state plus any one question, 65,536 of state plus all questions (`400` with `max_tokens_exceeded` past either); 4 MB request body |

Invalid requests answer `422` with a `detail` list naming the field. A busy model answers `529`; retry after a short delay (the TypeSafe SDKs do this for you). Failed requests are not charged.

## Chat completions

The language models on your workspace answer `POST /v1/chat/completions` in the OpenAI Chat Completions format, so the official OpenAI SDKs work by changing the base URL and key.

Set `FEYN_CHAT_MODEL` to a model ID from [the list of models your key can call](#which-models-you-can-call).

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.feyn.ai/v1",
    api_key=os.environ["FEYN_API_KEY"],
)

response = client.chat.completions.create(
    model=os.environ["FEYN_CHAT_MODEL"],
    messages=[{"role": "user", "content": "Classify this email: ..."}],
)
print(response.choices[0].message.content)
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://api.feyn.ai/v1',
  apiKey: process.env.FEYN_API_KEY,
})

const response = await client.chat.completions.create({
  model: process.env.FEYN_CHAT_MODEL,
  messages: [{ role: 'user', content: 'Classify this email: ...' }],
})
console.log(response.choices[0].message.content)
```

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.feyn.ai/v1/chat/completions \
  -H "Authorization: Bearer $FEYN_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"model\": \"$FEYN_CHAT_MODEL\", \"messages\": [{\"role\": \"user\", \"content\": \"hi\"}]}"
```

Streaming (`"stream": true`) works as it does with OpenAI.

### Which models you can call

`GET /v1/models` lists the models your key may call right now:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.feyn.ai/v1/models -H "Authorization: Bearer $FEYN_API_KEY"
```

Copy a model's `id` from the response's `data` array. It also lists the [Jiffy](#jiffy) models, which answer `POST /v1/systemone` rather than chat completions; they are repeated in a `models` array in TypeSafe's shape.

Models fine-tuned for your workspace are private: only your workspace sees them in this list or can call them. Any other workspace gets the same `404` as for an unknown model.

### Routing

Requests that share a model and a prompt prefix go to the same replica, so long shared system prompts stay in that replica's prefix cache. If a replica fails, the request is retried on another.

To keep a record of what a model did, write each run as a [trace](https://docs.usefeyn.com/observability/traces.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.