Skip to main content
This page follows one example: a support feature that answers a customer’s ticket in two LLM calls, first classifying it, then drafting the reply. Each step works the same whether your calls go through the gateway or straight to your provider, recorded by telemetry: pick your tab.

1. Set up

Turn on the x-weflayr-metadata header once: every gateway call, made by any OpenAI client, then carries the values of the scope it is made in.
Without the SDK, set the same values on each request yourself: see the gateway’s Weflayr fields.

2. Tag the feature run and name its calls

Wrap the feature in propagate_metadata / propagateMetadata: every LLM call made inside, including nested ones, carries its values, and the scope is one feature run, which AI cost counts and prices. Inside it, set_call_name / setCallName names each call.
  • feature_name: the product feature making the calls.
  • customer_name: who the calls are for, to join your AI cost with your revenue.
  • call_name: one LLM call of the feature. A benchmark is set up per call name.

3. Keep one run across processes

Each scope starts a new feature run. When one run spans several processes, for example the ticket classified by your API and the reply drafted by a worker, the two scopes would count as two runs. Create the run’s id once where it starts, send it along with the work, and pass it to every scope of the run.
Any id you pass must have the shape create_feature_run_uuid / createFeatureRunUuid gives: 32 lowercase hexadecimal characters.