Build your first integration

Run Ivorleaf from a trusted server, create one Technical Session, inspect validation, and retain session_id for later work.

type TechnicalSession = {
  session_id: string;
  answer: string;
  sources?: unknown[];
  technical_analysis?: { analyses?: unknown[] };
};

export async function createTechnicalSession(query: string): Promise<TechnicalSession> {
  const response = await fetch(`${process.env.IVORLEAF_API_BASE_URL}/v1/tutor`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.IVORLEAF_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ query }),
  });
  if (!response.ok) throw new Error(`Ivorleaf HTTP ${response.status}: ${await response.text()}`);
  return response.json();
}

Store the returned session_id with your own job or domain record. Do not expose the private API key to the browser. Follow Validation Responses before automating continuation.