Documentation Index
Fetch the complete documentation index at: https://docs.okrapdf.com/llms.txt
Use this file to discover all available pages before exploring further.
Why
Most coding agents follow the same loop:
- define tools
- model picks tools
- execute tools
- return tool results
- repeat
With OkraPDF, each processed document can be exposed as a tool by mapping tool names to session.prompt(...).
Core pattern
import { createOkra } from '@okrapdf/runtime';
const okra = createOkra({ apiKey: process.env.OKRA_API_KEY! });
const docs = [
{ id: 'ocr-abc123', label: 'NVIDIA 10-K' },
{ id: 'ocr-def456', label: 'AMD 10-K' },
{ id: 'ocr-ghi789', label: 'Intel 10-K' },
];
const sessions = Object.fromEntries(
docs.map((d, i) => [`query_doc_${i}`, okra.sessions.from(d.id)]),
);
async function executeDocTool(name: string, question: string): Promise<string> {
const session = sessions[name];
if (!session) throw new Error(`Unknown doc tool: ${name}`);
const { answer } = await session.prompt(question);
return answer;
}
const toolCalls = res.content.filter((b) => b.type === 'tool_use');
const results = await Promise.all(
toolCalls.map(async (tc) => ({
type: 'tool_result' as const,
tool_use_id: tc.id,
content: await executeDocTool(
tc.name,
(tc.input as { question: string }).question,
),
})),
);
for (const tc of msg.tool_calls ?? []) {
const input = JSON.parse(tc.function.arguments) as { question: string };
const session = sessions[tc.function.name];
const { answer } = await session.prompt(input.question);
messages.push({
role: 'tool',
tool_call_id: tc.id,
content: answer,
});
}
Multi-document fan-out
If your orchestration logic already knows which docs to hit, run in parallel:
const prompts = [
okra.sessions.from('ocr_a').prompt('What was revenue and YoY growth?'),
okra.sessions.from('ocr_b').prompt('What was revenue and YoY growth?'),
okra.sessions.from('ocr_c').prompt('What was revenue and YoY growth?'),
];
const results = await Promise.all(prompts);
When to use this pattern
- You want custom prompts and full agent control in your app runtime.
- You want to combine document tools with non-document tools (web search, calculators, DB lookups).
- You want transparent orchestration instead of a managed server-side multi-doc agent.