Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trulayer.ai/llms.txt

Use this file to discover all available pages before exploring further.

The demo-typescript repository contains a curated set of standalone scripts that show every public surface of @trulayer/sdk end-to-end. Each example is intentionally small — one concept per file — so you can copy a pattern straight into your own app.
Status: alpha. The demo scripts currently pin the SDK from a local sibling path while we cut the first public release. Standalone clones will fail to install until @trulayer/sdk 0.1.0 is on npm. Track the release in the demo-typescript repo. Once 0.1.0 ships, this notice will be removed.

What’s in the repo

  • 11 runnable examples under examples/, one per SDK concept (manual tracing, auto-instrumentation, RAG, agents, streaming, feedback, Vercel AI SDK, Next.js).
  • A local mock ingestion server (examples/mock-server.ts) so you can run every example offline.
  • A Vitest suite (tests/smoke.test.ts) that asserts each script’s payload shape end-to-end.

Clone and run

git clone https://github.com/trulayer/demo-typescript.git
cd demo-typescript
cp .env.example .env     # add TRULAYER_API_KEY and provider keys
pnpm install
pnpm basic-trace
To run every example against the bundled mock server (no network, no real keys):
pnpm run-all

Representative examples

basic-trace.ts

Manual trace() and span() around a real OpenAI call — the smallest possible end-to-end example.

openai-auto.ts

instrumentOpenAI() — wraps the client so every chat.completions.create becomes a span automatically.

vercel-ai.ts

instrumentVercelAI() — auto-trace generateText, streamText, generateObject, and streamObject.

nextjs-route.ts

A Next.js App Router API route that traces a chat handler end-to-end with a SIGTERM-safe flush.

agent.ts

Tool-calling agent loop, with one span per tool invocation and one per LLM turn.
For the full list, see the examples directory on GitHub.

Where to go next

Tutorial

Build the same patterns from scratch with a step-by-step walkthrough.

Reference

Every public export, with signatures and types.