Examples
External Metering File Key
Same pre-request balance check and post-response usage reporting as external-metering.yaml, but the internal bearer credential used to authenticate the metering callouts is read from a file rather than embedded in the config or image
Switching projects opens that project’s default documentation release.
Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.
Category: Setup-dependent integration
Task: Same pre-request balance check and post-response usage reporting as external-metering.yaml, but the internal bearer credential used to authenticate the metering callouts is read from a file rather than embedded in the config or image
Prerequisites: The external service, credentials, or certificates referenced by this configuration.
Run it: Use ghcr.io/praxis-proxy/ai:0.10.0 and follow the container quickstart to mount and start the configuration.
This configuration comes from the selected release. The example has not been run here; external services are not bundled.
Download the source file.
Companion resources from the same snapshot:
# External Metering with a File-Backed Internal Auth Token
#
# Same pre-request balance check and post-response usage reporting as
# external-metering.yaml, but the internal bearer credential used to
# authenticate the metering callouts is read from a file rather than
# embedded in the config or image.
#
# This suits a Kubernetes projected Secret mounted at a fixed path: the
# platform rotates the file in place and `external_metering` picks up the
# new token without a restart or image rebuild. The token value never
# appears in logs, tracing, or the rendered config. If the file is
# missing, unreadable, empty, or oversized at startup the proxy fails to
# start; if a post-startup rotation produces no valid token the metering
# callouts fail closed (never dialed unauthenticated) and the existing
# `fail_open` policy then decides whether the request proceeds.
#
listeners:
- name: default
address: "127.0.0.1:8080"
filter_chains:
- main
filter_chains:
- name: main
filters:
- filter: router
routes:
- path_prefix: "/"
cluster: backend
- filter: external_metering
metering_url: "http://127.0.0.1:9090"
# The metering service in this example listens on loopback, a
# non-public address, so callouts must be explicitly opted in.
allow_private_endpoint: true
timeout_seconds: 5
feature_key: "inference-tokens"
source: "ai-gateway"
fail_open: true
identity_header_prefix: "x-tenant-"
# Internal bearer token for the metering callouts, read from a file
# and watched for rotation. One of `value | env_var | file`.
internal_auth_token:
file: /etc/praxis/metering-token
- filter: token_count
provider: openai
- filter: load_balancer
clusters:
- name: backend
endpoints:
- "127.0.0.1:3000"
insecure_options:
allow_private_endpoints: true # example proxies to local backends