FileRelay
Documentation
Try our Sandbox

connectors/ai-gateway

AI Gateway

The AI Gateway destination (preview) makes routed documents searchable for AI clients. FileRelay extracts the text, splits it into chunks, optionally adds embeddings for semantic search, and serves the result to AI clients over MCP. The AI Gateway runs inside FileRelay: there is no separate server, URL or delivery key.

Each AI Gateway destination is its own knowledge base. A document routed to two AI destinations is indexed once for each of them.

Enable the module

The operator installs the module once: set ALLOW_AI_GATEWAY=true on the server and run php artisan migrate. Then enable AI Gateway in Settings → System (or set AI_GATEWAY_ENABLED=true as the default; the saved setting wins). The System editor requires SHOW_SYSTEM_CONFIG=true and owner/admin access.

When disabled, AI Gateway is hidden in the destination chooser, new test/create requests are blocked (also through the public API), deliveries to existing AI destinations fail, and AI clients get HTTP 503 from the MCP endpoint. Indexes and keys are kept; turning it on again restores them.

In the same settings, choose the document engine (Tika, Docling, Docling VLM or Auto), the empty-text fallback and the embedding engine (ollama enables semantic search). The operator runs the processing containers (Tika, Docling, Ollama) and the AI worker that does the indexing.

Configure a destination

  1. Open Destinations → Add Destination → Enterprise → AI Gateway.
  2. Enter a destination name, for example Finance AI.
  3. Choose what happens to originals:
    • Index only (default): FileRelay keeps the extracted text and vectors. Once FileRelay purges its buffer, AI clients still get answers and references but cannot open the file, and the document cannot be reindexed.
    • Keep originals in FileRelay storage: pick an existing S3, MinIO or R2 destination of this workspace (create it under Destinations first; it needs no connection) and optionally a prefix (default filerelay-ai/<destination id>/). FileRelay writes each original there and deletes it again with the index. The storage destination shows AI storage for … and cannot be deleted while linked.
  4. Choose what a SAP delete does: Remove (default) drops the document's index and kept original, Keep leaves both, like other routing destinations.
  5. Review & Test: the test checks that the AI Gateway is enabled and that the processing containers the current settings need answer.

The AI Gateway does not use the content server: a repository can route to an AI destination with or without a content-server binding, and the AI Gateway never reads content-server copies.

Delivery and indexing status

A delivery is Delivered as soon as FileRelay has recorded the indexing request (and, with Keep originals, written the original). Indexing is reported separately in the AI Gateway Indexing section of the document page, per AI destination: pending, processing, indexed (with the engine, chunk count and whether semantic search is available) or failed with the reason, and whether the original is kept or deleted.

While indexing is still open, FileRelay keeps the document's buffered copy even if your buffer policy would otherwise delete it, whether or not a content-server copy exists. The copy is released once indexing finishes or fails.

If the original cannot be written to the storage destination, the delivery is retried under the workspace delivery policy.

Document reads

The AI Gateway reads the bytes it indexes from FileRelay's buffer, else from the original kept for that destination. Only documents delivered to that AI destination are readable, and bytes whose SHA-256 differs from the archived hash are refused. Changes in storage (drift) are tracked by FileRelay as usual.

Removing documents from the index

FileRelay removes a document's index from an AI destination, and the original it kept for that destination, when:

  • SAP deletes the document and the destination's rule is Remove (the default). With Keep, both stay. Switching a destination from Keep to Remove later also clears documents SAP already deleted, within five minutes.
  • The document is deleted in FileRelay, or the AI destination is deleted.

Stopping a connection from routing to an AI destination does not remove what was already delivered: access follows the delivery history.

The kept original is deleted for good, every stored version included. A check every five minutes catches any removal that was missed.

AI Gateway pages

With the module enabled, the AI Gateway menu shows live data for the current workspace: Overview (health, configuration and indexing per AI destination), Documents (index state, extracted text and embeddings), Search (keywords plus meaning, the way AI clients search), Indexing (every request with its errors; Retry and Reindex), Access Keys and Activity (every MCP call with its outcome). A knowledge-base switcher at the top limits the pages to one AI destination.

Connect AI clients (MCP)

Owners and admins create access keys on AI Gateway → Access Keys:

  • choose the permissions: documents (search and read indexed documents) and/or live OData;
  • choose the knowledge bases (AI destinations) the key may read. A key never sees documents of other AI destinations. AI destinations added later are not included in existing keys.

The key is shown once. Revoke it at any time; a revoked key can then be removed.

AI clients connect to the MCP endpoint shown on the Access Keys page: <FileRelay URL>/mcp, or a separate host if the operator runs the MCP-only service. Send the key as Authorization: Bearer <key>. Every answer carries a source reference (SAP document id, repository, SHA-256 and a link to the document in FileRelay).

Live OData tools read only repositories whose Data API switch is on.

API configuration

Use the existing destination test and create endpoints with this payload:

{
  "type": "ai_gateway",
  "name": "Finance AI",
  "config": {
    "originals": "filerelay_storage",
    "storage_destination_id": "<id of an S3, MinIO or R2 destination>",
    "storage_prefix": "filerelay-ai/finance/",
    "on_sap_delete": "remove"
  },
  "credentials": {}
}

originals is index_only (default) or filerelay_storage; on_sap_delete is remove (default) or keep. No URL or credentials are needed.