Quick Start
Get observability on your LLM calls in under 2 minutes.
Install the SDK
npm install weflayrpip install weflayrGet your credentials
Your Flayr credentials are in the Weflayr app under My Flayrs. Pass them directly to
weflayr_setup, or load them from environment variables viadotenv:# .env WEFLAYR_INTAKE_URL=https://api.weflayr.com WEFLAYR_CLIENT_ID=your-client-id WEFLAYR_CLIENT_SECRET=your-client-secretConfigure and instrument your client
const OpenAI = require('openai'); const { weflayr_setup, weflayr_instrument } = require('weflayr'); weflayr_setup({ intake_url: process.env.WEFLAYR_INTAKE_URL, client_id: process.env.WEFLAYR_CLIENT_ID, client_secret: process.env.WEFLAYR_CLIENT_SECRET, default_tags: { app: 'my-app', version: '1.0.0', }, methods: [ { call: 'chat.completions.create' }, ], }); const client = weflayr_instrument(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));import os from openai import OpenAI from weflayr import weflayr_setup, weflayr_instrument weflayr_setup({ "intake_url": os.environ["WEFLAYR_INTAKE_URL"], "client_id": os.environ["WEFLAYR_CLIENT_ID"], "client_secret": os.environ["WEFLAYR_CLIENT_SECRET"], "default_tags": { "app": "my-app", "version": "1.0.0", }, "methods": [ {"call": "chat.completions.create"}, ], }) client = weflayr_instrument(OpenAI(api_key=os.environ["OPENAI_API_KEY"]))weflayr_setupmust be called beforeweflayr_instrument. Themethodsarray is the whitelist — only listed call paths are instrumented.default_tagsare attached to every event automatically — see Propagate for runtime tagging.Make a call and telemetry will be automatic
const response = await client.chat.completions.create({ model: 'gpt-4o-mini', messages: [{ role: 'user', content: 'Hello!' }], __weflayr_tags: { provider: 'openai', feature: 'onboarding', customer_id: '#3756' }, }); // response is the standard OpenAI response object — unchangedresponse = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello!"}], __weflayr_tags={ "provider": "openai", "feature": "onboarding", "customer_id": "#3756", }, ) # response is the standard OpenAI response object — unchanged__weflayr_tagsis stripped before forwarding to OpenAI and attached to the telemetry events.