This directory contains examples demonstrating key features of the Gentrace Node.js SDK.
custom-configuration.ts- Custom OpenTelemetry configuration with service name, sampler, and resource attributesmanual-otel.ts- Manual OpenTelemetry SDK setup for full control over tracing
openai-ai-sdk.ts- Simple OpenAI integration with Vercel AI SDK for text generationanthropic-ai-sdk.ts- Anthropic Claude integration with Vercel AI SDKstreaming-ai-sdk.ts- Streaming responses from AI models with real-time outputmastra-ai-sdk.ts- Integration with Mastra framework and Vercel AI SDK
evaluation.ts- Basic evaluation example using evalOnce within experimentsevaluation-dataset.ts- Advanced evaluation against datasets fetched from Gentrace
genai-semantic-conventions.ts- Comprehensive GenAI semantic conventions implementation including chat completions and function calling
# with yarn
yarn install
# with pnpm
pnpm install
# with npm
npm installCreate a .env file in the root of this repository with your API keys. Copy .env.example to .env and fill in the values:
cp .env.example .envAlternatively, you can set the environment variables in your terminal.
# with yarn
yarn example examples/openai-ai-sdk.ts
# with pnpm
pnpm example examples/openai-ai-sdk.ts
# with npm
npm run example examples/openai-ai-sdk.tsFor more comprehensive documentation on Gentrace, see the docs.