PyPI
The
weflayr package.Changelog
What changed in each release.
Send extra metadata to the gateway
Group the gateway calls of the same feature, and optionally tag their customer and your own dimensions.
Track calls with telemetry only
Record the calls your app makes to Anthropic, OpenAI, Bedrock, Vertex AI and other providers directly.
Call the management API
Read your costs and margin, and push revenue and customer tags.
Install
Requires Python 3.13 or later.Reference
Send extra metadata to the gateway
enable_propagate_metadata_to_gateway
propagate_metadata values in the x-weflayr-metadata header of its gateway requests.
Parameters
Parameters
Example
Example
propagate_metadata
Parameters
Parameters
Records the calls under this run instead of a new one, to group the calls of one run made in several scopes or processes. Create it with
weflayr.create_feature_run_uuid(): 32 lowercase hexadecimal characters.The provider to bill a call recorded by telemetry, when the client on the wire differs from it (e.g. Mistral reached through the OpenAI client). Ignored for gateway calls. One of
OPENAI, AZURE_OPENAI, ANTHROPIC, BEDROCK, COHERE, ELEVENLABS, MISTRAL, GOOGLE, VERTEX, ALIBABA, SPACEXAI, META, TOGETHER, TENSORX, DEEPSEEK or ZAI.Example
Example
Track calls with telemetry only
auto_instrument
Parameters
Parameters
OPENAI, ANTHROPIC, BEDROCK, COHERE, GOOGLE_GENAI, ELEVENLABS or MISTRAL, or a list of them.setup.Example
Example
setup
Parameters
Parameters
"immediate" sends each call as soon as it ends, instead of in batches.Set
False to keep prompts, answers and tool definitions in your process: only tokens, cost and latency are sent.Receives a copy of each call’s attributes and returns the ones to send. Returning
None keeps them unchanged; raising an error drops all of them.Example
Example
set_call_name
propagate_metadata scope and does not start a new feature run.
Parameters
Parameters
The name of the call (e.g.
"summarize_ticket"). A benchmark is set up per call name.Example
Example
flush
Example
Example
Call the management API
Every management API route, with its SDK method, is listed in Call the management API.client
Parameters
Parameters
Example
Example