revenium-python-sdk 0.13.0__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.13.0 → revenium_python_sdk-0.14.0}/PKG-INFO +75 -7
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/README.md +74 -6
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/pyproject.toml +1 -1
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/enforcement.py +9 -3
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/fields.py +3 -1
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/wire_guards.py +2 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/ai.py +22 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_completion_params.py +12 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_transport.py +5 -3
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/middleware.py +2 -2
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/provider.py +100 -67
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/middleware.py +20 -4
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_model_call.py +2 -2
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/provider.py +12 -3
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/trace_fields.py +2 -2
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/PKG-INFO +75 -7
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/LICENSE +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/cache_tokens.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/call_context.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/call_ownership.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/closable_scope.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/context.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/decorators.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/delivery_circuit.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/error_text.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/exceptions.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/failed_calls.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/json_safe.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/langchain_settings.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/load_diagnostics.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/log_sanitize.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_buffer.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_pool.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_status.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/metering_submission.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/outcomes.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/package_versions.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/parse_failures.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/patch_registry.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/perplexity_cost.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/perplexity_usage_metadata.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/prompt_extraction.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/responses_status.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/secret_shapes.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/selective_metering.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/shutdown_signals.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/sse_body_tap.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/subscriber.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/tool_event_transport.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/usage_iterations.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_core/vendor_model_aliases.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/LICENSE +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_base_client.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_client.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_compat.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_constants.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_exceptions.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_files.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_models.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_qs.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_resource.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_response.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_streaming.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_types.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_logs.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_proxy.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_reflection.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_resources_proxy.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_streams.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_sync.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_transform.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_typing.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_utils/_utils.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/_version.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/context.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/decorator.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/py.typed +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/apis.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/resources/events.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_audio_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_image_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/ai_create_video_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/api_meter_request_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/api_meter_response_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/event_create_params.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/_metering/types/metering_response_resource.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/agentic_outcomes.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_adapter.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/bedrock_model_names.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/inference_profiles.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/raw_response.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/stream_create.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/anthropic/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_call.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_metering.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/_queue.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/fal/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/exceptions.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/protocols.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/types.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/common/utils.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/google_ai/provider.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/google/vertex_ai/provider.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/_metadata.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/_retry.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/anthropic_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/budget_errors.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/litellm_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/ollama_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/openai_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/openai_embedding_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/griptape/universal_driver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/job_context.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/job_history.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/job_type_economics.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/context.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/decorators.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/hooks.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/integrations/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/integrations/crewai.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/client/validation.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/_metering_owner.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/guardrail.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/litellm/proxy/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/ollama/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/audio.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/azure_config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/azure_model_resolver.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/config.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/exceptions.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_abandoned_runs.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_perplexity_cost_capture.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_prompt_capture.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_text_completion_usage.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/_utils.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/langchain/unified_handler.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/prompt_extractor.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/raw_response.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/openai/xai_usage.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/_metering_scope.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/middleware.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/patching.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/perplexity_sdk.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/provider.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/raw_response.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/streaming.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/perplexity/trace_fields.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/webhooks/__init__.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_middleware/webhooks/_verify.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/SOURCES.txt +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/dependency_links.txt +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/requires.txt +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/revenium_python_sdk.egg-info/top_level.txt +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/setup.cfg +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/tests/test_metering.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/tests/test_metering_dispatch_timestamps.py +0 -0
- {revenium_python_sdk-0.13.0 → revenium_python_sdk-0.14.0}/tests/test_patch_coverage.py +0 -0
- {revenium_python_sdk-0.13.0 → 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
|
---
|
|
@@ -1875,6 +1929,8 @@ characters, and `product_name` at 224. Other text fields are sent as given.
|
|
|
1875
1929
|
| `response_quality_score` | Custom quality rating (0.0-1.0) | Track user satisfaction or automated quality metrics for model performance analysis |
|
|
1876
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 |
|
|
1877
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 |
|
|
1878
1934
|
|
|
1879
1935
|
**Example:**
|
|
1880
1936
|
|
|
@@ -1926,6 +1982,18 @@ underscores is left off the record with a WARNING, and the call is still
|
|
|
1926
1982
|
recorded. It is sent on completions only; image, video and audio calls ignore
|
|
1927
1983
|
it, and the LiteLLM proxy does not read it.
|
|
1928
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
|
+
|
|
1929
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.
|
|
1930
1998
|
|
|
1931
1999
|
**API Reference:** [Complete metadata field documentation](https://revenium.readme.io/reference/meter_ai_completion)
|
|
@@ -2299,7 +2367,7 @@ Block outbound provider requests client-side when a Revenium cost control trips.
|
|
|
2299
2367
|
|
|
2300
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.
|
|
2301
2369
|
|
|
2302
|
-
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.
|
|
2303
2371
|
|
|
2304
2372
|
### Enable
|
|
2305
2373
|
|
|
@@ -2342,7 +2410,7 @@ client = openai.OpenAI()
|
|
|
2342
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:
|
|
2343
2411
|
|
|
2344
2412
|
- OpenAI and Azure OpenAI: chat completions, responses, embeddings and audio.
|
|
2345
|
-
- 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.
|
|
2346
2414
|
- Google: google-genai content, embeddings, Imagen and Veo, and Vertex AI generation, chat, embeddings and Imagen.
|
|
2347
2415
|
- Ollama: chat, generate, embed and embeddings.
|
|
2348
2416
|
- Perplexity: the native client and the OpenAI-compatible client.
|
|
@@ -2721,7 +2789,7 @@ timeout raises `ValueError`.
|
|
|
2721
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` |
|
|
2722
2790
|
| `REVENIUM_OUTCOME_API_KEY` | - | Deprecated fallback name for the write-scope key; used only when `REVENIUM_WRITE_API_KEY` is unset |
|
|
2723
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`. |
|
|
2724
|
-
| `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 |
|
|
2725
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 |
|
|
2726
2794
|
| `REVENIUM_BUFFER_MAX_SIZE` | `20000` | Store-and-forward buffer capacity (oldest events evicted when full) |
|
|
2727
2795
|
| `REVENIUM_BUFFER_FLUSH_INTERVAL` | `30` | Seconds between automatic replay attempts for buffered events |
|
|
@@ -2776,7 +2844,7 @@ Per-call `usage_metadata` values take precedence over the `REVENIUM_AGENTIC_JOB_
|
|
|
2776
2844
|
|
|
2777
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.
|
|
2778
2846
|
|
|
2779
|
-
**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.
|
|
2780
2848
|
|
|
2781
2849
|
**Check initialization status (Anthropic):** Use `revenium_middleware.anthropic.is_initialized()` to verify setup.
|
|
2782
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
|
---
|
|
@@ -1759,6 +1813,8 @@ characters, and `product_name` at 224. Other text fields are sent as given.
|
|
|
1759
1813
|
| `response_quality_score` | Custom quality rating (0.0-1.0) | Track user satisfaction or automated quality metrics for model performance analysis |
|
|
1760
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 |
|
|
1761
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 |
|
|
1762
1818
|
|
|
1763
1819
|
**Example:**
|
|
1764
1820
|
|
|
@@ -1810,6 +1866,18 @@ underscores is left off the record with a WARNING, and the call is still
|
|
|
1810
1866
|
recorded. It is sent on completions only; image, video and audio calls ignore
|
|
1811
1867
|
it, and the LiteLLM proxy does not read it.
|
|
1812
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
|
+
|
|
1813
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.
|
|
1814
1882
|
|
|
1815
1883
|
**API Reference:** [Complete metadata field documentation](https://revenium.readme.io/reference/meter_ai_completion)
|
|
@@ -2183,7 +2251,7 @@ Block outbound provider requests client-side when a Revenium cost control trips.
|
|
|
2183
2251
|
|
|
2184
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.
|
|
2185
2253
|
|
|
2186
|
-
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.
|
|
2187
2255
|
|
|
2188
2256
|
### Enable
|
|
2189
2257
|
|
|
@@ -2226,7 +2294,7 @@ client = openai.OpenAI()
|
|
|
2226
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:
|
|
2227
2295
|
|
|
2228
2296
|
- OpenAI and Azure OpenAI: chat completions, responses, embeddings and audio.
|
|
2229
|
-
- 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.
|
|
2230
2298
|
- Google: google-genai content, embeddings, Imagen and Veo, and Vertex AI generation, chat, embeddings and Imagen.
|
|
2231
2299
|
- Ollama: chat, generate, embed and embeddings.
|
|
2232
2300
|
- Perplexity: the native client and the OpenAI-compatible client.
|
|
@@ -2605,7 +2673,7 @@ timeout raises `ValueError`.
|
|
|
2605
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` |
|
|
2606
2674
|
| `REVENIUM_OUTCOME_API_KEY` | - | Deprecated fallback name for the write-scope key; used only when `REVENIUM_WRITE_API_KEY` is unset |
|
|
2607
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`. |
|
|
2608
|
-
| `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 |
|
|
2609
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 |
|
|
2610
2678
|
| `REVENIUM_BUFFER_MAX_SIZE` | `20000` | Store-and-forward buffer capacity (oldest events evicted when full) |
|
|
2611
2679
|
| `REVENIUM_BUFFER_FLUSH_INTERVAL` | `30` | Seconds between automatic replay attempts for buffered events |
|
|
@@ -2660,7 +2728,7 @@ Per-call `usage_metadata` values take precedence over the `REVENIUM_AGENTIC_JOB_
|
|
|
2660
2728
|
|
|
2661
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.
|
|
2662
2730
|
|
|
2663
|
-
**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.
|
|
2664
2732
|
|
|
2665
2733
|
**Check initialization status (Anthropic):** Use `revenium_middleware.anthropic.is_initialized()` to verify setup.
|
|
2666
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.13.0 → 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.13.0 → 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.13.0 → 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,
|
|
@@ -86,6 +86,8 @@ class AIResource(SyncAPIResource):
|
|
|
86
86
|
effort: str | NotGiven = NOT_GIVEN,
|
|
87
87
|
client_surface: str | NotGiven = NOT_GIVEN,
|
|
88
88
|
entrypoint: str | NotGiven = NOT_GIVEN,
|
|
89
|
+
ccr_session_id: str | NotGiven = NOT_GIVEN,
|
|
90
|
+
inference_geo: str | NotGiven = NOT_GIVEN,
|
|
89
91
|
prompt_id: str | NotGiven = NOT_GIVEN,
|
|
90
92
|
prompt_length: int | NotGiven = NOT_GIVEN,
|
|
91
93
|
query_source: str | NotGiven = NOT_GIVEN,
|
|
@@ -238,6 +240,13 @@ class AIResource(SyncAPIResource):
|
|
|
238
240
|
same shape are stored as sent (1 to 64 letters, digits, dots, hyphens or
|
|
239
241
|
underscores)
|
|
240
242
|
|
|
243
|
+
ccr_session_id: The Claude Code cloud session this call ran in, so its completions can be
|
|
244
|
+
grouped by session (1 to 128 letters, digits, hyphens or underscores)
|
|
245
|
+
|
|
246
|
+
inference_geo: Where the provider reports the inference ran, for example us; sent as
|
|
247
|
+
given, the backend normalizes it (1 to 16 letters, digits, hyphens or
|
|
248
|
+
underscores)
|
|
249
|
+
|
|
241
250
|
prompt_id: Identifier of the user prompt that produced this completion, so every call
|
|
242
251
|
made while serving one prompt can be grouped (max 64 chars)
|
|
243
252
|
|
|
@@ -417,6 +426,8 @@ class AIResource(SyncAPIResource):
|
|
|
417
426
|
"effort": effort,
|
|
418
427
|
"client_surface": client_surface,
|
|
419
428
|
"entrypoint": entrypoint,
|
|
429
|
+
"ccr_session_id": ccr_session_id,
|
|
430
|
+
"inference_geo": inference_geo,
|
|
420
431
|
"prompt_id": prompt_id,
|
|
421
432
|
"prompt_length": prompt_length,
|
|
422
433
|
"query_source": query_source,
|
|
@@ -1400,6 +1411,8 @@ class AsyncAIResource(AsyncAPIResource):
|
|
|
1400
1411
|
effort: str | NotGiven = NOT_GIVEN,
|
|
1401
1412
|
client_surface: str | NotGiven = NOT_GIVEN,
|
|
1402
1413
|
entrypoint: str | NotGiven = NOT_GIVEN,
|
|
1414
|
+
ccr_session_id: str | NotGiven = NOT_GIVEN,
|
|
1415
|
+
inference_geo: str | NotGiven = NOT_GIVEN,
|
|
1403
1416
|
prompt_id: str | NotGiven = NOT_GIVEN,
|
|
1404
1417
|
prompt_length: int | NotGiven = NOT_GIVEN,
|
|
1405
1418
|
query_source: str | NotGiven = NOT_GIVEN,
|
|
@@ -1552,6 +1565,13 @@ class AsyncAIResource(AsyncAPIResource):
|
|
|
1552
1565
|
same shape are stored as sent (1 to 64 letters, digits, dots, hyphens or
|
|
1553
1566
|
underscores)
|
|
1554
1567
|
|
|
1568
|
+
ccr_session_id: The Claude Code cloud session this call ran in, so its completions can be
|
|
1569
|
+
grouped by session (1 to 128 letters, digits, hyphens or underscores)
|
|
1570
|
+
|
|
1571
|
+
inference_geo: Where the provider reports the inference ran, for example us; sent as
|
|
1572
|
+
given, the backend normalizes it (1 to 16 letters, digits, hyphens or
|
|
1573
|
+
underscores)
|
|
1574
|
+
|
|
1555
1575
|
prompt_id: Identifier of the user prompt that produced this completion, so every call
|
|
1556
1576
|
made while serving one prompt can be grouped (max 64 chars)
|
|
1557
1577
|
|
|
@@ -1731,6 +1751,8 @@ class AsyncAIResource(AsyncAPIResource):
|
|
|
1731
1751
|
"effort": effort,
|
|
1732
1752
|
"client_surface": client_surface,
|
|
1733
1753
|
"entrypoint": entrypoint,
|
|
1754
|
+
"ccr_session_id": ccr_session_id,
|
|
1755
|
+
"inference_geo": inference_geo,
|
|
1734
1756
|
"prompt_id": prompt_id,
|
|
1735
1757
|
"prompt_length": prompt_length,
|
|
1736
1758
|
"query_source": query_source,
|
|
@@ -139,6 +139,18 @@ class AICreateCompletionParams(TypedDict, total=False):
|
|
|
139
139
|
^[A-Za-z0-9._-]{1,64}$.
|
|
140
140
|
"""
|
|
141
141
|
|
|
142
|
+
ccr_session_id: Annotated[str, PropertyInfo(alias="ccrSessionId")]
|
|
143
|
+
"""The Claude Code cloud session this call ran in (max 128 chars).
|
|
144
|
+
|
|
145
|
+
Must match ^[A-Za-z0-9_-]{1,128}$.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
inference_geo: Annotated[str, PropertyInfo(alias="inferenceGeo")]
|
|
149
|
+
"""Where the provider reports the inference ran, for example us (max 16 chars).
|
|
150
|
+
|
|
151
|
+
Sent as given; the backend normalizes it. Must match ^[A-Za-z0-9_-]{1,16}$.
|
|
152
|
+
"""
|
|
153
|
+
|
|
142
154
|
prompt_id: Annotated[str, PropertyInfo(alias="promptId")]
|
|
143
155
|
"""Identifier of the user prompt that produced this completion (max 64 chars)"""
|
|
144
156
|
|
|
@@ -56,6 +56,8 @@ _STREAMING_OPERATIONS = frozenset({
|
|
|
56
56
|
"ConverseStream",
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
+
_PROVIDER_LABEL = "Bedrock"
|
|
60
|
+
|
|
59
61
|
# Marks botocore calls issued by Revenium's own Bedrock adapter so the
|
|
60
62
|
# transport layer sees but does not meter them (the adapter's wrapper is the
|
|
61
63
|
# sole emitter for that path). Context-local, so it is safe across threads
|
|
@@ -220,7 +222,7 @@ def _emit_completion(
|
|
|
220
222
|
"cost_type": "AI",
|
|
221
223
|
"model": model_id,
|
|
222
224
|
"input_token_count": input_tokens,
|
|
223
|
-
"provider":
|
|
225
|
+
"provider": _PROVIDER_LABEL,
|
|
224
226
|
"model_source": "ANTHROPIC",
|
|
225
227
|
"reasoning_token_count": 0,
|
|
226
228
|
"request_time": request_time,
|
|
@@ -641,12 +643,12 @@ def _make_api_call_wrapper(wrapped, instance, args, kwargs):
|
|
|
641
643
|
requested_model_id = args[1].get("modelId") if len(args) > 1 else None
|
|
642
644
|
if selectively_unmetered():
|
|
643
645
|
check_unmetered_call(_ambient_usage_metadata(), model=cap_model_names(model_id, requested_model_id),
|
|
644
|
-
provider=
|
|
646
|
+
provider=_PROVIDER_LABEL, callback_transport=BEDROCK)
|
|
645
647
|
return wrapped(*args, **kwargs)
|
|
646
648
|
|
|
647
649
|
request_time_dt = datetime.datetime.now(datetime.timezone.utc)
|
|
648
650
|
usage_metadata = _call_usage_metadata()
|
|
649
|
-
check_enforcement(usage_metadata, model=cap_model_names(model_id, requested_model_id), provider=
|
|
651
|
+
check_enforcement(usage_metadata, model=cap_model_names(model_id, requested_model_id), provider=_PROVIDER_LABEL)
|
|
650
652
|
metering_client = current_client()
|
|
651
653
|
response = wrapped(*args, **kwargs) # exceptions/retries pass through untouched
|
|
652
654
|
|
|
@@ -1628,7 +1628,7 @@ def async_stream_wrapper(wrapped, instance, args, kwargs):
|
|
|
1628
1628
|
# Attribution only, no re-routing -- the same choice AsyncMessages.create
|
|
1629
1629
|
# makes. The sync wrapper's Bedrock fast path is a blocking boto3 call
|
|
1630
1630
|
# and cannot serve an async context manager, so an AsyncAnthropicBedrock
|
|
1631
|
-
# stream stays on the SDK transport and is metered here under the
|
|
1631
|
+
# stream stays on the SDK transport and is metered here under the Bedrock
|
|
1632
1632
|
# label rather than being handed to the Bedrock adapter.
|
|
1633
1633
|
# REVENIUM_BEDROCK_DISABLE is honoured inside detect_provider, so a
|
|
1634
1634
|
# Foundry stream keeps its Foundry label when Bedrock routing is off.
|
|
@@ -1659,7 +1659,7 @@ wrap_once("anthropic.resources.messages.messages.AsyncMessages.stream",
|
|
|
1659
1659
|
|
|
1660
1660
|
# The Bedrock fast path rebuilds the request from a handful of standard fields
|
|
1661
1661
|
# and returns a plain Message, so it would drop the beta flags and the parse()
|
|
1662
|
-
# output format. These surfaces stay on the SDK transport and keep the
|
|
1662
|
+
# output format. These surfaces stay on the SDK transport and keep the Bedrock label.
|
|
1663
1663
|
def _parse_wrapper(wrapped, instance, args, kwargs):
|
|
1664
1664
|
return create_wrapper(wrapped, instance, args, kwargs, bedrock_fast_path=False)
|
|
1665
1665
|
|