# Extract intelligence from documents on premises

> Run the extraction web service of the Import Document AI connector in your own stack, so that OpenCTI extracts threat intelligence from documents on premises.

- URL: https://filigran.io/docs/deploy/configure/ai-extraction/
- Products: OpenCTI 7.261119.0
- Edition: requires an Enterprise Edition license
- For: platform engineers
- Type: How-to guide

The Import Document AI connector of OpenCTI extracts entities, observables and relationships from PDF, text, HTML and Markdown files, and imports them as a STIX bundle. It sends each document to an extraction web service, the one Filigran hosts or one you run. This page runs that web service in your own stack, for an air-gapped network or to keep documents on your premises, and points the connector to it.

**Diagram: OpenCTI hands each imported document to the connector, which sends it to the extraction web service in your stack and imports the STIX bundle, while the other AI features call the model of the ai keys**

- Documents: Documents (PDF, text, HTML, Markdown)
- OpenCTI: OpenCTI (Data > Import)
- Connector: ImportDocumentAI (connector-import-document-ai)
- On your premises: Extraction web service (import-document-ai-webservice:8000), Your language model (ai:endpoint, such as vLLM)

Connections:

- Documents → OpenCTI: upload
- OpenCTI → ImportDocumentAI: launch import
- ImportDocumentAI → Extraction web service: document and license
- ImportDocumentAI → OpenCTI: STIX bundle
- OpenCTI → Your language model: summaries, search, text

*(OpenCTI 7.260811 and later)*

The connector has no default address: without an XTM One agent, it needs the address of a web service and your license certificate, or every import fails with `No agent_slug provided and api_base_url/api_key is not configured`.

*(OpenCTI 7.260811 and later)*

> **With XTM One: Extract with an XTM One agent**
>
> When OpenCTI is [registered with XTM One](https://filigran.io/docs/deploy/configure/connect-modules/), the connector can hand the document to an XTM One AI agent instead of the web service. The import dialog of OpenCTI then offers the agents bound to the intent `cti.stix_harvester` (the connector setting `CONNECTOR_XTM_ONE_INTENT`), and the extraction runs in your XTM One with the model you configured there. No web service is needed for those imports.

## Before you start {#before-you-start}

- OpenCTI with an Enterprise Edition license, and the license certificate that Filigran gave you, in PEM format: the connector sends it to the web service.
- An access token to the private Docker repository of Filigran, from your Customer Success Manager or Account Manager.
- A host that fits the web service. These figures come from Filigran; extraction time depends on the size of the file.

  | | With a GPU | Without a GPU |
  | --- | --- | --- |
  | Computing | An NVIDIA GPU | CPU at 3 GHz or more |
  | RAM | 8 GB | 16 GB |
  | Disk | 16 GB | 16 GB |
  | Average extraction time | 5 to 10 seconds | 30 seconds to 2 minutes |

- The stack installed as [Install with Docker Compose](https://filigran.io/docs/deploy/install/docker-compose/) describes.

## Run the web service {#run-the-web-service}

1. Sign in to the private repository of Filigran, and enter the token when Docker asks for the password.

   ```bash
   docker login --username filigrancustomers
   ```

   To run the service where Docker Hub is not reachable, pull `filigran/import-document-ai-webservice` here and push it to your own registry.

2. Add the service to `docker-compose.override.yml`, under `services:`, as [Change the stack without editing docker-compose.yml](https://filigran.io/docs/deploy/install/docker-compose/#change-the-stack-without-editing-docker-compose-yml) describes. It listens on port 8000 inside the stack; the connector reaches it there, so it needs no published port. Keep the `deploy` block only on a host with an NVIDIA GPU.

   ```yaml
     import-document-ai-webservice:
       image: filigran/import-document-ai-webservice
       restart: always
       deploy:
         resources:
           reservations:
             devices:
               - driver: nvidia
                 count: 1
                 capabilities: [gpu]
   ```

3. Start it.

   ```bash
   docker compose pull import-document-ai-webservice
   docker compose up -d import-document-ai-webservice
   ```

   **Check that it worked**

   ```bash
   docker compose ps import-document-ai-webservice
   ```
   The service is `running`.

## Point the connector to it {#point-the-connector-to-it}

The connector is not part of xtm-docker. Add it to `docker-compose.override.yml` with the address of your web service.

1. Give the connector an identifier in `.env`.

   ```bash
   echo "CONNECTOR_IMPORT_DOCUMENT_AI_ID=$(python3 -c 'import uuid; print(uuid.uuid4())')" >> .env
   ```

2. Add the connector under `services:`, with your license certificate in place of the three certificate lines: the whole PEM text, from `-----BEGIN CERTIFICATE-----` to `-----END CERTIFICATE-----`, indented as shown.

   *(OpenCTI 7.260811 and later)*

   ```yaml
     connector-import-document-ai:
       image: opencti/connector-import-document-ai:latest
       environment:
         OPENCTI_URL: http://opencti:8080
         OPENCTI_TOKEN: ${OPENCTI_ADMIN_TOKEN}
         CONNECTOR_ID: ${CONNECTOR_IMPORT_DOCUMENT_AI_ID}
         CONNECTOR_NAME: ImportDocumentAI
         CONNECTOR_SCOPE: application/pdf,text/plain,text/html,text/markdown
         CONNECTOR_AUTO: "false"
         CONNECTOR_LOG_LEVEL: info
         IMPORT_DOCUMENT_AI_API_BASE_URL: http://import-document-ai-webservice:8000
         IMPORT_DOCUMENT_AI_API_KEY: |
           -----BEGIN CERTIFICATE-----
           Your license certificate
           -----END CERTIFICATE-----
       depends_on:
         opencti:
           condition: service_healthy
       restart: always
   ```

   The connector calls `/stix` under `IMPORT_DOCUMENT_AI_API_BASE_URL`.

   Use the image tag of your OpenCTI version in place of `latest`, as for the other connectors.

3. Start the connector.

   ```bash
   docker compose up -d connector-import-document-ai
   ```

4. In OpenCTI, go to **Data > Import**, upload a PDF file, and launch an import with the connector `ImportDocumentAI`.

   **Check that it worked**

   The import completes and its entities appear in OpenCTI.

   *(OpenCTI 7.260811 and later)*

   The connector log names your web service:

   ```bash
   docker compose logs connector-import-document-ai | grep "HTTP Post Request"
   ```
   The line holds `http://import-document-ai-webservice:8000/stix`.

If the import fails with `ImportDocumentAI webservice seems to be unreachable`, the connector cannot reach the address you set: check the service name and the port.

## Connect OpenCTI to your own language model {#connect-opencti-to-your-own-language-model}

The connector above handles documents only. The other AI features of OpenCTI, such as the summaries of an entity, the search in natural language and the text generation in the editors, call the language model set in the `ai` keys of the platform. To keep those prompts on your premises too, point these keys to a model you host.

| Key | Default | What it does |
| --- | --- | --- |
| `ai:enabled` | not set | Set to `true` to connect the model. Unset or `false`, the AI features have no model |
| `ai:type` | `mistralai` | The API of the model: `mistralai`, `openai` or `azureopenai`. With `ai:enabled` and `ai:token` set, any other value stops the platform at start |
| `ai:endpoint` | empty | URL of the model API. Empty: the public cloud of the provider. For the Mistral AI cloud, set `https://api.mistral.ai`: with `mistralai` and any other URL, OpenCTI calls an OpenAI-compatible API at the URL followed by `/v1`, as a model served by vLLM exposes |
| `ai:token` | empty | The API key. Without it, the AI features have no model |
| `ai:model` | empty | The model name, as the API knows it |
| `ai:max_tokens` | `30000` | Length of the prompt sent to the model. Despite its name, OpenCTI cuts the prompt to this number of characters, not tokens |
| `app:ai:timeout` | `60000` | Time, in milliseconds, a search in natural language waits for the model before it fails. Raise it for a slow model |

For Azure OpenAI, set `ai:type` to `azureopenai`, with `ai:version`, the API version of your deployment, `ai:ai_azure_instance`, the instance name, such as `example-cert` for `https://example-cert.openai.azure.com`, and `ai:ai_azure_deployment`, the deployment name.

Two keys of `config/default.json` have no effect: `ai:timeout`, since the timeout is read from `app:ai:timeout` (`APP__AI__TIMEOUT`), and `ai:model_images`, which no code reads. The platform also needs the **Generative AI (AI Insight, NLQ)** switch on, in **Settings > Filigran Experience**. Every other AI key is in the [AI Service section](https://filigran.io/docs/reference/opencti/configuration/#ai-service) of the configuration reference.

**Example: Use the model of Example CERT's GPU cluster**

Example CERT serves a Mistral model with vLLM at `https://llm.example.com`, behind its own API key, kept in `.env` as `OPENCTI_AI_TOKEN`. It adds to `docker-compose.override.yml`:

```yaml
services:
  opencti:
    environment:
      - AI__ENABLED=true
      - AI__TYPE=mistralai
      - AI__ENDPOINT=https://llm.example.com
      - AI__TOKEN=${OPENCTI_AI_TOKEN}
      - AI__MODEL=mistralai/Mistral-Small-3.2-24B-Instruct-2506
      - APP__AI__TIMEOUT=120000
```

After `docker compose up -d opencti`, the summaries and the search in natural language of OpenCTI use this model, and no prompt leaves the network.

## What's next {#what-s-next}

- [Run an integration without XTM Composer](https://filigran.io/docs/deploy/integrations/manual/), for the other settings of a connector run this way.
- [Install offline or with FIPS 140-3](https://filigran.io/docs/deploy/install/air-gapped/).
- [Connect the modules to each other](https://filigran.io/docs/deploy/configure/connect-modules/), to extract with an XTM One agent instead.
