Skip to main content

Overview

Use an ask share link when you want public prompt access to a document without exposing your API key.

SDK flow

import { createOkra } from '@okrapdf/runtime';

const okra = createOkra({ apiKey: process.env.OKRA_API_KEY });

const session = await okra.sessions.create('./quarterly-report.pdf', {
  wait: true,
});

const link = await session.shareLink({
  role: 'ask',
  maxViews: 1000,
  expiresInMs: 24 * 60 * 60 * 1000,
});

console.log(link.links.completion);

Consumer curl (no API key)

curl -X POST "https://api.okrapdf.com/document/ocr-demo/completion?token=..." \
  -H "Content-Type: application/json" \
  -d '{"prompt":"What was total revenue?"}'
Use the exact URL returned by link.links.completion.

Internal authenticated prompt

For server-side usage where you control credentials, keep using session prompts:
const { answer } = await session.prompt('What was revenue?');
console.log(answer);

Revoke / rotate

Revoke a link and create a new one:
curl -X DELETE "https://api.okrapdf.com/document/ocr-demo/share-link?tokenHint=..." \
  -H "Authorization: Bearer $OKRA_API_KEY"
Then call session.shareLink({ role: 'ask' }) again for a new link.