---
title: Extract data from text or file (SSE stream)
url: https://anyrow.ai/docs/api/extract/stream
canonical_url: https://anyrow.ai/docs/api/extract/stream
---

# Extract data from text or file (SSE stream)

`POST /v1/projects/{project_id}/extract-stream`

Authentication: `Authorization: ApiKey {your_api_key}`.

## Path parameters

- `project_id` (string, required)

## Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `columns` (string, optional)
- `file` (string, optional)
- `instruction` (string, optional): Up to 1000000 characters.
- `schema` (string, optional)
- `strictness` (string, optional): One of `strict`, `balanced`, `flexible`.
- `text` (string, optional): Up to 1000000 characters.

## Returns

200 `text/event-stream`.

## Errors

- 404: `not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

## Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.extract.stream({
  params: {
    project_id: "{project_id}"
  },
  form: {
    columns: "string",
    file: "<file>",
    instruction: "string",
    schema: "string",
    strictness: "strict",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/extract-stream' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'columns=string' \
  -F 'file=@./document.pdf' \
  -F 'instruction=string' \
  -F 'schema=string' \
  -F 'strictness=strict' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("columns", "string")
body.append("file", await openAsBlob("./document.pdf"))
body.append("instruction", "string")
body.append("schema", "string")
body.append("strictness", "strict")
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/extract-stream", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.text()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/extract-stream",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "columns": "string",
        "instruction": "string",
        "schema": "string",
        "strictness": "strict",
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.text)
```

## Response

```text title="200"
string
```
