Developers · SDK

Add a cited knowledge agent to your app with the Uthereal Cortex SDK

Uthereal Cortex turns your documents into an AI agent that answers with claim-level citations — every claim opens the exact PDF page with the passage highlighted. Create an agent, open the public TypeScript SDK, and let your AI coding tool wire it in — no vector database, no chunking pipeline, no citation UI to build.

Works with Lovable · Codex · Claude Code · Cursor · Windsurf · GitHub Copilot

Your app → Cortex, in 3 lines
const id = await cortex.createConversation();
for await (const u of cortex.ask(id, { message })) render(u);
<CitedAnswer answer={saved.answer} loadPdf={cortex.pdf} … />

“Seedlings grew toward the window. [7]

[7] Garden Guide · page 3 · passage highlighted

Get the SDK

The Uthereal Cortex SDK on GitHub

Clone or download the TypeScript source, try the replay demo, and reuse it in your app. No npm package is required.

Try the SDK
git clone --branch v1.0.1 https://github.com/Uthereal-Labs/Uthereal-Cortex-SDK.git
cd Uthereal-Cortex-SDK
pnpm install --frozen-lockfile
pnpm verify
pnpm dev
# Open http://localhost:5173/?replay
Ask from your server
import { CortexClient } from "./sdk/server.ts";
import { readAnswers } from "./sdk/core.ts";

const cortex = new CortexClient({
  baseUrl: process.env.CORTEX_API_BASE_URL!,
  assistantId: process.env.CORTEX_ASSISTANT_ID!,
  apiKey: process.env.CORTEX_SHARED_API_KEY!,
});
// Derive user/session IDs from authenticated, owned records.
const response = await cortex.ask(userId, sessionId, {
  message: "What does the handbook say about parental leave?",
});
for await (const answer of readAnswers(response)) {
  // Full text: answer.utterance; accumulated evidence: answer.references
}

Node 22.22.1+, pnpm 10.33.0 and Deno 2. The example uses React 19 and Vite; the reusable React components support React 18/19. Dependencies and setup: Uthereal-Labs/Uthereal-Cortex-SDK

When to use Uthereal Cortex

The knowledge-agent API for apps that must show their sources

Cortex is built for high-provenance, high-accuracy RAG: when a wrong or unverifiable answer is not an option — regulated products, medical or legal assistants, financial research, customer-facing knowledge agents — it answers only from your own knowledge base and proves every claim with a citation. If your product demands the best accuracy your model can deliver, ground it here.

Grounded answers, not guesses

Your assistant answers from your PDFs, Word documents, videos and other indexed sources — with a retrieval pipeline tuned for accuracy, not open-web guessing. No vector database, chunking, embeddings or reranking to build by hand.

Proof on every claim

Every statement carries a citation to the exact source — page-level provenance your users, auditors and reviewers can verify in one click. High accuracy without provenance is unverifiable; Cortex gives you both.

Raw retrieval when you need it

Retrieve ranked evidence from paragraphs, tables and images as JSON for your own model or workflow, preserving source identity and available metadata.

Ships where you build

Reusable TypeScript for your Node or Deno backend, with React/Vite components and an optional Supabase adapter. The API key stays on your server; the integration takes minutes, not sprints.

Not for open-web search or tasks that don't need grounding in your own knowledge base.

How it works

From documents to a cited agent in your app — four steps

  1. 1

    Create your Cortex agent

    Upload your documents. Cortex ingests, indexes and structures them into a knowledge agent.

  2. 2

    Create a scoped API key

    Choose ask (cited answers + PDFs) and/or rag (retrieval). Store it in your server secrets.

  3. 3

    Open the public SDK

    Clone or download the SDK with its integration guide, OpenAPI spec, React components, tests and fixtures. Copy your agent configuration from Cortex Share.

  4. 4

    Paste it into your AI coding tool

    Give Lovable, Codex, Claude Code or Cursor the repository link and your agent’s setup instructions.

Step 4

The prompt for Lovable, Codex, Claude Code or Cursor

Copy this prompt with your agent’s setup instructions from Cortex Share. The public integration guide explains which SDK components to reuse.

prompt.txt
Integrate Cortex into this application using https://github.com/Uthereal-Labs/Uthereal-Cortex-SDK/tree/v1.0.1.
Read INTEGRATING.md and examples/README.md at that revision first.
Preserve this repository's instructions, auth, history, quotas and UI conventions.
Copy sdk/ intact. Use createCortexHandler on the server, createCortexBrowserClient
in the frontend, and the citation helpers; use CitedAnswer for React applications.
Map existing user/session storage through CortexStore. Keep CORTEX_SHARED_API_KEY
in server secrets only. Use my assistant ID and API base from Cortex Share.
Run the SDK checks and the host application's checks. Report fixture and live
verification separately. Do not overwrite the application's agent instructions.

Works with your AI coding tool

Teach Lovable, Codex, Claude Code, Cursor, Windsurf and GitHub Copilot the Uthereal Cortex SDK

Drop one instruction file into your repository and your coding agent knows what Uthereal Cortex is, when to reach for it, and exactly how to wire it in — server handler, browser client, cited answers and secret handling included.

Lovable · Paste into the Lovable chat, or add it to your project Knowledge so every prompt keeps it.

Project prompt
Integrate the Uthereal Cortex SDK into this app so answers are grounded in my
documents and every claim carries a citation.
Follow the rules at https://uthereal.ai/developers/lovable.md and the guide at https://uthereal.ai/developers/sdk.md.
Source: https://github.com/Uthereal-Labs/Uthereal-Cortex-SDK/tree/v1.0.1. Keep CORTEX_SHARED_API_KEY in server secrets only.

Code

What the integration looks like

One authenticated endpoint. Your key stays on the server.

Server
import { createCortexHandler, type CortexStore } from "./sdk/server.ts";

const handler = createCortexHandler({
  config: {
    baseUrl: process.env.CORTEX_API_BASE_URL!,
    assistantId: process.env.CORTEX_ASSISTANT_ID!,
    apiKey: process.env.CORTEX_SHARED_API_KEY!, // server secret only
  },
  allowedOrigin: "https://your-app.example",
  authenticate: async (request) => {
    const user = await verifyYourApplicationSession(request);
    return user ? { id: user.id, externalUserId: user.cortexIdentity } : null;
  },
  store: yourStoreAdapter satisfies CortexStore,
});
// Mount at /cortex — Supabase Edge Functions, Deno or a Node Fetch adapter.

What you get

Everything a production knowledge agent needs

Claim-level citations

Answers carry GIST and CIT markers that resolve to claims and references with durable IDs.

PDF page + highlight

References include page, coordinates and dimensions. PdfEvidence renders the passage highlighted.

Rich evidence

Preserve source and evidence metadata across supported formats. The SDK renders PDF highlights and textual evidence; other media viewers belong to your application.

Streaming with memory

Session-aware answers with adjustable detail (succinct → detailed) and technicality (simple → technical).

Typed end to end

Generated OpenAPI 3.1, TypeScript types and Zod runtime validators. No guessing at payloads.

Tested integration SDK

Stream parser, citation reducer, token refresh and ownership checks — with replay fixtures that need no key.

Secure by design

Scoped, revocable server keys. The browser only talks to your backend. Per-user checks before any PDF.

Sovereign by default

Built in Zurich by Uthereal AG on Swiss sovereign infrastructure with zero data retention.

Compare

Cortex vs. building RAG yourself

Time to first cited answer in your app
Uthereal Cortex
Open SDK, copy setup instructions
DIY RAG on a cloud AI stack
Design ingestion, index, prompts, API, UI
Basic vector-search API
Build prompting, answers and UI
Ingestion, chunking, indexing
Uthereal Cortex
Managed
DIY RAG on a cloud AI stack
You build and tune
Basic vector-search API
Partly — you chunk and embed
Generated answers with session memory
Uthereal Cortex
Included
DIY RAG on a cloud AI stack
You build
Basic vector-search API
Not included
Claim-level citations with durable IDs
Uthereal Cortex
Included
DIY RAG on a cloud AI stack
You design the format
Basic vector-search API
Not included
Open cited PDF page with highlight
Uthereal Cortex
Included (React)
DIY RAG on a cloud AI stack
Custom build
Basic vector-search API
Not included
Retrieval-only JSON endpoint
Uthereal Cortex
Included
DIY RAG on a cloud AI stack
You build
Basic vector-search API
Core feature
Typed SDK, OpenAPI, runtime validators
Uthereal Cortex
Versioned public contract
DIY RAG on a cloud AI stack
You write
Basic vector-search API
Varies
Instructions for AI coding agents
Uthereal Cortex
One public integration guide
DIY RAG on a cloud AI stack
None
Basic vector-search API
Rare
Test fixtures without API keys
Uthereal Cortex
Included
DIY RAG on a cloud AI stack
You write
Basic vector-search API
Rare

Reference

API at a glance

Base URL: https://agent.uthereal.ai/api/functions/v1/api-server-proxy · Headers: Authorization: Bearer <assistant key>, X-App-Code: selfserve

Ask
Method and path
POST /external/v1/assistants/{assistant}/sessions/{external_session}/ask
Body and scope
{ id_user, message, detail_level?, technicality_level? } → NDJSON stream. Scope: ask
RAG
Method and path
POST /external/v1/assistants/{assistant}/rag
Body and scope
{ query, id_user?, max_results? (1–20), datasource_ids? (≤50) } → JSON. Scope: rag
PDF
Method and path
GET /chat/reference/pdf/{token}?page={page}
Body and scope
Cited page slice with X-External-User-Id. Scope: ask
Refresh
Method and path
POST /chat/reference/pdf/refresh
Body and scope
Renews an expired PDF reference once from saved IDs. Scope: ask

SDK entry points

sdk/core.ts

Generated OpenAPI types, Zod validators, readAnswers, mergeAnswer, resolveMarker, pdfLocation.

sdk/server.ts

createCortexHandler, CortexStore, CortexClient — server only, holds the API key.

sdk/browser.ts

createCortexBrowserClient — create, ask, rag, pdf against your own endpoint.

sdk/react.ts

CitedAnswer and PdfEvidence components for React 18 and 19.

sdk/adapters/supabase-server.ts

Supabase auth + storage adapter for Edge Functions.

sdk/adapters/supabase-browser.ts

Supabase browser adapter for authenticated fetch.

Requirements: TypeScript; React 18 or 19 for the components; Zod, TanStack Query 5, React-PDF 9. The runnable example uses Node 22, pnpm 10, Deno 2 and the Supabase CLI.

Errors: 400/422 input · 401 invalid or revoked key · 403 missing scope · 404 not found · 502/503/504 transient. Keep X-Request-ID for support — questions? sdk@uthereal.ai. Full guide for AI tools: cortex.md · llms.txt

FAQ

Questions developers ask

How do I make my AI coding tool use the Uthereal Cortex SDK?

Add one instruction file to your repository: AGENTS.md for Codex (https://uthereal.ai/developers/agents.md), CLAUDE.md for Claude Code, .cursor/rules/uthereal-cortex-sdk.mdc for Cursor, .windsurf/rules/uthereal-cortex-sdk.md for Windsurf, .github/copilot-instructions.md for GitHub Copilot, or paste https://uthereal.ai/developers/lovable.md into Lovable. Each file tells the tool what Cortex is, when to use it and how to wire the SDK in safely.

What is Uthereal Cortex?

A platform that turns an organisation's knowledge base into an AI agent that answers with verifiable citations, callable from any application through an API and a TypeScript SDK.

Can I use Cortex with Lovable?

Yes. Open the public SDK for your agent and give it to Lovable. It includes a Supabase Edge Function handler, a Supabase auth adapter and React components that match the Lovable stack.

Does it work with Codex, Claude Code and Cursor?

Yes. The public repository provides a canonical integration guide, contributor instructions and fixture tests. Supply its pinned revision and your agent configuration to your coding tool.

Is Cortex a RAG API?

Both an answer API and a RAG API. Use ask for streamed, cited answers, or rag for ranked retrieval results to feed your own model.

Where does my API key go?

Only in your server secrets, for example Supabase Edge Function secrets. The browser calls your backend, which calls Cortex.

Can I test without credentials?

Yes. Run pnpm dev and open localhost:5173/?replay to render synthetic answers, citations and a highlighted PDF.

Do I need Supabase?

No. Supabase is an optional adapter. Implement authenticate and CortexStore for any backend that runs a Fetch API handler.

Ship a knowledge agent your users can trust

Create your agent, open the SDK, and copy the setup instructions into your AI coding tool.

Need help? Email us at sdk@uthereal.ai

Machine-readable versions: /developers/sdk.md · /llms.txt