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
string
default:"https://gateway.weflayr.com"
The gateway URL whose requests get the header. Requests to any other host are left unchanged.
Example
Example
propagate_metadata
Parameters
Parameters
string
required
The product feature making the call (e.g.
"support-chat").string
The customer the call is made for. It joins your AI cost to your revenue.
dict[str, str | int | float | bool]
Your own dimensions to filter on.
string
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.function
Runs this function inside the scope and returns its result.
weflayr.AIProviderName
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.
Example
Example
Track calls with telemetry only
auto_instrument
Parameters
Parameters
Example
Example
setup
Parameters
Parameters
string
A key with the Management scope. Defaults to
WEFLAYR_API_KEY.string
default:"https://api.weflayr.com"
Where recorded calls are sent.
dict
Tags added to every recorded call.
"batch" | "immediate"
default:"batch"
"immediate" sends each call as soon as it ends, instead of in batches.boolean
default:"true"
Set
False to keep prompts, answers and tool definitions in your process: only tokens, cost and latency are sent.function
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.boolean
default:"true"
Set
False to silence the warning written to stderr on each failed export.Example
Example
set_call_name
propagate_metadata scope and does not start a new feature run.
Parameters
Parameters
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