revenium-python-sdk 0.12.1__tar.gz → 0.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/PKG-INFO +145 -7
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/README.md +144 -6
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/pyproject.toml +1 -1
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/cache_tokens.py +9 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/enforcement.py +9 -3
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/fields.py +3 -1
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/wire_guards.py +2 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/ai.py +22 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_completion_params.py +12 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_transport.py +5 -3
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/middleware.py +2 -2
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/provider.py +100 -67
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/middleware.py +20 -4
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/guardrail.py +301 -35
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/middleware.py +17 -7
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_model_call.py +2 -2
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/provider.py +12 -3
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/trace_fields.py +2 -2
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/PKG-INFO +145 -7
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/LICENSE +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/call_context.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/call_ownership.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/closable_scope.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/context.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/decorators.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/delivery_circuit.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/error_text.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/exceptions.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/failed_calls.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/json_safe.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/langchain_settings.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/load_diagnostics.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/log_sanitize.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_buffer.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_pool.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_status.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_submission.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/outcomes.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/package_versions.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/parse_failures.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/patch_registry.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/perplexity_cost.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/perplexity_usage_metadata.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/prompt_extraction.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/responses_status.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/secret_shapes.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/selective_metering.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/shutdown_signals.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/sse_body_tap.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/subscriber.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/tool_event_transport.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/usage_iterations.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/vendor_model_aliases.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/LICENSE +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_base_client.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_client.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_compat.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_constants.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_exceptions.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_files.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_models.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_qs.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_resource.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_response.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_streaming.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_types.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_logs.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_proxy.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_reflection.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_resources_proxy.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_streams.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_sync.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_transform.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_typing.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_utils.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_version.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/context.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/decorator.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/py.typed +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/apis.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/events.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_audio_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_image_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_video_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/api_meter_request_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/api_meter_response_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/event_create_params.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/metering_response_resource.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/agentic_outcomes.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_adapter.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_model_names.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/inference_profiles.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/raw_response.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/stream_create.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_call.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_metering.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_queue.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/exceptions.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/protocols.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/types.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/utils.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/provider.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/provider.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/_metadata.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/_retry.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/anthropic_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/budget_errors.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/litellm_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/ollama_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/openai_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/openai_embedding_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/universal_driver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/job_context.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/job_history.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/job_type_economics.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/context.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/decorators.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/hooks.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/integrations/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/integrations/crewai.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/validation.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/_metering_owner.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/audio.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/azure_config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/azure_model_resolver.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/config.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/exceptions.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_abandoned_runs.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_perplexity_cost_capture.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_prompt_capture.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_text_completion_usage.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_utils.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/unified_handler.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/raw_response.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/xai_usage.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/_metering_scope.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/middleware.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/patching.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/perplexity_sdk.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/provider.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/raw_response.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/streaming.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/trace_fields.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/webhooks/__init__.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/webhooks/_verify.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/SOURCES.txt +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/dependency_links.txt +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/requires.txt +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/top_level.txt +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/setup.cfg +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/tests/test_metering.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/tests/test_metering_dispatch_timestamps.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/tests/test_patch_coverage.py +0 -0
- {revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/tests/test_release_verify_ticket.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: revenium-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: The official Revenium Python SDK — unified AI metering middleware for OpenAI, Anthropic, Google, Ollama, LiteLLM, Perplexity, and fal.ai.
|
|
5
5
|
Author-email: Revenium <support@revenium.io>
|
|
6
6
|
License: MIT
|
|
@@ -144,8 +144,10 @@ The official Revenium Python SDK — unified AI metering middleware for deeply a
|
|
|
144
144
|
| OpenAI | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
145
145
|
| Azure OpenAI | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
146
146
|
| xAI (Grok, via OpenAI SDK) | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
147
|
+
| OpenRouter (via OpenAI SDK) | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
147
148
|
| Anthropic | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
148
149
|
| AWS Bedrock (Anthropic) | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
150
|
+
| Google Cloud (Anthropic managed) | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
149
151
|
| Google Gemini | `google-genai` | `pip install revenium-python-sdk[google-genai]` |
|
|
150
152
|
| Google Vertex AI | `google-vertex` | `pip install revenium-python-sdk[google-vertex]` |
|
|
151
153
|
| Ollama | `ollama` | `pip install revenium-python-sdk[ollama]` |
|
|
@@ -787,6 +789,26 @@ response = client.chat.completions.create(
|
|
|
787
789
|
)
|
|
788
790
|
```
|
|
789
791
|
|
|
792
|
+
#### OpenRouter
|
|
793
|
+
|
|
794
|
+
Point the OpenAI client at OpenRouter and calls are recorded with provider and model source `OPENROUTER`, so OpenRouter spend is reported as OpenRouter rather than OpenAI and a spending cap scoped to OpenRouter applies to it. This covers chat, Responses and embeddings calls, sync and async, streamed or not, on any base URL whose host is `openrouter.ai` or one of its subdomains; a proxy or gateway on your own domain is recorded as the OpenAI-compatible call it appears to be.
|
|
795
|
+
|
|
796
|
+
```python
|
|
797
|
+
import os
|
|
798
|
+
from openai import OpenAI
|
|
799
|
+
import revenium_middleware.openai
|
|
800
|
+
|
|
801
|
+
client = OpenAI(
|
|
802
|
+
api_key=os.getenv("OPENROUTER_API_KEY"),
|
|
803
|
+
base_url="https://openrouter.ai/api/v1"
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
response = client.chat.completions.create(
|
|
807
|
+
model="openai/gpt-4o-mini",
|
|
808
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
809
|
+
)
|
|
810
|
+
```
|
|
811
|
+
|
|
790
812
|
---
|
|
791
813
|
|
|
792
814
|
### Anthropic
|
|
@@ -876,7 +898,7 @@ message = client.messages.create(
|
|
|
876
898
|
|
|
877
899
|
**Provider detection** automatically routes between Bedrock and direct Anthropic API based on:
|
|
878
900
|
- AWS credentials availability (`aws configure`, IAM roles, environment variables)
|
|
879
|
-
- Base URL detection (when `base_url` contains `amazonaws.com`)
|
|
901
|
+
- Base URL detection (when `base_url` contains `amazonaws.com`). The Anthropic SDK's Foundry and Google Cloud clients are labelled by their class first, so one behind an AWS-hosted gateway stays `Foundry` or `Google`
|
|
880
902
|
- Defaults to direct Anthropic API - Bedrock only used when explicitly configured
|
|
881
903
|
|
|
882
904
|
**Bedrock environment variables:**
|
|
@@ -884,7 +906,7 @@ message = client.messages.create(
|
|
|
884
906
|
| Variable | Description | Default |
|
|
885
907
|
|----------|-------------|---------|
|
|
886
908
|
| `AWS_REGION` | AWS region for Bedrock | `us-east-1` |
|
|
887
|
-
| `REVENIUM_BEDROCK_DISABLE` | Set to `1` to disable Bedrock support for Anthropic clients (Bedrock detection only - Foundry detection
|
|
909
|
+
| `REVENIUM_BEDROCK_DISABLE` | Set to `1` to disable Bedrock support for Anthropic clients (Bedrock detection only - Foundry and Google Cloud detection are unaffected). Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT`, and LangChain's `ChatBedrock` and `ChatBedrockConverse`, are recorded as Bedrock | Not set |
|
|
888
910
|
| `REVENIUM_BEDROCK_TRANSPORT` | Set to `1` or `true` to meter Claude models called through a raw `boto3.client("bedrock-runtime")` (`invoke_model`, `invoke_model_with_response_stream`, `converse`, `converse_stream`); other Bedrock models are never metered this way | Not set |
|
|
889
911
|
|
|
890
912
|
**AWS authentication**: an `AnthropicBedrock` client uses its own `aws_access_key` / `aws_secret_key` / `aws_session_token`, `aws_profile` or Bedrock `api_key`, exactly as without the middleware. A plain `anthropic.Anthropic` client with a Bedrock `base_url` uses the standard credential chain: environment variables, `~/.aws/credentials`, IAM roles, AWS SSO. Required permissions: `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream`.
|
|
@@ -909,6 +931,8 @@ message = client.messages.create(
|
|
|
909
931
|
|
|
910
932
|
For other models, the middleware uses the format `anthropic.{model_name}`.
|
|
911
933
|
|
|
934
|
+
Bedrock usage is reported with provider `Bedrock` and model source `ANTHROPIC` (or the model's vendor for LangChain `ChatBedrock`), and caps on `AWS` still match.
|
|
935
|
+
|
|
912
936
|
#### Microsoft Foundry
|
|
913
937
|
|
|
914
938
|
Claude served through Microsoft Foundry is metered by the same patched endpoints as the
|
|
@@ -935,6 +959,36 @@ is separated from direct-Anthropic totals while still priced against the Anthrop
|
|
|
935
959
|
that Foundry bills at. `AsyncAnthropicFoundry` is metered the same way, as is
|
|
936
960
|
`client.messages.stream()`.
|
|
937
961
|
|
|
962
|
+
#### Google Cloud (Anthropic managed)
|
|
963
|
+
|
|
964
|
+
Claude reached through your Google Cloud project with the Anthropic SDK's Google Cloud
|
|
965
|
+
client (anthropic 2.4.0 or later) is metered by the same patched endpoints, with no extra setup.
|
|
966
|
+
|
|
967
|
+
```python
|
|
968
|
+
import anthropic
|
|
969
|
+
import revenium_middleware.anthropic
|
|
970
|
+
|
|
971
|
+
# Detected from the client class, so a custom base_url is fine too
|
|
972
|
+
client = anthropic.AnthropicGoogleCloud(
|
|
973
|
+
project="your-project",
|
|
974
|
+
location="global",
|
|
975
|
+
workspace_id="your-workspace-id",
|
|
976
|
+
)
|
|
977
|
+
|
|
978
|
+
message = client.messages.create(
|
|
979
|
+
model="claude-opus-4-7",
|
|
980
|
+
max_tokens=100,
|
|
981
|
+
messages=[{"role": "user", "content": "Hello from Google Cloud!"}]
|
|
982
|
+
)
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
Google Cloud usage is reported with provider `Google` and model source `ANTHROPIC`, the
|
|
986
|
+
values the Node SDK sends for Google-billed Claude, because Google Cloud Marketplace bills
|
|
987
|
+
these calls. `AsyncAnthropicGoogleCloud` is metered the same way, as is
|
|
988
|
+
`client.messages.stream()`. A spending cap scoped to the `Google` provider counts these
|
|
989
|
+
calls; one scoped to `ANTHROPIC` does not. Claude through the older `AnthropicVertex`
|
|
990
|
+
client is still reported with provider `ANTHROPIC`.
|
|
991
|
+
|
|
938
992
|
**Examples:** `examples/anthropic/` - `anthropic-basic.py`, `anthropic-streaming.py`, `anthropic-bedrock.py`, `anthropic-advanced.py`
|
|
939
993
|
|
|
940
994
|
---
|
|
@@ -1197,6 +1251,24 @@ the others to be recorded. A malformed header value, such as a quality score of
|
|
|
1197
1251
|
`high` or an effort of `very high`, is left off the record with a WARNING in the
|
|
1198
1252
|
gateway log; the call is still recorded.
|
|
1199
1253
|
|
|
1254
|
+
**LiteLLM identities.** Below those sources, the guardrail also reads what
|
|
1255
|
+
LiteLLM itself resolved for the call:
|
|
1256
|
+
|
|
1257
|
+
| Revenium field | LiteLLM source | Used when |
|
|
1258
|
+
|---|---|---|
|
|
1259
|
+
| `subscriber.id` | The end user: the request's `user`, or the header named by LiteLLM's `user_header_name` | Nothing else named a subscriber id or email. A key with an owner keeps attributing to the owner, and the end user is never paired with the owner's email. |
|
|
1260
|
+
| `organizationName` | The alias of the LiteLLM organization the key belongs to | No header, team alias or `revenium_organization_name` key metadata named one |
|
|
1261
|
+
| `productName` | The alias of the LiteLLM project the key belongs to | No `x-revenium-product-name` header or `product_name:` tag |
|
|
1262
|
+
|
|
1263
|
+
LiteLLM organizations and projects need a LiteLLM enterprise license; without
|
|
1264
|
+
one these fallbacks never apply. Every record also carries `reasoningTokenCount`
|
|
1265
|
+
from LiteLLM's normalized usage (it is already inside the output count, which is
|
|
1266
|
+
unchanged) and `modelHost`, the LiteLLM provider that served the call (`openai`,
|
|
1267
|
+
`azure`, `bedrock`, ...; LiteLLM's `vertex_ai` is sent as `vertex` and `azure_ai` as
|
|
1268
|
+
`foundry`, the names coding-assistant records use). `provider` stays `LITELLM`, so
|
|
1269
|
+
provider-scoped spending caps and existing breakdowns are unaffected. The
|
|
1270
|
+
deprecated callback reads none of these.
|
|
1271
|
+
|
|
1200
1272
|
**Trace id.** The guardrail takes a record's trace id from `x-revenium-trace-id`.
|
|
1201
1273
|
Without that header it takes the LiteLLM session id the caller sent: the
|
|
1202
1274
|
`x-litellm-session-id` or `x-litellm-trace-id` header, or `litellm_session_id` or
|
|
@@ -1220,6 +1292,58 @@ never named after its LiteLLM session. A name over 256 characters is cut to 256.
|
|
|
1220
1292
|
with no LiteLLM session and no name has no trace name. The deprecated callback
|
|
1221
1293
|
reads only the header and `REVENIUM_TRACE_NAME`.
|
|
1222
1294
|
|
|
1295
|
+
**Attribution from LiteLLM tags.** Six fields can also come from LiteLLM's own tags,
|
|
1296
|
+
so a gateway caller needs no Revenium header to set them. A tag `<field>:<value>`
|
|
1297
|
+
fills the field when its `x-revenium-*` header is absent or blank:
|
|
1298
|
+
|
|
1299
|
+
| Tag | Fills | Instead of |
|
|
1300
|
+
|-----|-------|------------|
|
|
1301
|
+
| `trace_type:<value>` | trace type | `x-revenium-trace-type` |
|
|
1302
|
+
| `task_type:<value>` | task type | `x-revenium-task-type` |
|
|
1303
|
+
| `agent:<value>` | agent | `x-revenium-agent` |
|
|
1304
|
+
| `product_name:<value>` | product name | `x-revenium-product-name` |
|
|
1305
|
+
| `environment:<value>` | environment | `x-revenium-environment` |
|
|
1306
|
+
| `transaction_name:<value>` | transaction name | `x-revenium-transaction-name` |
|
|
1307
|
+
|
|
1308
|
+
The guardrail reads the tags LiteLLM has merged by the time it runs: the caller's
|
|
1309
|
+
(body `metadata.tags` or root `tags`, or the `x-litellm-tags` header) and those of
|
|
1310
|
+
the calling virtual key, team and project. For each field the header wins, then the
|
|
1311
|
+
caller's tag, then a key, team or project tag, then the gateway setting such as
|
|
1312
|
+
`REVENIUM_TRACE_TYPE`. Two different values at one level are ignored and the next
|
|
1313
|
+
level decides; a WARNING names the field once per request. Values are validated as
|
|
1314
|
+
the header's are. A key or team tag is a per-customer default; a request tag
|
|
1315
|
+
describes one call:
|
|
1316
|
+
|
|
1317
|
+
```python
|
|
1318
|
+
client.chat.completions.create(
|
|
1319
|
+
model="gpt-4o-mini",
|
|
1320
|
+
messages=[...],
|
|
1321
|
+
extra_body={"metadata": {"tags": ["trace_type:research-brief", "agent:research-planner"]}},
|
|
1322
|
+
)
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
A tag carries the same weight as its header. Agent, task type and product also
|
|
1326
|
+
decide which spending caps apply, so a `product_name:`, `agent:` or `task_type:` tag
|
|
1327
|
+
can move a call into or out of a cap filtered on that field, and a caller's request
|
|
1328
|
+
tag overrides a key's or team's. On upgrade, a key or team that already carries tags
|
|
1329
|
+
of this form starts setting these fields, for the record and the cap check alike;
|
|
1330
|
+
review existing tags before upgrading if you filter caps on agent, task type or
|
|
1331
|
+
product.
|
|
1332
|
+
|
|
1333
|
+
Tags reach the pre-call cap check only when the guardrail writes the record itself
|
|
1334
|
+
(`default_on: true` with `post_call` in its mode), so a call is never checked under a
|
|
1335
|
+
value its record lacks. The deprecated callback reads headers only.
|
|
1336
|
+
|
|
1337
|
+
LiteLLM records which tags the request itself sent (`caller_tags`), so a caller's tag
|
|
1338
|
+
stays the caller's even when the key or team carries the same string. Body
|
|
1339
|
+
`metadata.tags` on `/chat/completions` is the exception: LiteLLM leaves it out of
|
|
1340
|
+
that record, so there a tag that is also a key or team tag counts as the key's or
|
|
1341
|
+
team's.
|
|
1342
|
+
|
|
1343
|
+
Tags never set the organization, subscriber, subscription, agentic job or trace id:
|
|
1344
|
+
those are billing identity and trace grouping, and keep coming from headers and the
|
|
1345
|
+
virtual key.
|
|
1346
|
+
|
|
1223
1347
|
**Organization caps and the organization header.** By default the
|
|
1224
1348
|
`x-revenium-organization-name` header (and the retired `x-revenium-organization-id`)
|
|
1225
1349
|
wins over the calling virtual key's team alias, for the budget check and the record
|
|
@@ -1805,6 +1929,8 @@ characters, and `product_name` at 224. Other text fields are sent as given.
|
|
|
1805
1929
|
| `response_quality_score` | Custom quality rating (0.0-1.0) | Track user satisfaction or automated quality metrics for model performance analysis |
|
|
1806
1930
|
| `effort` | Reasoning effort level requested of the model (free-form string, max 16 chars, `^[A-Za-z0-9_-]+$`) | Report what share of AI spend is high-effort reasoning, and compare cost per effort level |
|
|
1807
1931
|
| `entrypoint` | How the coding assistant that made the call was launched, such as `cli`, `sdk-py` or `claude-vscode` (completions only, 1 to 64 chars, `^[A-Za-z0-9._-]+$`) | Split coding-assistant spend between the terminal, the SDKs and the editor or chat integrations |
|
|
1932
|
+
| `ccr_session_id` | The Claude Code cloud session the call ran in; `ccrSessionId` also accepted (completions only, 1 to 128 chars, `^[A-Za-z0-9_-]+$`) | Group the spend of one Claude Code cloud session |
|
|
1933
|
+
| `inference_geo` | Where the provider reports the inference ran, such as `us`; `inferenceGeo` also accepted (completions only, 1 to 16 chars, `^[A-Za-z0-9_-]+$`) | Passed to Revenium with the call; it is not stored as a dimension to group spend by |
|
|
1808
1934
|
|
|
1809
1935
|
**Example:**
|
|
1810
1936
|
|
|
@@ -1856,6 +1982,18 @@ underscores is left off the record with a WARNING, and the call is still
|
|
|
1856
1982
|
recorded. It is sent on completions only; image, video and audio calls ignore
|
|
1857
1983
|
it, and the LiteLLM proxy does not read it.
|
|
1858
1984
|
|
|
1985
|
+
**Claude Code cloud session and inference geography:** `ccr_session_id` records
|
|
1986
|
+
the Claude Code cloud session a completion ran in, and `inference_geo` records
|
|
1987
|
+
where the provider says the inference ran. Both are values you supply per call;
|
|
1988
|
+
the SDK does not read them from the environment or from the provider response.
|
|
1989
|
+
`inference_geo` is sent exactly as given, with no lowercasing or allow-list;
|
|
1990
|
+
the backend normalizes it. It is not stored as a dimension to group spend by,
|
|
1991
|
+
so it cannot break spend down by geography. A value that is empty, too long (128 characters
|
|
1992
|
+
for `ccr_session_id`, 16 for `inference_geo`) or holds anything but letters,
|
|
1993
|
+
digits, hyphens and underscores is left off the record with a WARNING, and the
|
|
1994
|
+
call is still recorded. Both are sent on completions only; image, video and
|
|
1995
|
+
audio calls ignore them, and the LiteLLM proxy does not read them.
|
|
1996
|
+
|
|
1859
1997
|
**Deprecation notice:** The legacy field aliases `organizationId`, `organization_id`, `productId`, and `product_id` are accepted by this SDK only as an input-layer convenience and emit a `DeprecationWarning`. The Revenium backend no longer accepts them — they are translated to `organizationName` / `productName` before the wire call. Migrate to `organization_name` / `organizationName` and `product_name` / `productName` now; the input-layer aliases will be removed in the next major release.
|
|
1860
1998
|
|
|
1861
1999
|
**API Reference:** [Complete metadata field documentation](https://revenium.readme.io/reference/meter_ai_completion)
|
|
@@ -2229,7 +2367,7 @@ Block outbound provider requests client-side when a Revenium cost control trips.
|
|
|
2229
2367
|
|
|
2230
2368
|
> **Terminology note:** The customer-facing entity is called a **cost control**, served by the backend at `/v2/api/ai/cost-controls`. This SDK polls a separate compiled-rules feed at `/v2/api/ai/enforcement-rules/{teamId}` and is unaffected by changes to the CRUD path — no SDK upgrade is required.
|
|
2231
2369
|
|
|
2232
|
-
Every provider middleware checks the cap: OpenAI, Azure OpenAI, Anthropic (including Claude on Bedrock and
|
|
2370
|
+
Every provider middleware checks the cap: OpenAI, Azure OpenAI, Anthropic (including Claude on Bedrock, Foundry and Google Cloud), Google Gemini and Vertex AI, Ollama, Perplexity, fal, the LiteLLM client and proxy, and the LangChain callback.
|
|
2233
2371
|
|
|
2234
2372
|
### Enable
|
|
2235
2373
|
|
|
@@ -2272,7 +2410,7 @@ client = openai.OpenAI()
|
|
|
2272
2410
|
The pre-call check fires before every call these middlewares meter, including streamed, raw-response, beta and async variants and calls selective metering leaves unmetered:
|
|
2273
2411
|
|
|
2274
2412
|
- OpenAI and Azure OpenAI: chat completions, responses, embeddings and audio.
|
|
2275
|
-
- Anthropic, including Claude on Bedrock (`AnthropicBedrock`, and raw boto3 calls with `REVENIUM_BEDROCK_TRANSPORT=1`), Claude on Vertex AI (`AnthropicVertex`) and
|
|
2413
|
+
- Anthropic, including Claude on Bedrock (`AnthropicBedrock`, and raw boto3 calls with `REVENIUM_BEDROCK_TRANSPORT=1`), Claude on Vertex AI (`AnthropicVertex`), Foundry and Google Cloud (`AnthropicGoogleCloud`): `messages.create`, `stream` and `parse`, and their beta twins.
|
|
2276
2414
|
- Google: google-genai content, embeddings, Imagen and Veo, and Vertex AI generation, chat, embeddings and Imagen.
|
|
2277
2415
|
- Ollama: chat, generate, embed and embeddings.
|
|
2278
2416
|
- Perplexity: the native client and the OpenAI-compatible client.
|
|
@@ -2651,7 +2789,7 @@ timeout raises `ValueError`.
|
|
|
2651
2789
|
| `REVENIUM_WRITE_API_KEY` | - | Primary write-scope key (`rev_sk_`) for the agentic outcomes API (report/amend/history); falls back to `REVENIUM_OUTCOME_API_KEY` (deprecated), then `REVENIUM_METERING_API_KEY` |
|
|
2652
2790
|
| `REVENIUM_OUTCOME_API_KEY` | - | Deprecated fallback name for the write-scope key; used only when `REVENIUM_WRITE_API_KEY` is unset |
|
|
2653
2791
|
| `REVENIUM_PROFITSTREAM_BASE_URL` | same address as `REVENIUM_METERING_BASE_URL` | Agentic outcomes API base URL. Only needed when outcomes live at a different address than usage. By default it follows the `REVENIUM_METERING_BASE_URL` environment variable: a trailing `/meter` is removed and a path prefix is kept. `AgenticOutcomeClient` also follows a usage address set in code with `initialize_metering(base_url=...)` or a `metering_key(..., base_url=...)` block, for its jobs and outcomes as for its usage records, unless this variable or `profitstream_base_url=` sets an outcome address, or `meter_base_url=` names an address other than the one in `REVENIUM_METERING_BASE_URL`. |
|
|
2654
|
-
| `REVENIUM_BEDROCK_DISABLE` | - | Set to `1` to stop Anthropic clients being detected as Bedrock; Foundry detection
|
|
2792
|
+
| `REVENIUM_BEDROCK_DISABLE` | - | Set to `1` to stop Anthropic clients being detected as Bedrock; Foundry and Google Cloud detection are unaffected. Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT`, and LangChain's `ChatBedrock` and `ChatBedrockConverse`, are recorded as Bedrock |
|
|
2655
2793
|
| `REVENIUM_BEDROCK_TRANSPORT` | - | Set to `1` or `true` to meter Claude models called through a raw `boto3.client("bedrock-runtime")` (`invoke_model`, `invoke_model_with_response_stream`, `converse`, `converse_stream`); other Bedrock models are never metered this way |
|
|
2656
2794
|
| `REVENIUM_BUFFER_MAX_SIZE` | `20000` | Store-and-forward buffer capacity (oldest events evicted when full) |
|
|
2657
2795
|
| `REVENIUM_BUFFER_FLUSH_INTERVAL` | `30` | Seconds between automatic replay attempts for buffered events |
|
|
@@ -2706,7 +2844,7 @@ Per-call `usage_metadata` values take precedence over the `REVENIUM_AGENTIC_JOB_
|
|
|
2706
2844
|
|
|
2707
2845
|
**Debug mode:** Set `REVENIUM_LOG_LEVEL=DEBUG` (or `REVENIUM_DEBUG=true`, which is the same for every integration) to see detailed provider detection, routing decisions, and metering payloads, with credentials, emails and prompt or reply text redacted. Token counts, ids, model names and attribution names still print.
|
|
2708
2846
|
|
|
2709
|
-
**Stop Bedrock detection on Anthropic clients:** Set `REVENIUM_BEDROCK_DISABLE=1` to disable Bedrock auto-detection on Anthropic clients. It does not send your calls to Anthropic directly: an `AnthropicBedrock` call still goes to AWS and is billed by AWS, but is recorded as provider `anthropic` at the Anthropic price. Foundry detection
|
|
2847
|
+
**Stop Bedrock detection on Anthropic clients:** Set `REVENIUM_BEDROCK_DISABLE=1` to disable Bedrock auto-detection on Anthropic clients. It does not send your calls to Anthropic directly: an `AnthropicBedrock` call still goes to AWS and is billed by AWS, but is recorded as provider `anthropic` at the Anthropic price. Foundry and Google Cloud detection are unaffected - a Foundry client is still labelled `Foundry` and a Google Cloud client `Google`. Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT` and LangChain's `ChatBedrock` and `ChatBedrockConverse` are recorded as Bedrock.
|
|
2710
2848
|
|
|
2711
2849
|
**Check initialization status (Anthropic):** Use `revenium_middleware.anthropic.is_initialized()` to verify setup.
|
|
2712
2850
|
|
|
@@ -28,8 +28,10 @@ The official Revenium Python SDK — unified AI metering middleware for deeply a
|
|
|
28
28
|
| OpenAI | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
29
29
|
| Azure OpenAI | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
30
30
|
| xAI (Grok, via OpenAI SDK) | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
31
|
+
| OpenRouter (via OpenAI SDK) | `openai` | `pip install revenium-python-sdk[openai]` |
|
|
31
32
|
| Anthropic | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
32
33
|
| AWS Bedrock (Anthropic) | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
34
|
+
| Google Cloud (Anthropic managed) | `anthropic` | `pip install revenium-python-sdk[anthropic]` |
|
|
33
35
|
| Google Gemini | `google-genai` | `pip install revenium-python-sdk[google-genai]` |
|
|
34
36
|
| Google Vertex AI | `google-vertex` | `pip install revenium-python-sdk[google-vertex]` |
|
|
35
37
|
| Ollama | `ollama` | `pip install revenium-python-sdk[ollama]` |
|
|
@@ -671,6 +673,26 @@ response = client.chat.completions.create(
|
|
|
671
673
|
)
|
|
672
674
|
```
|
|
673
675
|
|
|
676
|
+
#### OpenRouter
|
|
677
|
+
|
|
678
|
+
Point the OpenAI client at OpenRouter and calls are recorded with provider and model source `OPENROUTER`, so OpenRouter spend is reported as OpenRouter rather than OpenAI and a spending cap scoped to OpenRouter applies to it. This covers chat, Responses and embeddings calls, sync and async, streamed or not, on any base URL whose host is `openrouter.ai` or one of its subdomains; a proxy or gateway on your own domain is recorded as the OpenAI-compatible call it appears to be.
|
|
679
|
+
|
|
680
|
+
```python
|
|
681
|
+
import os
|
|
682
|
+
from openai import OpenAI
|
|
683
|
+
import revenium_middleware.openai
|
|
684
|
+
|
|
685
|
+
client = OpenAI(
|
|
686
|
+
api_key=os.getenv("OPENROUTER_API_KEY"),
|
|
687
|
+
base_url="https://openrouter.ai/api/v1"
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
response = client.chat.completions.create(
|
|
691
|
+
model="openai/gpt-4o-mini",
|
|
692
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
693
|
+
)
|
|
694
|
+
```
|
|
695
|
+
|
|
674
696
|
---
|
|
675
697
|
|
|
676
698
|
### Anthropic
|
|
@@ -760,7 +782,7 @@ message = client.messages.create(
|
|
|
760
782
|
|
|
761
783
|
**Provider detection** automatically routes between Bedrock and direct Anthropic API based on:
|
|
762
784
|
- AWS credentials availability (`aws configure`, IAM roles, environment variables)
|
|
763
|
-
- Base URL detection (when `base_url` contains `amazonaws.com`)
|
|
785
|
+
- Base URL detection (when `base_url` contains `amazonaws.com`). The Anthropic SDK's Foundry and Google Cloud clients are labelled by their class first, so one behind an AWS-hosted gateway stays `Foundry` or `Google`
|
|
764
786
|
- Defaults to direct Anthropic API - Bedrock only used when explicitly configured
|
|
765
787
|
|
|
766
788
|
**Bedrock environment variables:**
|
|
@@ -768,7 +790,7 @@ message = client.messages.create(
|
|
|
768
790
|
| Variable | Description | Default |
|
|
769
791
|
|----------|-------------|---------|
|
|
770
792
|
| `AWS_REGION` | AWS region for Bedrock | `us-east-1` |
|
|
771
|
-
| `REVENIUM_BEDROCK_DISABLE` | Set to `1` to disable Bedrock support for Anthropic clients (Bedrock detection only - Foundry detection
|
|
793
|
+
| `REVENIUM_BEDROCK_DISABLE` | Set to `1` to disable Bedrock support for Anthropic clients (Bedrock detection only - Foundry and Google Cloud detection are unaffected). Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT`, and LangChain's `ChatBedrock` and `ChatBedrockConverse`, are recorded as Bedrock | Not set |
|
|
772
794
|
| `REVENIUM_BEDROCK_TRANSPORT` | Set to `1` or `true` to meter Claude models called through a raw `boto3.client("bedrock-runtime")` (`invoke_model`, `invoke_model_with_response_stream`, `converse`, `converse_stream`); other Bedrock models are never metered this way | Not set |
|
|
773
795
|
|
|
774
796
|
**AWS authentication**: an `AnthropicBedrock` client uses its own `aws_access_key` / `aws_secret_key` / `aws_session_token`, `aws_profile` or Bedrock `api_key`, exactly as without the middleware. A plain `anthropic.Anthropic` client with a Bedrock `base_url` uses the standard credential chain: environment variables, `~/.aws/credentials`, IAM roles, AWS SSO. Required permissions: `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream`.
|
|
@@ -793,6 +815,8 @@ message = client.messages.create(
|
|
|
793
815
|
|
|
794
816
|
For other models, the middleware uses the format `anthropic.{model_name}`.
|
|
795
817
|
|
|
818
|
+
Bedrock usage is reported with provider `Bedrock` and model source `ANTHROPIC` (or the model's vendor for LangChain `ChatBedrock`), and caps on `AWS` still match.
|
|
819
|
+
|
|
796
820
|
#### Microsoft Foundry
|
|
797
821
|
|
|
798
822
|
Claude served through Microsoft Foundry is metered by the same patched endpoints as the
|
|
@@ -819,6 +843,36 @@ is separated from direct-Anthropic totals while still priced against the Anthrop
|
|
|
819
843
|
that Foundry bills at. `AsyncAnthropicFoundry` is metered the same way, as is
|
|
820
844
|
`client.messages.stream()`.
|
|
821
845
|
|
|
846
|
+
#### Google Cloud (Anthropic managed)
|
|
847
|
+
|
|
848
|
+
Claude reached through your Google Cloud project with the Anthropic SDK's Google Cloud
|
|
849
|
+
client (anthropic 2.4.0 or later) is metered by the same patched endpoints, with no extra setup.
|
|
850
|
+
|
|
851
|
+
```python
|
|
852
|
+
import anthropic
|
|
853
|
+
import revenium_middleware.anthropic
|
|
854
|
+
|
|
855
|
+
# Detected from the client class, so a custom base_url is fine too
|
|
856
|
+
client = anthropic.AnthropicGoogleCloud(
|
|
857
|
+
project="your-project",
|
|
858
|
+
location="global",
|
|
859
|
+
workspace_id="your-workspace-id",
|
|
860
|
+
)
|
|
861
|
+
|
|
862
|
+
message = client.messages.create(
|
|
863
|
+
model="claude-opus-4-7",
|
|
864
|
+
max_tokens=100,
|
|
865
|
+
messages=[{"role": "user", "content": "Hello from Google Cloud!"}]
|
|
866
|
+
)
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
Google Cloud usage is reported with provider `Google` and model source `ANTHROPIC`, the
|
|
870
|
+
values the Node SDK sends for Google-billed Claude, because Google Cloud Marketplace bills
|
|
871
|
+
these calls. `AsyncAnthropicGoogleCloud` is metered the same way, as is
|
|
872
|
+
`client.messages.stream()`. A spending cap scoped to the `Google` provider counts these
|
|
873
|
+
calls; one scoped to `ANTHROPIC` does not. Claude through the older `AnthropicVertex`
|
|
874
|
+
client is still reported with provider `ANTHROPIC`.
|
|
875
|
+
|
|
822
876
|
**Examples:** `examples/anthropic/` - `anthropic-basic.py`, `anthropic-streaming.py`, `anthropic-bedrock.py`, `anthropic-advanced.py`
|
|
823
877
|
|
|
824
878
|
---
|
|
@@ -1081,6 +1135,24 @@ the others to be recorded. A malformed header value, such as a quality score of
|
|
|
1081
1135
|
`high` or an effort of `very high`, is left off the record with a WARNING in the
|
|
1082
1136
|
gateway log; the call is still recorded.
|
|
1083
1137
|
|
|
1138
|
+
**LiteLLM identities.** Below those sources, the guardrail also reads what
|
|
1139
|
+
LiteLLM itself resolved for the call:
|
|
1140
|
+
|
|
1141
|
+
| Revenium field | LiteLLM source | Used when |
|
|
1142
|
+
|---|---|---|
|
|
1143
|
+
| `subscriber.id` | The end user: the request's `user`, or the header named by LiteLLM's `user_header_name` | Nothing else named a subscriber id or email. A key with an owner keeps attributing to the owner, and the end user is never paired with the owner's email. |
|
|
1144
|
+
| `organizationName` | The alias of the LiteLLM organization the key belongs to | No header, team alias or `revenium_organization_name` key metadata named one |
|
|
1145
|
+
| `productName` | The alias of the LiteLLM project the key belongs to | No `x-revenium-product-name` header or `product_name:` tag |
|
|
1146
|
+
|
|
1147
|
+
LiteLLM organizations and projects need a LiteLLM enterprise license; without
|
|
1148
|
+
one these fallbacks never apply. Every record also carries `reasoningTokenCount`
|
|
1149
|
+
from LiteLLM's normalized usage (it is already inside the output count, which is
|
|
1150
|
+
unchanged) and `modelHost`, the LiteLLM provider that served the call (`openai`,
|
|
1151
|
+
`azure`, `bedrock`, ...; LiteLLM's `vertex_ai` is sent as `vertex` and `azure_ai` as
|
|
1152
|
+
`foundry`, the names coding-assistant records use). `provider` stays `LITELLM`, so
|
|
1153
|
+
provider-scoped spending caps and existing breakdowns are unaffected. The
|
|
1154
|
+
deprecated callback reads none of these.
|
|
1155
|
+
|
|
1084
1156
|
**Trace id.** The guardrail takes a record's trace id from `x-revenium-trace-id`.
|
|
1085
1157
|
Without that header it takes the LiteLLM session id the caller sent: the
|
|
1086
1158
|
`x-litellm-session-id` or `x-litellm-trace-id` header, or `litellm_session_id` or
|
|
@@ -1104,6 +1176,58 @@ never named after its LiteLLM session. A name over 256 characters is cut to 256.
|
|
|
1104
1176
|
with no LiteLLM session and no name has no trace name. The deprecated callback
|
|
1105
1177
|
reads only the header and `REVENIUM_TRACE_NAME`.
|
|
1106
1178
|
|
|
1179
|
+
**Attribution from LiteLLM tags.** Six fields can also come from LiteLLM's own tags,
|
|
1180
|
+
so a gateway caller needs no Revenium header to set them. A tag `<field>:<value>`
|
|
1181
|
+
fills the field when its `x-revenium-*` header is absent or blank:
|
|
1182
|
+
|
|
1183
|
+
| Tag | Fills | Instead of |
|
|
1184
|
+
|-----|-------|------------|
|
|
1185
|
+
| `trace_type:<value>` | trace type | `x-revenium-trace-type` |
|
|
1186
|
+
| `task_type:<value>` | task type | `x-revenium-task-type` |
|
|
1187
|
+
| `agent:<value>` | agent | `x-revenium-agent` |
|
|
1188
|
+
| `product_name:<value>` | product name | `x-revenium-product-name` |
|
|
1189
|
+
| `environment:<value>` | environment | `x-revenium-environment` |
|
|
1190
|
+
| `transaction_name:<value>` | transaction name | `x-revenium-transaction-name` |
|
|
1191
|
+
|
|
1192
|
+
The guardrail reads the tags LiteLLM has merged by the time it runs: the caller's
|
|
1193
|
+
(body `metadata.tags` or root `tags`, or the `x-litellm-tags` header) and those of
|
|
1194
|
+
the calling virtual key, team and project. For each field the header wins, then the
|
|
1195
|
+
caller's tag, then a key, team or project tag, then the gateway setting such as
|
|
1196
|
+
`REVENIUM_TRACE_TYPE`. Two different values at one level are ignored and the next
|
|
1197
|
+
level decides; a WARNING names the field once per request. Values are validated as
|
|
1198
|
+
the header's are. A key or team tag is a per-customer default; a request tag
|
|
1199
|
+
describes one call:
|
|
1200
|
+
|
|
1201
|
+
```python
|
|
1202
|
+
client.chat.completions.create(
|
|
1203
|
+
model="gpt-4o-mini",
|
|
1204
|
+
messages=[...],
|
|
1205
|
+
extra_body={"metadata": {"tags": ["trace_type:research-brief", "agent:research-planner"]}},
|
|
1206
|
+
)
|
|
1207
|
+
```
|
|
1208
|
+
|
|
1209
|
+
A tag carries the same weight as its header. Agent, task type and product also
|
|
1210
|
+
decide which spending caps apply, so a `product_name:`, `agent:` or `task_type:` tag
|
|
1211
|
+
can move a call into or out of a cap filtered on that field, and a caller's request
|
|
1212
|
+
tag overrides a key's or team's. On upgrade, a key or team that already carries tags
|
|
1213
|
+
of this form starts setting these fields, for the record and the cap check alike;
|
|
1214
|
+
review existing tags before upgrading if you filter caps on agent, task type or
|
|
1215
|
+
product.
|
|
1216
|
+
|
|
1217
|
+
Tags reach the pre-call cap check only when the guardrail writes the record itself
|
|
1218
|
+
(`default_on: true` with `post_call` in its mode), so a call is never checked under a
|
|
1219
|
+
value its record lacks. The deprecated callback reads headers only.
|
|
1220
|
+
|
|
1221
|
+
LiteLLM records which tags the request itself sent (`caller_tags`), so a caller's tag
|
|
1222
|
+
stays the caller's even when the key or team carries the same string. Body
|
|
1223
|
+
`metadata.tags` on `/chat/completions` is the exception: LiteLLM leaves it out of
|
|
1224
|
+
that record, so there a tag that is also a key or team tag counts as the key's or
|
|
1225
|
+
team's.
|
|
1226
|
+
|
|
1227
|
+
Tags never set the organization, subscriber, subscription, agentic job or trace id:
|
|
1228
|
+
those are billing identity and trace grouping, and keep coming from headers and the
|
|
1229
|
+
virtual key.
|
|
1230
|
+
|
|
1107
1231
|
**Organization caps and the organization header.** By default the
|
|
1108
1232
|
`x-revenium-organization-name` header (and the retired `x-revenium-organization-id`)
|
|
1109
1233
|
wins over the calling virtual key's team alias, for the budget check and the record
|
|
@@ -1689,6 +1813,8 @@ characters, and `product_name` at 224. Other text fields are sent as given.
|
|
|
1689
1813
|
| `response_quality_score` | Custom quality rating (0.0-1.0) | Track user satisfaction or automated quality metrics for model performance analysis |
|
|
1690
1814
|
| `effort` | Reasoning effort level requested of the model (free-form string, max 16 chars, `^[A-Za-z0-9_-]+$`) | Report what share of AI spend is high-effort reasoning, and compare cost per effort level |
|
|
1691
1815
|
| `entrypoint` | How the coding assistant that made the call was launched, such as `cli`, `sdk-py` or `claude-vscode` (completions only, 1 to 64 chars, `^[A-Za-z0-9._-]+$`) | Split coding-assistant spend between the terminal, the SDKs and the editor or chat integrations |
|
|
1816
|
+
| `ccr_session_id` | The Claude Code cloud session the call ran in; `ccrSessionId` also accepted (completions only, 1 to 128 chars, `^[A-Za-z0-9_-]+$`) | Group the spend of one Claude Code cloud session |
|
|
1817
|
+
| `inference_geo` | Where the provider reports the inference ran, such as `us`; `inferenceGeo` also accepted (completions only, 1 to 16 chars, `^[A-Za-z0-9_-]+$`) | Passed to Revenium with the call; it is not stored as a dimension to group spend by |
|
|
1692
1818
|
|
|
1693
1819
|
**Example:**
|
|
1694
1820
|
|
|
@@ -1740,6 +1866,18 @@ underscores is left off the record with a WARNING, and the call is still
|
|
|
1740
1866
|
recorded. It is sent on completions only; image, video and audio calls ignore
|
|
1741
1867
|
it, and the LiteLLM proxy does not read it.
|
|
1742
1868
|
|
|
1869
|
+
**Claude Code cloud session and inference geography:** `ccr_session_id` records
|
|
1870
|
+
the Claude Code cloud session a completion ran in, and `inference_geo` records
|
|
1871
|
+
where the provider says the inference ran. Both are values you supply per call;
|
|
1872
|
+
the SDK does not read them from the environment or from the provider response.
|
|
1873
|
+
`inference_geo` is sent exactly as given, with no lowercasing or allow-list;
|
|
1874
|
+
the backend normalizes it. It is not stored as a dimension to group spend by,
|
|
1875
|
+
so it cannot break spend down by geography. A value that is empty, too long (128 characters
|
|
1876
|
+
for `ccr_session_id`, 16 for `inference_geo`) or holds anything but letters,
|
|
1877
|
+
digits, hyphens and underscores is left off the record with a WARNING, and the
|
|
1878
|
+
call is still recorded. Both are sent on completions only; image, video and
|
|
1879
|
+
audio calls ignore them, and the LiteLLM proxy does not read them.
|
|
1880
|
+
|
|
1743
1881
|
**Deprecation notice:** The legacy field aliases `organizationId`, `organization_id`, `productId`, and `product_id` are accepted by this SDK only as an input-layer convenience and emit a `DeprecationWarning`. The Revenium backend no longer accepts them — they are translated to `organizationName` / `productName` before the wire call. Migrate to `organization_name` / `organizationName` and `product_name` / `productName` now; the input-layer aliases will be removed in the next major release.
|
|
1744
1882
|
|
|
1745
1883
|
**API Reference:** [Complete metadata field documentation](https://revenium.readme.io/reference/meter_ai_completion)
|
|
@@ -2113,7 +2251,7 @@ Block outbound provider requests client-side when a Revenium cost control trips.
|
|
|
2113
2251
|
|
|
2114
2252
|
> **Terminology note:** The customer-facing entity is called a **cost control**, served by the backend at `/v2/api/ai/cost-controls`. This SDK polls a separate compiled-rules feed at `/v2/api/ai/enforcement-rules/{teamId}` and is unaffected by changes to the CRUD path — no SDK upgrade is required.
|
|
2115
2253
|
|
|
2116
|
-
Every provider middleware checks the cap: OpenAI, Azure OpenAI, Anthropic (including Claude on Bedrock and
|
|
2254
|
+
Every provider middleware checks the cap: OpenAI, Azure OpenAI, Anthropic (including Claude on Bedrock, Foundry and Google Cloud), Google Gemini and Vertex AI, Ollama, Perplexity, fal, the LiteLLM client and proxy, and the LangChain callback.
|
|
2117
2255
|
|
|
2118
2256
|
### Enable
|
|
2119
2257
|
|
|
@@ -2156,7 +2294,7 @@ client = openai.OpenAI()
|
|
|
2156
2294
|
The pre-call check fires before every call these middlewares meter, including streamed, raw-response, beta and async variants and calls selective metering leaves unmetered:
|
|
2157
2295
|
|
|
2158
2296
|
- OpenAI and Azure OpenAI: chat completions, responses, embeddings and audio.
|
|
2159
|
-
- Anthropic, including Claude on Bedrock (`AnthropicBedrock`, and raw boto3 calls with `REVENIUM_BEDROCK_TRANSPORT=1`), Claude on Vertex AI (`AnthropicVertex`) and
|
|
2297
|
+
- Anthropic, including Claude on Bedrock (`AnthropicBedrock`, and raw boto3 calls with `REVENIUM_BEDROCK_TRANSPORT=1`), Claude on Vertex AI (`AnthropicVertex`), Foundry and Google Cloud (`AnthropicGoogleCloud`): `messages.create`, `stream` and `parse`, and their beta twins.
|
|
2160
2298
|
- Google: google-genai content, embeddings, Imagen and Veo, and Vertex AI generation, chat, embeddings and Imagen.
|
|
2161
2299
|
- Ollama: chat, generate, embed and embeddings.
|
|
2162
2300
|
- Perplexity: the native client and the OpenAI-compatible client.
|
|
@@ -2535,7 +2673,7 @@ timeout raises `ValueError`.
|
|
|
2535
2673
|
| `REVENIUM_WRITE_API_KEY` | - | Primary write-scope key (`rev_sk_`) for the agentic outcomes API (report/amend/history); falls back to `REVENIUM_OUTCOME_API_KEY` (deprecated), then `REVENIUM_METERING_API_KEY` |
|
|
2536
2674
|
| `REVENIUM_OUTCOME_API_KEY` | - | Deprecated fallback name for the write-scope key; used only when `REVENIUM_WRITE_API_KEY` is unset |
|
|
2537
2675
|
| `REVENIUM_PROFITSTREAM_BASE_URL` | same address as `REVENIUM_METERING_BASE_URL` | Agentic outcomes API base URL. Only needed when outcomes live at a different address than usage. By default it follows the `REVENIUM_METERING_BASE_URL` environment variable: a trailing `/meter` is removed and a path prefix is kept. `AgenticOutcomeClient` also follows a usage address set in code with `initialize_metering(base_url=...)` or a `metering_key(..., base_url=...)` block, for its jobs and outcomes as for its usage records, unless this variable or `profitstream_base_url=` sets an outcome address, or `meter_base_url=` names an address other than the one in `REVENIUM_METERING_BASE_URL`. |
|
|
2538
|
-
| `REVENIUM_BEDROCK_DISABLE` | - | Set to `1` to stop Anthropic clients being detected as Bedrock; Foundry detection
|
|
2676
|
+
| `REVENIUM_BEDROCK_DISABLE` | - | Set to `1` to stop Anthropic clients being detected as Bedrock; Foundry and Google Cloud detection are unaffected. Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT`, and LangChain's `ChatBedrock` and `ChatBedrockConverse`, are recorded as Bedrock |
|
|
2539
2677
|
| `REVENIUM_BEDROCK_TRANSPORT` | - | Set to `1` or `true` to meter Claude models called through a raw `boto3.client("bedrock-runtime")` (`invoke_model`, `invoke_model_with_response_stream`, `converse`, `converse_stream`); other Bedrock models are never metered this way |
|
|
2540
2678
|
| `REVENIUM_BUFFER_MAX_SIZE` | `20000` | Store-and-forward buffer capacity (oldest events evicted when full) |
|
|
2541
2679
|
| `REVENIUM_BUFFER_FLUSH_INTERVAL` | `30` | Seconds between automatic replay attempts for buffered events |
|
|
@@ -2590,7 +2728,7 @@ Per-call `usage_metadata` values take precedence over the `REVENIUM_AGENTIC_JOB_
|
|
|
2590
2728
|
|
|
2591
2729
|
**Debug mode:** Set `REVENIUM_LOG_LEVEL=DEBUG` (or `REVENIUM_DEBUG=true`, which is the same for every integration) to see detailed provider detection, routing decisions, and metering payloads, with credentials, emails and prompt or reply text redacted. Token counts, ids, model names and attribution names still print.
|
|
2592
2730
|
|
|
2593
|
-
**Stop Bedrock detection on Anthropic clients:** Set `REVENIUM_BEDROCK_DISABLE=1` to disable Bedrock auto-detection on Anthropic clients. It does not send your calls to Anthropic directly: an `AnthropicBedrock` call still goes to AWS and is billed by AWS, but is recorded as provider `anthropic` at the Anthropic price. Foundry detection
|
|
2731
|
+
**Stop Bedrock detection on Anthropic clients:** Set `REVENIUM_BEDROCK_DISABLE=1` to disable Bedrock auto-detection on Anthropic clients. It does not send your calls to Anthropic directly: an `AnthropicBedrock` call still goes to AWS and is billed by AWS, but is recorded as provider `anthropic` at the Anthropic price. Foundry and Google Cloud detection are unaffected - a Foundry client is still labelled `Foundry` and a Google Cloud client `Google`. Raw boto3 calls metered with `REVENIUM_BEDROCK_TRANSPORT` and LangChain's `ChatBedrock` and `ChatBedrockConverse` are recorded as Bedrock.
|
|
2594
2732
|
|
|
2595
2733
|
**Check initialization status (Anthropic):** Use `revenium_middleware.anthropic.is_initialized()` to verify setup.
|
|
2596
2734
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "revenium-python-sdk"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.14.0"
|
|
8
8
|
description = "The official Revenium Python SDK — unified AI metering middleware for OpenAI, Anthropic, Google, Ollama, LiteLLM, Perplexity, and fal.ai."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
{revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/cache_tokens.py
RENAMED
|
@@ -238,6 +238,15 @@ def _upstream_provider(sources) -> Optional[str]:
|
|
|
238
238
|
return None
|
|
239
239
|
|
|
240
240
|
|
|
241
|
+
def upstream_provider(*sources) -> Optional[str]:
|
|
242
|
+
"""The LiteLLM provider that served the call, lower-cased, or None.
|
|
243
|
+
|
|
244
|
+
``sources`` are LiteLLM-populated surfaces in lookup order, as for
|
|
245
|
+
``prompt_tokens_fold_cache``; the first that names a provider decides.
|
|
246
|
+
"""
|
|
247
|
+
return _upstream_provider(sources)
|
|
248
|
+
|
|
249
|
+
|
|
241
250
|
def _provider_folds_cache(provider: str, sources) -> bool:
|
|
242
251
|
if provider in _CACHE_FOLDING_PROVIDERS:
|
|
243
252
|
return True
|
{revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/enforcement.py
RENAMED
|
@@ -1817,15 +1817,21 @@ def _rule_blocks(
|
|
|
1817
1817
|
|
|
1818
1818
|
_FILTER_OPERATORS = frozenset({"IS", "IS_NOT", "CONTAINS", "STARTS_WITH", "ENDS_WITH", "IN"})
|
|
1819
1819
|
|
|
1820
|
-
# The
|
|
1821
|
-
#
|
|
1822
|
-
#
|
|
1820
|
+
# The provider values a call carrying the key label also counts toward. The
|
|
1821
|
+
# FOUNDRY and coding-assistant rows copy the server's
|
|
1822
|
+
# ProviderVocabulary.ALIAS_BUCKETS (hypercurrent commons) and alias one way
|
|
1823
|
+
# only, so a cap on FOUNDRY never covers direct Anthropic calls. The Bedrock
|
|
1824
|
+
# rows mirror the Bedrock bucket in that same server table (BACK-4461,
|
|
1825
|
+
# hypercurrent #7678): the Bedrock spellings name one provider, so each
|
|
1826
|
+
# counts toward all of them, both ways.
|
|
1827
|
+
_BEDROCK_SPELLINGS = frozenset({"BEDROCK", "AWS", "AMAZON BEDROCK", "AWS BEDROCK"})
|
|
1823
1828
|
_PROVIDER_ALIAS_BUCKETS = {
|
|
1824
1829
|
"FOUNDRY": frozenset({"FOUNDRY", "ANTHROPIC"}),
|
|
1825
1830
|
"CLAUDECODE": frozenset({"CLAUDECODE", "ANTHROPIC"}),
|
|
1826
1831
|
"CLAUDECOWORK": frozenset({"CLAUDECOWORK", "ANTHROPIC"}),
|
|
1827
1832
|
"CODEXCLI": frozenset({"CODEXCLI", "OPENAI"}),
|
|
1828
1833
|
"GEMINICLI": frozenset({"GEMINICLI", "GOOGLE"}),
|
|
1834
|
+
**dict.fromkeys(_BEDROCK_SPELLINGS, _BEDROCK_SPELLINGS),
|
|
1829
1835
|
}
|
|
1830
1836
|
|
|
1831
1837
|
# Dimensions whose value the SDK itself puts on the metering record, so a call
|
{revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/fields.py
RENAMED
|
@@ -122,6 +122,8 @@ EFFORT_FIELD_MAP = {
|
|
|
122
122
|
PROMPT_CONTEXT_FIELD_MAP = {
|
|
123
123
|
"client_surface": ("client_surface", "clientSurface"),
|
|
124
124
|
"entrypoint": ("entrypoint",),
|
|
125
|
+
"ccr_session_id": ("ccr_session_id", "ccrSessionId"),
|
|
126
|
+
"inference_geo": ("inference_geo", "inferenceGeo"),
|
|
125
127
|
"prompt_id": ("prompt_id", "promptId"),
|
|
126
128
|
"prompt_length": ("prompt_length", "promptLength"),
|
|
127
129
|
"query_source": ("query_source", "querySource"),
|
|
@@ -360,7 +362,7 @@ def extract_effort_field(source: Optional[Mapping[str, Any]]) -> Dict[str, Any]:
|
|
|
360
362
|
|
|
361
363
|
|
|
362
364
|
def extract_prompt_context_fields(source: Optional[Mapping[str, Any]]) -> Dict[str, Any]:
|
|
363
|
-
"""Resolve client-surface, entrypoint, prompt, speed-mode and subagent attribution
|
|
365
|
+
"""Resolve client-surface, entrypoint, cloud-session, inference-geo, prompt, speed-mode and subagent attribution.
|
|
364
366
|
|
|
365
367
|
Each field resolves from its snake_case key then its camelCase alias and is
|
|
366
368
|
returned under the snake_case keyword ``create_completion`` expects. Absent
|
{revenium_python_sdk-0.12.1 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/wire_guards.py
RENAMED
|
@@ -137,6 +137,8 @@ _RULES_BY_OPERATION: Dict[str, Dict[str, Callable[[Any], Any]]] = {
|
|
|
137
137
|
"subagent_type": _slug(_SOURCE_SLUG, 128, _SOURCE_CHARACTERS),
|
|
138
138
|
"client_surface": _slug(_SURFACE_SLUG, 64, _SURFACE_CHARACTERS),
|
|
139
139
|
"entrypoint": _slug(_SURFACE_SLUG, 64, _SURFACE_CHARACTERS),
|
|
140
|
+
"ccr_session_id": _slug(_SLUG, 128, _SLUG_CHARACTERS),
|
|
141
|
+
"inference_geo": _slug(_SLUG, 16, _SLUG_CHARACTERS),
|
|
140
142
|
"prompt_id": _slug(_SLUG, 64, _SLUG_CHARACTERS),
|
|
141
143
|
"prompt_length": _prompt_length,
|
|
142
144
|
"response_quality_score": _quality_score,
|