From 6ff668c7aa01a73738ed39aa64913a089a183565 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 5 May 2026 16:15:03 -0700 Subject: [PATCH 1/2] [Infra] Promote internal staging to main (#27245) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * default requested_model to empty string on litellm-side rejects * Update litellm/router.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix: scope key access_group_ids override by team's assigned groups A team member could set any access_group_ids on their key (e.g. a group assigned only to a different team) and override the team's model restriction. Intersect the key's access_group_ids with team_object.access_group_ids in _key_access_group_grants_model so foreign groups are dropped before model expansion. Adds a regression test that asserts expansion is never called for foreign groups. * [Fix] Proxy: Skip Personal Budget Hook When Reservation Covers Counter The reservation path (PR #26845) atomically pre-fills `spend:user:{user_id}` and admits at the strict-`<` boundary. The legacy `_PROXY_MaxBudgetLimiter` pre-call hook re-reads the same counter with `>=`, so a reservation that fills the counter to exactly `max_budget` (e.g. a request without a `max_tokens` cap that falls back to reserving the smallest remaining headroom) is rejected by the hook even though the reservation already admitted it. Skip the hook when the request's active `budget_reservation` covers `spend:user:{user_id}`. The reservation is the source of truth for that counter cross-pod; the legacy `>=` path remains in place for requests without a reservation (e.g. paths that bypass the reservation entirely). Reproduces as `tests/otel_tests/test_prometheus.py::test_user_budget_metrics` on a fresh user with `max_budget=10` calling `fake-openai-endpoint` without `max_tokens`. Adds focused unit coverage in `tests/test_litellm/proxy/hooks/test_max_budget_limiter.py`. * harden bedrock file bucket validation * Fix syntax errors from botched merge in router.py * Fix Vertex batch output edge cases * [Fix] RBAC: Drop management_routes Write Fallback for Admin Viewer Greptile P1: the unsafe-method branch of `_check_proxy_admin_viewer_access` ended with a blanket `if route in management_routes: return`. That set is a mix of reads (info/list — handled via the safe-method GET branch above) and writes. The fallback let Admin Viewer POST to write endpoints not enumerated in `_ADMIN_VIEWER_BLOCKED_WRITE_ROUTES`, including: - /team/block, /team/unblock, /team/permissions_update - /jwt/key/mapping/{new,update,delete} - /key/bulk_update - /key/{key_id}/reset_spend Remove the fallback. The two remaining allow sets (admin_viewer_routes and global_spend_tracking_routes) are both read-only, so removal does not affect the legitimate POST-as-read cases (e.g. /spend/calculate, which is in spend_tracking_routes ⊂ admin_viewer_routes). Tests: - 8 new parametrized cases pinning each previously-leaking management write endpoint to 403 on POST for PROXY_ADMIN_VIEW_ONLY. * fix(tests): anchor VCR redis cassette key to repo root `os.path.relpath` with no `start` arg uses the current working directory, so running pytest from a subdirectory produced a different Redis key than running from the repo root. CI-recorded cassettes and locally-replayed runs would silently miss each other's cache. Anchor the path to the repo root (derived from `__file__`) so the key is stable regardless of CWD. https://claude.ai/code/session_018uCx7pcrkdUJZrCVMaTdPx * fix: gate key access_group override on group's own assignment Replaces the previous intersect-with-team.access_group_ids check, which made the override unreachable in practice (the team-gate fallback already covered every case the intersection allowed). The override now resolves each of the key's access_group_ids via get_access_object and accepts the group only if its assigned_team_ids includes the key's team_id, or its assigned_key_ids includes the key's token. This fulfills the original ask (a key can extend a team's allow-list via a group the admin granted to that team or that specific key) while still rejecting foreign groups referenced by team members of other teams. * [Fix] Proxy/Key Management: Honor team_member_permissions /key/list In /key/list Endpoint When a team grants /key/list via team_member_permissions, non-admin members should see all keys for that team — same as a team admin. Previously the classification in list_keys() only checked admin status, so permitted members fell into the service-account-only path and could not see other members' personal keys. Routes those members into the full-visibility set. * Fix access-group bypass via litellm-model fallback path When _get_all_deployments returns 0 candidates and the litellm-model fallback branch (_get_deployment_by_litellm_model) finds deployments that the access-group filter then empties, _access_group_filter_emptied_candidates remained False (it was captured before that branch ran). The router would then proceed to default fallbacks; the fallback model could have no access_groups and short-circuit the filter, silently serving a caller blocked by access-group restrictions. Update the flag inside the litellm-model branch when filtering empties a non-empty candidate set so the default-fallback guard still triggers. * fix(proxy): redact MCP server URL and headers for non-admin viewers (VERIA-8) Many MCP integrations (Zapier, etc.) embed an upstream API key directly in the server URL, e.g. ``https://actions.zapier.com/mcp//sse``. The list and single-server endpoints were returning the full URL to any authenticated user — `_redact_mcp_credentials` only stripped the explicit ``credentials`` field, and `_sanitize_mcp_server_for_virtual_key` only ran for restricted virtual keys. Non-admin internal users could read the dashboard, click the unmask toggle, and exfiltrate the raw token. Add `_sanitize_mcp_server_for_non_admin` that runs on top of the existing credential redaction and clears the credential-bearing fields: - ``url`` (the primary leak vector) - ``spec_path`` (OpenAPI spec URLs that may carry tokens) - ``static_headers`` / ``extra_headers`` (Authorization) - ``env`` (arbitrary secrets) - ``authorization_url`` / ``token_url`` / ``registration_url`` Identity fields (``server_id``, ``alias``, ``mcp_info``, etc.) are preserved so the UI can still list servers a non-admin's team has access to. Apply the new sanitizer in `fetch_all_mcp_servers` and the per-server fetch path right after the existing virtual-key branch. Update the existing `test_list_mcp_servers_non_admin_user_filtered` assertions that previously checked URL visibility. Frontend defense-in-depth: hide the URL unmask toggle on `mcp_server_view.tsx` unless the viewer is a proxy admin. Co-Authored-By: Claude Opus 4.7 (1M context) * Fix runtime policy attachment initialization Mark runtime-created policies and attachments initialized so global policy attachments created from the policy builder apply immediately without requiring a restart. Co-authored-by: Cursor * test(router): cover _try_early_resolve_deployments_for_model_not_in_names The router_code_coverage CI check requires every function in router.py to be referenced by at least one test under tests/{local_testing, router_unit_tests,test_litellm} in a file with "router" in its name. The recently-extracted helper had no direct test, so the check failed with "0.45% of functions in router.py are not tested". Add a focused test that exercises the four return paths: model already in self.model_names, no fallback applies, pattern-router match, and default_deployment substitution (also asserting the stored default isn't mutated). https://claude.ai/code/session_019AVp1XL7RT9RxRe4qRLkay * Fix policy registry teardown in tests Reset the policy ID index during policy engine test cleanup so stale policy versions cannot leak between tests. Co-authored-by: Cursor * fix(batches): count non-chat tokens, validate batch-file model access (VERIA-39) (#27015) * fix(batches): count non-chat tokens and validate every model in batch file Two security control bypasses on POST /v1/batches: 1. `_get_batch_job_input_file_usage` only summed tokens for `body.messages` (chat completions). Embedding (`input`) and text completion (`prompt`) batches reported zero, letting massive non-chat workloads slip past TPM rate limits. Extend the counter to handle string and list shapes for both fields. 2. The batch input file was forwarded to the upstream provider without inspecting the models named inside the JSONL — only the outer `model` query parameter was checked against the caller's allowlist. A caller restricted to gpt-3.5 could submit a batch targeting gpt-4o and the upstream would execute it under the proxy's shared API key. Add `_get_models_from_batch_input_file_content` (returns the distinct `body.model` values) and call it from `_enforce_batch_file_model_access` in the pre-call hook, which runs each model through `can_key_call_model` so the same allowlist semantics (wildcards, access groups, all-proxy-models, team aliases) the proxy enforces on `/chat/completions` apply here too. Any unauthorized model raises a 403 before the file is forwarded. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(batches): count pre-tokenized prompt/input shapes, classify 403 logs Two follow-ups from the Greptile review on the batch validation PR: 1. P1 TPM bypass via integer token arrays. The OpenAI batch schema accepts ``prompt`` and ``input`` as ``list[int]`` (a single pre-tokenized prompt) or ``list[list[int]]`` (multiple) in addition to the string and ``list[str]`` shapes. Pre-fix only the string shapes were counted, so a caller could submit a batch with hundreds of millions of pre-tokenized tokens and the rate limiter would record zero. Extract the per-field logic into ``_count_prompt_or_input_tokens`` and count each int as one token. 2. P2 access-denial logs were indistinguishable from I/O failures. ``count_input_file_usage`` caught every exception under a generic "Error counting input file usage" message, so an intentional 403 from ``_enforce_batch_file_model_access`` looked the same in the logs as a missing file or a Prisma timeout. Catch ``HTTPException`` separately and log 403s at WARNING level with a security-relevant message before re-raising. Tests cover the new shapes: single ``list[int]``, ``list[list[int]]`` (the worst-case bypass vector), and embeddings ``input`` with pre-tokenized arrays. Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: Claude Opus 4.7 (1M context) * fix(proxy): re-validate user_id after /user/info re-parses query (#27009) * fix(proxy): re-validate user_id ownership after /user/info re-parses query The route-level access check in `RouteChecks.non_proxy_admin_allowed_routes_check` reads `request.query_params.get("user_id")`, which decodes literal `+` to spaces. The endpoint then re-parses the raw query string with `urllib.unquote` in `get_user_id_from_request` to preserve `+` characters (so plus-addressed emails work as user_ids). Those two paths produce different ids: a caller who registered a user_id containing a literal space could pass the route check and then read another user's row by sending the encoded `+` form. Add `_enforce_user_info_access` and call it after `_normalize_user_info_user_id` returns the final id. Proxy admin / view-only admin still bypass; everyone else must match the resolved user_id (or have no user_id, which falls back to the caller's own id later in the handler). Tests cover the admin bypass, owner-match path, and the cross-user lookup that this change blocks. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(proxy): apply user_info ownership check to PROXY_ADMIN_VIEW_ONLY `_enforce_user_info_access` was bypassing both PROXY_ADMIN and PROXY_ADMIN_VIEW_ONLY, but the upstream route check in `RouteChecks.non_proxy_admin_allowed_routes_check` only treats PROXY_ADMIN as a true admin for the `/user/info` route — view-only admins go through the `user_id == valid_token.user_id` enforcement along with regular users. Mirroring that asymmetry left the same encoded-`+` bypass open for view-only admins whose user_id contains a literal space. Drop the PROXY_ADMIN_VIEW_ONLY exemption so the post-decode re-check matches the upstream rule. Update tests: a view-only admin must now be blocked from cross-user lookups but still allowed to read their own row. Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: yuneng-jiang Co-authored-by: Claude Opus 4.7 (1M context) * feat(spend-logs): opt-in suppression of stack traces in spend-tracking error logs Adds LITELLM_SUPPRESS_SPEND_LOG_TRACEBACKS env var. When set to true and the proxy log level is INFO or above, spend-tracking error paths emit a single ERROR line without the full traceback. Stack traces are preserved at DEBUG and the Sentry / proxy_logging_obj.failure_handler path is unchanged. The new spend_log_error helper is wired through the spend write hot path: - DBSpendUpdateWriter (update_database, _update_*_db, batch upsert, redis-commit fallbacks) - _ProxyDBLogger._PROXY_track_cost_callback - get_logging_payload exception path - update_spend / update_daily_tag_spend / spend logs queue monitor Resolves LIT-2704. Co-authored-by: Mateo Wang * fix(spend-logs): preserve no-traceback behavior for update_daily_tag_spend This call site previously logged a single-line error via verbose_proxy_logger.error() with no traceback. Switching it to spend_log_error(..., exc=e) caused a full stack trace to render by default (when LITELLM_SUPPRESS_SPEND_LOG_TRACEBACKS is unset), which contradicts the PR goal of leaving default behavior unchanged. Revert this specific site to the original error log call. * fix(spend-logs): preserve no-traceback behavior for update_daily_tag_spend Bugbot caught a regression: the previous error log here was a single-line verbose_proxy_logger.error(...) with no traceback. spend_log_error attaches the active exception's traceback by default (when the suppression env var is unset), so swapping it in changed default behavior. Revert this one site to its original .error() call to keep the PR strictly opt-in. Co-authored-by: Mateo Wang * feat(spend-logs): suppress traceback in SpendLogs error_information row Extend LITELLM_SUPPRESS_SPEND_LOG_TRACEBACKS to the failure callback so the per-row Metadata pane in the UI no longer shows the stack trace when the opt-in env var is set, matching the existing console-side suppression. https://claude.ai/code/session_014dztoRbRnRvq54HL9EyHx6 * [Fix] Proxy: Repair Merge Fallout In Router-Override Fallback Auth Conflict resolution for #26968 dropped the `Iterator` typing import (NameError at module load), left a dead `fallback_models = cast(...)` block, and the new tests called `_enforce_key_and_fallback_model_access` without the now-required `request` kwarg. * isolate dual OTEL handlers * harden cloud file compatibility path * harden cloud file compatibility path * [Fix] Proxy/Key Management: Align Key-Org Membership Checks On Generate And Regenerate Mirrors the membership rule on /key/update so that /key/generate and /key/{key}/regenerate apply the same `_validate_caller_can_assign_key_org` gate when the caller specifies an `organization_id`. Proxy admins bypass. The check no-ops when `organization_id` is not being set. * thread trusted params through vertex file content * trust only server legacy file flag * chore(proxy): keep public AI hub unauthenticated * fix(proxy): preserve low-detail readiness status * [Test] Anthropic: Replace Legacy Claude-4-Sonnet Alias With Haiku 4.5 Three live-API tests pinned to claude-4-sonnet-20250514, which is a non-canonical alias of claude-sonnet-4-20250514. Anthropic's main API no longer resolves the legacy form under freshly issued keys, so the tests fail with not_found_error. The token counter test pinned to claude-sonnet-4-20250514 itself (deprecation_date 2026-05-14, two weeks out) was on borrowed time too. Bump all four to claude-haiku-4-5-20251001 — capability superset for what these tests exercise (streaming, parallel tool calling, extended thinking, token counting), no upcoming deprecation, cheaper per-token. * chore(proxy): move URL-valued model/file_id guard from SDK to proxy The previous per-provider guards in HuggingFace, Oobabooga, and Gemini files lived in the SDK layer, breaking SDK callers who legitimately pass URL-valued model identifiers. Move the check to the proxy boundary in add_litellm_data_to_request so SDK users keep working while proxy users default-deny URL-valued model and file_id, with admin opt-in via litellm.provider_url_destination_allowed_hosts. Co-Authored-By: Claude Opus 4.7 (1M context) * [Chore] Proxy/UI: Drop stray _experimental/out/chat/index.html This file is a regenerable UI build artifact that should not be tracked in source. Removing so the merge into litellm_internal_staging stays clean. * [Test] Anthropic Passthrough: Bump Streaming Cost-Injection Test To Haiku 4.5 test_anthropic_messages_streaming_cost_injection hits the proxy's /v1/messages route, which routes via the anthropic/* wildcard to api.anthropic.com. The 404 surfaced in the test was Anthropic's own not_found_error propagated back through the proxy (visible from the x-litellm-model-id hash on the response — the proxy did route). Same root cause as the prior commit: the legacy claude-4-sonnet-20250514 alias is no longer recognized by Anthropic's main API under the new key. Swap to claude-haiku-4-5-20251001 — same routing path, canonical model. * fix(proxy): handle ownership-recording failures after upstream create If record_container_owner raises after the upstream container is created, the user previously got a 500 with no usable container — they were billed for an unreachable resource. Move ownership recording into the create path's exception handling and split the two failure modes: - HTTPException from the recorder (auth conflicts) propagates verbatim so the client sees the real status code, not a generic LLM error. - Unexpected exceptions are logged and swallowed; the response is returned to the caller so they aren't billed for a container they can't address. The DB row stays untracked until an operator reconciles. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(guardrails): close post-call coverage gaps * fix(types): add /team/permissions_bulk_update to management_routes The blocklist check in _check_proxy_admin_viewer_access only fires for routes that match LiteLLMRoutes.management_routes — the bulk-update endpoint was missing from that list, so the test for view-only admins on /team/permissions_bulk_update fell through to "allow." Co-Authored-By: Claude Opus 4.7 (1M context) * [Test] Anthropic Passthrough: Bump Thinking Tests Off Legacy Sonnet 4 Alias base_anthropic_messages_test.test_anthropic_messages_with_thinking and test_anthropic_streaming_with_thinking still pinned to claude-4-sonnet-20250514 — the same legacy alias Anthropic no longer recognizes under freshly issued keys. The other four tests in this base class already use claude-sonnet-4-5-20250929; these two were missed. Bump to claude-haiku-4-5-20251001 (supports_reasoning=true, no upcoming deprecation). Subclasses including TestAnthropicPassthroughBasic inherit these methods. * fix(guardrails): cover multi-choice output variants * fix(proxy): preserve public ai hub ui setting * fix(scim): cascade FK cleanup on user delete and surface block status in UI SCIM DELETE /Users/{id} previously called litellm_usertable.delete without clearing rows that FK back to the user, so Postgres rejected the delete with LiteLLM_InvitationLink_user_id_fkey and the SCIM caller saw a 500. Add a helper to drop invitation_link, organization_membership, and team_membership rows before the user delete (mirrors /user/delete in internal_user_endpoints). Also add a Status column to the Virtual Keys and Internal Users tables so admins can see at a glance which keys are blocked and which users SCIM has deactivated. SCIM-blocked keys carry a tooltip explaining the origin. Pin the dashboard's Node version to 20 via .nvmrc to match CI. * chore: update Next.js build artifacts (2026-05-02 03:21 UTC, node v20.20.2) * perf(proxy): cache container/skill ownership reads on the hot path Container ownership and skill rows are looked up on every retrieve / delete / list / file-content / chat-completion-with-skill call. The new stores wrapped raw Prisma queries with no cache, putting one DB round-trip on each request. Add an in-process TTL'd cache mirroring the _byok_cred_cache pattern in mcp_server/server.py: per-key (value, monotonic_timestamp), 60s TTL, 10000-entry cap with full-clear on overflow, invalidated by every write. Negative results (`None`) are cached too so untracked-resource checks also skip the DB. Tests cover: cache-after-first-hit, negative caching, write invalidation, no-caching-on-DB-error, TTL expiry, capacity eviction. 56 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) * chore: update Next.js build artifacts (2026-05-02 03:39 UTC, node v20.20.2) * fix: remove traceback key instead of it being "" * fix: linting error * fix(scim): preserve scim_active on PUT when client omits the field A SCIM PUT may legally omit `active` (full-replace with the field absent). Pydantic fills the SCIMUser.active default of True, so the PUT handler was overwriting metadata.scim_active with True even when the client never sent it — silently reactivating a previously SCIM-blocked user and unblocking their keys. Use model_fields_set to detect whether the client actually sent `active`. If omitted, preserve the prior scim_active value and skip the cascade to virtual keys. Also drop comments added in this PR that just narrate what the code does; keep only the docstrings and the SQL-NULL pitfall note that explain non-obvious behaviour. Co-authored-by: Mateo Wang * fix(proxy): use set lookup for permitted agent filters * fix(mcp): redact command fields for non-admin server views * fix(proxy): forward decoded container ids after ownership checks * fix(caching): handle stale isolated Redis semantic index * fix(cloudflare): support response_text in streaming chunk parser Newer Cloudflare Workers AI models (e.g. Nemotron) emit 'response_text' instead of 'response' on streamed chunks. The non-streaming path was already updated to fall back to 'response_text' (#26385), but the streaming chunk parser still only read 'response', which caused streaming requests against those models to silently produce empty content. Mirror the non-streaming fallback in CloudflareChatResponseIterator.chunk_parser and add a streaming test for the response_text shape. Co-authored-by: Mateo Wang * Fix code qa * Address bugbot: drop dead encode/decode helpers; preserve empty custom_id - Remove unused _encode_gcp_label_value / _decode_gcp_label_value singular helpers; only the _chunks variants are actually called. - Use 'is not None' check for custom_id so empty-string custom_ids are still labeled and round-trip through batch outputs. Co-authored-by: Mateo Wang * Forward Vertex file content logging context * test vertex file content logging forwarding Co-authored-by: Sameer Kankute * Fix Vertex batch output logging mutation * fix: don't mutate caller's logging_obj in _try_transform_vertex_batch_output_to_openai The method was overwriting logging_obj.optional_params, logging_obj.model, and logging_obj.start_time on the caller's Logging instance. When invoked from llm_http_handler.py's generic framework path, the framework's own logging_obj (which already went through pre_call) had its properties clobbered, causing model and start_time to reflect the last batch line's values rather than the original call context. Fix: create a fresh local Logging instance for the per-line transformation instead of mutating the incoming logging_obj. The caller's object is now left entirely untouched regardless of whether a logging_obj was passed in or not. Regression tests added to verify model, start_time, and optional_params are not mutated on the caller's logging_obj. Co-authored-by: Sameer Kankute * feat: add opt-out flag for Vertex batch output transformation Adds litellm.disable_vertex_batch_output_transformation (default False). When True, afile_content returns raw Vertex predictions.jsonl untouched so users that parse candidates/modelVersion directly are not broken. * fix(anthropic,bedrock): omit thinking/output_config when reasoning_effort="none" Setting reasoning_effort="none" on Anthropic chat models (direct, Bedrock Invoke, Bedrock Converse, Vertex AI Anthropic, Azure AI Anthropic) crashed LiteLLM with: litellm.APIConnectionError: 'NoneType' object has no attribute 'get' Both the Anthropic chat transformation and Bedrock Converse called ``AnthropicConfig._map_reasoning_effort`` and assigned the ``None`` it returns for ``"none"`` directly to ``optional_params["thinking"]``. Downstream ``is_thinking_enabled`` then did ``optional_params["thinking"].get("type")`` and crashed. Pop ``thinking`` (and on Claude 4.6/4.7, ``output_config``) instead of assigning ``None``, restoring the documented contract that ``reasoning_effort="none"`` means "do not enable thinking". This also prevents downstream Anthropic 400s ("thinking: Input should be an object", "output_config.effort: Input should be ...") if the bug were ever masked. Verified end-to-end against the live Anthropic API and Bedrock Converse on claude-opus-4-{5,6,7} and claude-sonnet-4-6, plus Bedrock Invoke for Claude 4.5/4.6. Vertex AI Anthropic and Azure AI Anthropic inherit the fixed ``map_openai_params`` from ``AnthropicConfig`` and need no further changes. * fix(vertex-ai): set response=null on batch error entries per OpenAI spec The Vertex batch output transformer was emitting both a populated 'response' and 'error' for failed batch entries. The OpenAI Batch output spec defines them as mutually exclusive: on error 'response' MUST be null. This broke any consumer using 'result["response"] is None' to detect failures. * test(vertex-ai): cover transformation_error path emits response=null * fix(security): sandbox jinja2 in gitlab/arize/bitbucket prompt managers DotpromptManager was hardened to render through ImmutableSandboxedEnvironment. The three sibling managers (gitlab, arize, bitbucket) were missed and still instantiate plain jinja2.Environment(), leaving the same attribute-traversal SSTI primitive open: a template fetched from a GitLab/BitBucket repo or Arize Phoenix workspace can reach __class__.__init__.__globals__ and execute arbitrary Python on the proxy host. Match the dotprompt pattern by switching all three to ImmutableSandboxedEnvironment. The sandbox blocks the dunder-traversal chain while leaving normal {{ var }} substitution intact, so the template surface is unchanged for legitimate use. Adds tests/test_litellm/integrations/test_prompt_manager_ssti.py (18 cases) verifying each manager's jinja_env is a sandbox, that classic SSTI payloads raise SecurityError, and that ordinary variable rendering still works. Co-Authored-By: Claude Opus 4.7 (1M context) * chore(proxy): drop client-supplied pricing fields from request bodies The proxy currently forwards request-body pricing parameters (the fields on `CustomPricingLiteLLMParams`, plus `metadata.model_info`) into the core call path. Those fields belong to deployment configuration, not to per-request input — sending them from a client mutates the request's recorded cost and, via `litellm.completion` → `register_model`, the process-wide `litellm.model_cost` map for every later caller in the worker. Strip them at the boundary. The strip set is built from `CustomPricingLiteLLMParams.model_fields` so pricing fields added later are covered automatically. Operators who do want clients to supply per-request pricing can opt back in per key or team via `metadata.allow_client_pricing_override = true`, mirroring the existing `allow_client_mock_response` and `allow_client_message_redaction_opt_out` flags. Tests cover the strip set's coverage, root and metadata strips, the opt-in skip on both key and team metadata, and a regression check that the global `litellm.model_cost` map is unmutated after a stripped request. Co-Authored-By: Claude Opus 4.7 (1M context) * chore(proxy): log stripped pricing fields at debug for operator visibility Operators upgrading would otherwise see client-supplied pricing overrides silently stop applying with no diagnostic. Emit a debug-level line listing the dropped fields and pointing at the opt-in flag when any are stripped; stay silent on the no-op path so the log isn't filled with noise. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(proxy): move pricing strip below the litellm_metadata JSON-string parse The strip ran before the proxy parses ``litellm_metadata`` from a JSON string into a dict (a path used by multipart/form-data and ``extra_body`` callers), so ``isinstance(metadata, dict)`` was False and ``model_info`` survived the strip. Move the call to the same post-parse position the ``user_api_key_*`` strip already uses for the same reason. Adds a regression test exercising the JSON-string ``litellm_metadata`` path. Co-Authored-By: Claude Opus 4.7 (1M context) * test(responses): replace legacy claude-4-sonnet alias in multiturn tool-call test Anthropic's main API no longer resolves the non-canonical 'claude-4-sonnet-20250514' alias for freshly issued keys, returning 404 not_found_error. PR #27031 already swept three other live tests pinned to this alias to claude-haiku-4-5-20251001 but missed test_multiturn_tool_calls in the responses API suite, which is now failing reliably on PR CI runs (e.g. PR #27074, job 1603363). Bump the two model references in test_multiturn_tool_calls to the same claude-haiku-4-5-20251001 snapshot used by PR #27031 -- it covers everything this test exercises (tool calling, multi-turn) and isn't on a deprecation schedule. Co-authored-by: Mateo Wang * chore(proxy): close callback-config and observability-credential side channels Two related gaps in the proxy's request bouncer: 1. ``is_request_body_safe`` (auth_utils.py) walked the request-body root and the ``litellm_embedding_config`` nested dict, but not ``metadata`` or ``litellm_metadata``. The same fields it bans at root — Langfuse / Langsmith / Arize / PostHog / Braintrust / Phoenix / W&B Weave / GCS / Humanloop / Lunary credentials and routing — were silently accepted when the caller put them inside metadata, retargeting observability callbacks to a caller-controlled host with caller-supplied creds. Walk both metadata containers (and parse the JSON-string form sent via multipart / ``extra_body``) through the same banned-params helper, so the existing ``allow_client_side_credentials`` opt-in covers both paths consistently. 2. The banned-params list was hand-maintained and lagged the canonical ``_supported_callback_params`` allow-list in ``initialize_dynamic_callback_params``. Derive the observability bans from that allow-list (minus a small ``_SAFE_CLIENT_CALLBACK_PARAMS`` set for informational fields like ``langfuse_prompt_version`` and ``langsmith_sampling_rate``) so future integrations are covered automatically; ``_EXTRA_BANNED_OBSERVABILITY_PARAMS`` carries the handful of fields integrations read but the allow-list hasn't caught up to. A guard test fails CI if a new entry is added to ``_supported_callback_params`` without an explicit safe-list decision. Separately in ``litellm_pre_call_utils.py``: add ``callbacks``, ``service_callback``, ``logger_fn``, and ``litellm_disabled_callbacks`` to ``_UNTRUSTED_ROOT_CONTROL_FIELDS``. The first three are appended to worker-wide ``litellm.{input,success,failure,_async_*,service}_callback`` lists / ``litellm.user_logger_fn`` from inside ``function_setup`` — one request poisons every subsequent caller in that worker. The last is the inverse primitive: the legitimate path reads it from key/team metadata, the request-body version silently disables admin-configured audit / observability for the call. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(auth): per-param allow must continue, not return early A pre-existing logic bug in ``_check_banned_params``: when the deployment-level ``configurable_clientside_auth_params`` permitted one banned field, the loop ``return``-ed on the first match instead of ``continue``-ing, so any other banned param later in the same body or metadata dict was never checked. This PR's metadata walk multiplies the surface where that bypass matters — a body pairing an allowed ``api_base`` with an observability credential like ``langfuse_host`` would silently pass. Proxy-wide ``allow_client_side_credentials`` keeps ``return`` (it's a global opt-in for every banned param). The per-param branch becomes ``continue`` so only the one explicitly-permitted field is skipped. Adds a regression test that exercises the api_base + langfuse_host pair. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(vector_store): resolve embedding config at request time, never persist creds The vector store create/update path previously called ``_resolve_embedding_config`` against the admin-configured router/DB model and persisted the resolved ``litellm_embedding_config`` dict (``api_key`` / ``api_base`` / ``api_version``) into the ``litellm_managedvectorstorestable.litellm_params`` column. Because the resolver expanded ``os.environ/...`` references via ``get_secret``, the DB row carried cleartext provider credentials, and the ``/vector_store/{new,info,update,list}`` responses returned them to any authenticated caller who could supply a known admin model name. Move the auto-resolve out of ``create_vector_store_in_db`` and out of the update path. Persist only the user-supplied ``litellm_embedding_model`` reference. Resolve at request-handling time inside ``_update_request_data_with_litellm_managed_vector_store_registry`` so the resolved config lives in the per-request ``data`` dict and is garbage-collected after the response. Legacy rows that were created by an earlier proxy version and already carry a resolved ``litellm_embedding_config`` skip the re-resolution and pass through unchanged so embedding calls keep working. The ``new_vector_store`` response now also runs the existing ``_redact_sensitive_litellm_params`` masker (already used by ``info``, ``update``, and ``list``), defending against caller-supplied cleartext on the create path and against legacy rows whose persisted credentials are still in the database. Existing tests that asserted the old write-time-resolve behaviour are updated to assert the new persistence shape (no embedding config stored, just the model reference). Two new tests cover the use-time path: one asserting fresh resolution happens when a row carries only the model reference, the other asserting legacy rows with persisted config skip re-resolution and continue to work. Co-Authored-By: Claude Opus 4.7 (1M context) * fix(vector_store): tighten registry-mutation comment and dedupe test helpers * fix(vector_store): cache use-time embedding-config resolution Hold the resolved config in a process-memory TTL cache so the request-handling path doesn't run litellm_proxymodeltable.find_first on every vector-store call. * fix(anthropic,bedrock,vertex): forward output_config.effort + 400 on garbage reasoning_effort Follow-up bugs surfaced by the QA sweep on PR #27039 (https://github.com/BerriAI/litellm/pull/27039#issuecomment-4363363610). 1. Stop stripping output_config.effort on Bedrock + Vertex adaptive routes. - Vertex AI Claude 4.6/4.7 accepts output_config.effort on rawPredict (verified end-to-end against us-east5 / global). The strip helper now no-ops for effort. - Bedrock Converse routes output_config into additionalModelRequestFields for anthropic base models so the requested adaptive tier (low/medium/ high/xhigh/max) actually reaches the wire instead of all collapsing to identical thinking. - Bedrock Invoke chat transformation (AmazonAnthropicClaudeConfig) stops popping output_config from the post-AnthropicConfig request body. - Bedrock Invoke /v1/messages allowlist (BedrockInvokeAnthropicMessagesRequest) now lists output_config so the runtime allowlist filter forwards it. 2. Validate effort across Bedrock Converse so 'disabled' / 'invalid' / '' / unsupported tiers (xhigh/max on Sonnet 4.6 or budget-mode 4.5 models) surface as a clean 400 BadRequestError instead of 500. 3. ValueError -> BadRequestError throughout (AnthropicConfig.map_openai_params, _apply_output_config, AmazonConverseConfig._handle_reasoning_effort_parameter). Empty-string effort is now rejected (was silently passing the 'if effort and ...' short-circuit). 4. Floor reasoning_effort='minimal' at the Anthropic provider minimum (1024 budget_tokens) via new ANTHROPIC_MIN_THINKING_BUDGET_TOKENS so it's a usable tier on direct Anthropic / Azure AI Anthropic / Vertex AI Anthropic / Bedrock Invoke (all of which 400 below 1024). 5. model_prices: dedupe duplicate supports_max_reasoning_effort key on claude-opus-4-7 / claude-opus-4-7-20260416. Adds regression tests across all five affected paths; existing tests asserting the silent-strip behavior were updated to reflect the new pass-through and clean 400 surfaces. Co-authored-by: Mateo Wang * fix(constants): make ANTHROPIC_MIN_THINKING_BUDGET_TOKENS a plain constant The documentation CI test (tests/documentation_tests/test_env_keys.py) asserts every os.getenv() key in the source has a matching entry in the litellm-docs config_settings.md table. ANTHROPIC_MIN_THINKING_BUDGET_TOKENS tracks Anthropic's published wire-protocol minimum (1024) — it's not a user-tunable, so making it env-overridable was wrong anyway. Drop the os.getenv() wrapper; the value is now a plain literal. Co-authored-by: Mateo Wang * fix(anthropic,bedrock): correct effort error message and dedupe effort_map - Remove 'none' from the Bedrock _validate_anthropic_adaptive_effort error message; it was listed as a valid value but rejected by the membership check, leaving users in a feedback loop if they tried 'none'. - Hoist the duplicated reasoning_effort -> output_config.effort mapping out of AnthropicConfig.map_openai_params and AmazonConverseConfig._handle_reasoning_effort_parameter into a single AnthropicConfig.REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT class constant so the two routes cannot drift. * fix(anthropic): translate reasoning_effort on /v1/messages route Closes the remaining QA-sweep gap on PR #27074: Bedrock Invoke /v1/messages was silently ignoring ``reasoning_effort`` because the shared param filter only kept native Anthropic keys, so every effort tier collapsed to the same behavior on the wire (27/231 cells failing across opus-4-5 / opus-4-6 / sonnet-4-6). Map ``reasoning_effort`` to native Anthropic ``thinking`` / ``output_config.effort`` at the ``AnthropicMessagesConfig`` layer so all four /v1/messages routes (direct Anthropic, Azure AI, Vertex AI, Bedrock Invoke) inherit the same translation: - Add ``reasoning_effort`` to ``AnthropicMessagesRequestOptionalParams`` so the param filter in ``AnthropicMessagesRequestUtils.get_requested_anthropic_messages_optional_param`` no longer drops it before the transformation runs. - Add ``_translate_reasoning_effort_to_anthropic`` and call it from ``transform_anthropic_messages_request``. Mirrors ``AnthropicConfig.map_openai_params`` on the chat completion path (re-uses ``_map_reasoning_effort`` and ``REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT``) so the two routes cannot drift. Pops ``reasoning_effort`` so it never reaches the wire. - Caller-supplied native ``thinking`` / ``output_config.effort`` always win — same precedence as ``_translate_legacy_thinking_for_adaptive_model``. - Garbage values (``""``, ``"disabled"``, ``"invalid"``) raise ``AnthropicError(status_code=400)`` instead of falling through and surfacing as 500s from the provider. - ``"none"`` clears thinking + output_config so callers can opt out per request. Also restores the non-adaptive-model test coverage on Bedrock Invoke /v1/messages that the previous commit lost when ``test_bedrock_messages_strips_output_config`` was renamed to the ``forwards`` variant on Opus 4.7. Adds a new test file ``test_reasoning_effort_translation.py`` covering the translation at the shared config level (adaptive + non-adaptive models, none, garbage, caller precedence) so all four /v1/messages routes are exercised by a single suite. Adds parametrized + behavioral tests on the Bedrock Invoke /v1/messages suite covering: minimal/low/medium/high/xhigh/max mapping for adaptive models, thinking-budget mapping for non-adaptive Opus 4.5, ``none`` clears both, garbage raises 400, explicit ``output_config`` wins. Refs: https://github.com/BerriAI/litellm/pull/27074 * fix(anthropic,bedrock): reject unmapped reasoning_effort at mapping site Both the chat completion path (AnthropicConfig.map_openai_params) and the Bedrock Converse path (_handle_reasoning_effort_parameter) used REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get(value, value) which falls back to the raw input on unmapped keys. Combined with _map_reasoning_effort returning type='adaptive' for any string on Claude 4.6/4.7, garbage values (e.g. 'disabled') could leak into optional_params['output_config']['effort'] unvalidated if map_openai_params ran without the downstream transform_request or _validate_anthropic_adaptive_effort check. Mirror the /v1/messages pattern: use .get(value) (no fallback) and raise BadRequestError immediately when the value is unmapped, co-locating validation with the mapping for defense in depth. * style: black formatting Co-authored-by: Mateo Wang * fix(anthropic): stop class-attr leak; gate xhigh/max on every route The reasoning-effort mapping dict was a public class attribute on AnthropicConfig, so BaseConfig.get_config returned it as a request parameter and every Anthropic-backed call (Anthropic / Azure / Vertex / Bedrock Invoke) hit a 400 'REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT: Extra inputs are not permitted' from the provider. Move the mapping to a module-level constant. _supports_effort_level only looked the model up under custom_llm_provider='anthropic', so bedrock-prefixed model ids (e.g. bedrock/invoke/us.anthropic.claude-opus-4-7) returned False for both 'max' and 'xhigh' even when the underlying model entry has the flag set. Strip known provider prefixes and retry the lookup against litellm.model_cost directly so per-model gating works on every route. Mirror the per-model xhigh/max gate from AnthropicConfig._apply_output_config in AnthropicMessagesConfig._translate_reasoning_effort_to_anthropic so the /v1/messages route also raises a clean 400 instead of forwarding the unsupported tier. * feat(anthropic,bedrock): strip output_config under drop_params for non-effort models When a proxy fronts Claude Code (which always sends `output_config.effort`) at a pre-4.5 Anthropic model — haiku-3, sonnet-3.5, opus-3, sonnet-4 — the forwarded knob causes a forced 400 the client can't fix. Gating a strip behind the existing `drop_params` flag lets operators opt into silent fixup once and stop worrying about per-model param hygiene. Default (`drop_params=False`) still forwards and surfaces the provider's error, preserving the strict, debuggable contract from #27074. Per https://platform.claude.com/docs/en/build-with-claude/effort the supporting set is Opus 4.5+, Sonnet 4.6+, and Mythos Preview; everything else is dropped (with a verbose_logger warning so the strip is visible). Recognition uses model-name patterns plus a fallback to any `supports_*_reasoning_effort` flag in the model map for forward compatibility with new entries. https://claude.ai/code/session_01WjHq31rvXT6xYNdVmSJvRp (cherry picked from commit 1233943e7861ba8a9062f792310ebd401cb03db8) * fix(base_llm): filter all _-prefixed class attrs from get_config The drop_params strip work added `AnthropicConfig._EFFORT_SUPPORTING_MODEL_PATTERNS` as a private class-level lookup tuple. `BaseConfig.get_config()` only filtered the `__`-prefixed names plus `_abc` / `_is_base_class`, so `_EFFORT_SUPPORTING_MODEL_PATTERNS` would have leaked into the request body the same way `REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT` did before the previous commit. Generalize the existing `_abc` / `_is_base_class` carve-outs to skip every `_`-prefixed name. `AmazonConverseConfig.get_config()` overrides the base method, so apply the same change there. Also unblocks future internal helpers from accidentally serialising into the wire body. * fix(anthropic): drive output_config.effort support from model map flags Replace hardcoded _EFFORT_SUPPORTING_MODEL_PATTERNS with a JSON-backed check that uses supports_*_reasoning_effort flags from the model map. Add supports_minimal_reasoning_effort: true to opus-4-5 and mythos-preview entries (which previously only carried supports_reasoning) so the JSON remains the single source of truth for effort capability. * fix(anthropic,bedrock,databricks): four reasoning_effort follow-ups - claude-sonnet-4-6 + reasoning_effort=max no longer 400s. Renamed _is_opus_4_6_model to _is_claude_4_6_model at three sites and added supports_max_reasoning_effort: true to 12 model entries in the JSON cost map (10 sonnet 4.6 ids + OpenRouter opus 4.6/4.7). - _map_reasoning_effort now raises BadRequestError(400) directly with llm_provider, instead of letting Databricks (and similar callers) surface its raw ValueError as a 500. - output_config.effort on Opus 4.5 over Bedrock no longer 400s for missing effort-2025-11-24 beta. Flipped JSON to "effort-2025-11-24" for bedrock + bedrock_converse and added an auto-attach branch in _process_tools_and_beta for non-adaptive Anthropic + output_config on Converse. - reasoning_effort=xhigh / =max on legacy budget-mode models (Haiku 4.5, Sonnet 4.5, Opus 4.5) now map to thinking.budget_tokens 8192 / 16384 instead of returning 400. Added two constants in litellm/constants.py. Tests updated for all four flips. Validated end-to-end via 306-cell live proxy matrix (6 model families x 3 routes x 17 effort cases), all pass. * fix(databricks): validate reasoning_effort and set output_config on adaptive Claude The Databricks path called `AnthropicConfig._map_reasoning_effort` for Claude models but never validated the effort string nor set `output_config.effort` for adaptive models (Claude 4.6/4.7). Since `_map_reasoning_effort` returns `type=adaptive` for ANY non-None / non-"none" string on adaptive models (including "disabled", "invalid", ""), Databricks silently accepted garbage and emitted a request without an `output_config.effort`, collapsing every adaptive tier to identical behavior. Match the Anthropic native, Bedrock Converse, Bedrock Invoke, and /v1/messages paths: when the resolved `thinking` is non-None on a 4.6/4.7 model, look up the value in `REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT` and either raise a clean `BadRequestError` or set `optional_params["output_config"]`. * fix(azure): omit model from image generation and image edit deployment requests Azure OpenAI routes image gen/edit by deployment in the URL; sending the deployment id in model breaks gpt-image-2 (invalid_value). Strip model from JSON for deployments/.../images/generations and from multipart data for .../images/edits. Non-deployment URLs (e.g. Azure AI FLUX) unchanged. Fixes #26316. Co-authored-by: Cursor * test(azure): exercise image gen JSON filter via HTTP client; dedupe image edit URL - Image generation tests patch HTTPHandler.post / get_async_httpx_client so make_*_azure_httpx_request runs and wire json is asserted on call kwargs. - Azure image edit: strip model in finalize_image_edit_multipart_data using the same URL string the handler passes to POST (no second get_complete_url in transform). BaseImageEditConfig default finalize is a no-op. Co-authored-by: Cursor * fix(azure_ai/anthropic): promote output_config out of extra_body so validation runs `azure_ai` is registered in `litellm.openai_compatible_providers`, so `add_provider_specific_params_to_optional_params` (litellm/utils.py) auto-stuffs any non-OpenAI kwarg (e.g. `output_config={"effort": "..."}`) into `optional_params["extra_body"]`. `AzureAnthropicConfig.transform_request` then strips `extra_body` entirely on the way out, silently dropping the param — and `AnthropicConfig._apply_output_config` never sees it, so `effort="invalid"` / `effort="xhigh"` on a non-supporting model quietly reaches the model with default behavior instead of returning a clean 400 (as the native `anthropic` provider does). Promote the keys back to top-level `optional_params` (using `setdefault` so explicit top-level values win) before delegating to the parent `AnthropicConfig`. Apply in both `validate_environment` and `transform_request` so flag detection (`is_mcp_server_used`, etc.) and output-config validation both run. Surfaced by the QA matrix expansion on PR #27074: 20 cells where Azure returned 200 while `anthropic` returned 400 — all `output_config` mode across haiku_4_5, sonnet_4_5, opus_4_5, sonnet_4_6, opus_4_6, opus_4_7 families with `effort` in {invalid, xhigh, max, low, medium, high}. Tests: * `test_output_config_promoted_from_extra_body`: valid effort reaches data * `test_invalid_output_config_effort_raises_via_extra_body`: 400 on bad effort * `test_unsupported_effort_xhigh_raises_via_extra_body`: 400 on xhigh-on-Sonnet-4.6 * `test_extra_body_promotion_does_not_clobber_top_level`: setdefault semantics * test(image_gen): expect no model in Azure image edit multipart (#26316) Align test_azure_image_edit_litellm_sdk with deployment-scoped Azure edits. Co-authored-by: Cursor * refactor(anthropic): extract _validate_effort_for_model to prevent drift The chat completion path (`_apply_output_config`) and the /v1/messages pass-through (`AnthropicMessagesConfig._translate_reasoning_effort_to_anthropic`) both gate `max` / `xhigh` per model. The two sites had diverged from near-identical copies into separately maintained blocks, creating a real drift risk when a new model tier (e.g. Claude 4.8) lands -- a contributor could update one site and miss the other. Centralise the gating in `AnthropicConfig._validate_effort_for_model`, which returns an error message string or `None`. Each call site keeps its own provider-appropriate exception type (`BadRequestError` for the chat path, `AnthropicError` for the /v1/messages pass-through) but the gating decision now comes from one place. Net -11 LOC. Adds a parametrised unit test exercising the helper directly across 4.5 / 4.6 / 4.7 model families and `max` / `xhigh` / lower-effort inputs. Existing tests at both call sites continue to pass unchanged. Addresses Greptile finding on PR #27074. * fix(databricks): narrow reasoning_effort_value to str for mypy `non_default_params.get("reasoning_effort")` returns `Any | None`, but `REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get()` expects `str`. Mypy flagged this on the strict pass. Narrow with `isinstance` before the lookup; non-strings fall through to the existing `BadRequestError` below with a clean validation message, so behavior is unchanged. Fixes a regression introduced by 1a10746e95 in this PR. * feat(proxy): add health_check_reasoning_effort for model health checks Co-authored-by: Cursor * test(image_gen): align Azure image gen fixture with body omitting model Expected JSON matches deployment-scoped Azure POST (#26316). Co-authored-by: Cursor * test(anthropic/chat): force PR-local model_cost map via autouse fixture CI runs without LITELLM_LOCAL_MODEL_COST_MAP=True, so litellm.model_cost is loaded from main-branch JSON (default model_cost_map_url) instead of the PR's checked-out model_prices_and_context_window.json. Tests that assert per-model flags added in this PR (supports_max_reasoning_effort, supports_xhigh_reasoning_effort) therefore pass locally but fail in CI with 'AssertionError: assert False is True' on 5 cases: - test_anthropic_model_supports_effort_param_recognizes_supporting_models [anthropic.claude-mythos-preview, bedrock/.../mythos-preview, claude-opus-4-5-20251101] - test_supports_effort_level_handles_provider_prefixes [bedrock/invoke/us.anthropic.claude-sonnet-4-6-max-True, claude-sonnet-4-6-max-True] Add an autouse fixture at tests/test_litellm/llms/anthropic/chat/conftest.py that monkey-patches litellm.model_cost to the PR-local JSON for every test in this directory. The parent conftest already snapshots+restores litellm.model_cost per-function, so the mutation is contained. This is a scoped workaround. The proper fix is to set the env var globally in the test workflow once the ~10 inline self-set test files are audited; tracking that as a follow-up issue. * [Fix] Docker: Pin Wolfi And Uv To Multi-Arch Index Digests The previous pins resolved to single-platform amd64 manifests, so buildx pulled the same amd64 base for both linux/amd64 and linux/arm64 targets. The published OCI index then advertised an arm64 entry whose layers are byte-identical to amd64 -- arm64 users got an amd64 binary. Switch all three Dockerfiles to the multi-arch image-index digests: - cgr.dev/chainguard/wolfi-base (index has linux/amd64 + linux/arm64) - ghcr.io/astral-sh/uv:0.11.7 (index has linux/amd64 + linux/arm64) Resolved with `docker buildx imagetools inspect ` -- that returns the index digest. `docker pull` + `docker inspect` returns the per-host platform digest, which is what slipped in last time. * [Fix] Docker: Pin Uv To Multi-Arch Index Digest In Remaining Dockerfiles Apply the same fix to the three Dockerfiles not in the release pipeline today (alpine, dev, health_check) so they stay correct if/when they're built for arm64 in the future. Wolfi pins are not present in these files; the python:3.11-alpine and python:3.13-slim digests they already use are multi-arch indexes that include arm64/v8, so only the uv pin needed swapping. * fix(xai): fold reasoning_tokens into completion_tokens to satisfy OpenAI invariant xAI's chat completions API accounts reasoning_tokens separately from completion_tokens, but rolls them into total_tokens. This breaks the OpenAI invariant total_tokens == prompt_tokens + completion_tokens that downstream consumers (including litellm's own _usage_format_tests in tests/llm_translation/base_llm_unit_tests.py:58) rely on. Live capture (grok-3-mini-beta, 2026-05-04): prompt=14, completion=10, total=336, reasoning=312 14 + 10 = 24, NOT 336. OpenAI's o1/o3 reasoning models include reasoning_tokens in completion_tokens, leaving the prompt+completion=total invariant intact. xAI deviates. This patch aligns xAI to OpenAI semantics by folding reasoning_tokens into completion_tokens after the parent OpenAI parser runs. The fold is idempotent and defensive: - Only fires when total_tokens == prompt_tokens + completion_tokens + reasoning_tokens (the documented xAI shape). Refuses to fold if the gap doesn't match, guarding against silent corruption when xAI changes accounting. - Skips if completion_tokens already covers the gap (already normalised — e.g. cost calc replays a previously-folded Usage). xai.cost_calculator.cost_per_token already added reasoning_tokens to the visible completion count for billing. Post-fold the Usage block now satisfies that invariant directly, so the cost calc would double-bill. Updated cost_per_token to detect the OpenAI-normalised shape (total == prompt + completion) and skip the reasoning add-on in that case, falling through to the legacy raw-shape behaviour for callers that bypass the transformation (e.g. proxy log replay). Tests: - Adds TestXAIReasoningTokenFolding covering: gap-explained-fold, idempotent-no-double-fold, no-reasoning-skip, gap-mismatch-skip. - Adds test_already_normalised_usage_does_not_double_count_reasoning to lock the cost-calc idempotency. - Updates 7 pre-existing cost-calc tests whose total_tokens was internally inconsistent (used the OpenAI-normalised total but kept reasoning_tokens external) to use the documented xAI raw shape total = prompt + visible completion + reasoning. Pre-existing values masked the missing-fold by accident. Verified end-to-end against the live xAI API: LITELLM_LOCAL_MODEL_COST_MAP=False (CI default) + XAI_API_KEY set + pytest tests/llm_translation/test_xai.py::TestXAIChat::test_prompt_caching -> PASSED in 18.81s (was: AssertionError on usage.total_tokens == usage.prompt_tokens + usage.completion_tokens) 20/20 tests in tests/test_litellm/llms/xai/test_xai_cost_calculator.py and 8/8 in tests/test_litellm/llms/xai/test_xai_chat_transformation.py pass. * refactor(bedrock/converse): delegate effort gating to AnthropicConfig._validate_effort_for_model Removes the duplicated max/xhigh gating logic in _validate_anthropic_adaptive_effort and the now-unused _supports_effort_level_on_bedrock helper. Per-model gating now flows through the centralized AnthropicConfig._validate_effort_for_model (whose _supports_effort_level already strips Bedrock prefixes), so the chat completion, /v1/messages, and Bedrock Converse paths can't drift when a new gated effort tier is added. * Implement normalize_nonempty_secret_str function to trim whitespace from secrets and treat empty values as unset. Update proxy_server to use this function for Grafana credentials. Enhance tests to validate the new normalization behavior. * Fix qdrant semantic cache miss metadata * chore(deps): refresh dependency locks * chore(deps): authorize pytest license * fix: preserve tokenizer decode round trips * refactor(anthropic): drive adaptive-thinking gate via supports_adaptive_thinking flag Three of greptile's open comments on #27074 (P2 converse:512, P1 databricks:361, and the underlying capability-flag policy rule) flagged the same pattern: _is_claude_4_6_model(...) or _is_claude_4_7_model(...) used inline as a runtime 'is this an adaptive-thinking model?' check. That requires a code release each time a new adaptive Claude lands. Consolidate the inline gating to AnthropicModelInfo._is_adaptive_thinking_model, and switch the helper itself to read a new supports_adaptive_thinking flag from `model_prices_and_context_window.json` via `_supports_factory`, falling back to the family pattern only when the model-map entry doesn't carry the flag (preserves OpenRouter / Vercel / Bedrock-prefixed variants that route through the same code path with non-canonical ids). Adds `supports_adaptive_thinking: true` to the four 4.6/4.7 anthropic entries (opus-4-6 + dated, opus-4-7 + dated, sonnet-4-6). Bedrock-prefixed and Vertex-prefixed entries don't need the flag because both fall back through the family pattern (the helper short-circuits early on True from either path) and the bedrock/vertex Claude IDs all match the existing opus-4-{6,7} / sonnet-4-{6,7} pattern. Affected call sites: - `bedrock/chat/converse_transformation.py:_handle_reasoning_effort_parameter` - `anthropic/chat/transformation.py:_map_reasoning_effort` - `anthropic/chat/transformation.py:map_openai_params` (output_config branch) - `databricks/chat/transformation.py:map_openai_params` (output_config branch) The remaining `_is_claude_4_6_model` / `_is_claude_4_7_model` references in `AnthropicConfig._validate_effort_for_model` and `AnthropicConfig.get_supported_openai_params` are intentionally retained: they're per-model gating fallbacks for variants whose model-map entries don't yet carry the `supports_max_reasoning_effort` / `supports_reasoning` flag. Those are documented in-place. Tests: 537 anthropic/bedrock/databricks/vertex/messages tests pass. Co-authored-by: Mateo Wang * chore(deps): address dependency review notes * test(model_prices): add supports_adaptive_thinking to schema `test_aaamodel_prices_and_context_window_json_is_valid` validates the model-map JSON against an explicit schema with `additionalProperties`, so the new `supports_adaptive_thinking` flag added in 98ced0ae43 needs a matching schema entry. Co-authored-by: Mateo Wang * refactor: remove unnecessary comments from #27074 Strip out the explanatory and historical comments that don't carry business-logic justification. Comments that simply narrate what code does — or that explain prior behavior, what was changed, or which PR introduced a fix — are removed. Docstrings are reduced to a one-line summary where the long form repeated information already evident from the code or test data. No code-behavior changes. All 643 affected unit tests still pass. Co-authored-by: Mateo Wang * test: keep decode token test local * chore(deps): align dashboard node engine * feat: selectively apply routing strategy according to model name * style: make _model_supports_effort_param more concise * refactor(anthropic,bedrock): hoist drop_params output_config warning to module constant Three call sites (anthropic chat, bedrock converse, bedrock invoke messages) emitted the same '...Effort is only supported on Opus 4.5+, Sonnet 4.6+, and Mythos Preview' warning verbatim. Extract DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING in litellm/llms/anthropic/chat/transformation.py and import it from the bedrock sites so future copy edits live in one place. Addresses Michael's review on PR #27074. Co-authored-by: Mateo Wang * refactor(anthropic,bedrock,databricks): factor BadRequestError for unknown reasoning_effort Three call sites raised the same BadRequestError("Invalid reasoning_effort: ... Must be one of 'minimal', 'low', ...") block when REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT returned None: anthropic chat map_openai_params, bedrock converse _handle_reasoning_effort_parameter, and databricks chat reasoning_effort path. Extract AnthropicConfig._raise_invalid_reasoning_effort(model, value, llm_provider) so future copy edits / valid-set changes happen in one place. Typed as NoReturn so type-checkers correctly narrow control flow at call sites. Addresses Michael's review on PR #27074. Co-authored-by: Mateo Wang * Clean up Redis semantic cache isolation fallback * fix(guardrails): align banned_keywords + azure_content_safety call_type gates with runtime route_type The hooks gated on ``call_type == "completion"`` but the proxy ingress passes ``route_type`` straight through as ``call_type`` — ``"acompletion"`` for /v1/chat/completions and ``"aresponses"`` for /v1/responses. Tests passed because they used the literal sync ``"completion"`` value, masking the gap. Switch both hooks to ``is_text_content_call_type`` (matches the canonical runtime values: completion / acompletion / aresponses) and update existing tests to assert against runtime values, plus parametrize a regression test that pins the gate. * fix: remove unused import * Add semantic cache legacy migration flag * Treat 0 team_member_budget as no cap * chore(caching): annotate qdrant quantization_params dict type Mypy infers the dict's value type from the first branch (Dict[str, bool]) which clashes with the scalar branch's mixed-type inner dict. Explicit Dict[str, Any] annotation lifts the inference. * chore(caching): remove allow_legacy_unscoped_cache_hits opt-in The flag was an opt-in escape hatch for the cross-tenant leak the rest of the patch closes — flipping it on (env var or constructor param) re-enables exactly the VERIA-54 primitive on either backend. There is no operational need that the secure path doesn't already meet: - Qdrant: legacy points without ``litellm_cache_key`` payload are excluded by the must-clause filter and treated as misses; new sets populate the cache key, so cold-start lasts only as long as the natural cache rebuild. - Redis: existing unscoped index can't carry the new schema; the init path falls back to ``{name}_isolated`` (and recreates it on stale schema), leaving the legacy index untouched. Drop the constructor param, env-var fallback, ``_using_legacy_unscoped_index`` flag, the legacy-reuse branch in ``_init_semantic_cache``, and the matching guards in set/get paths. Update tests to drop the legacy-mode cases and assert the secure-only behaviour. * fix(container): keep ownership-filter exceptions out of the LLM-error path filter_container_list_response runs after the upstream call has already succeeded; treating an ownership-lookup failure as an LLM-API error fires post_call_failure_hook for a successful upstream call and returns a misleading provider-shaped error to the client. Run the filter outside the try/except so genuine LLM errors stay scoped to the upstream call. * chore(container,skills): LRU eviction for owner caches; widen file_purpose Literal Two cleanups from the /simplify pass: * ``_CONTAINER_OWNER_CACHE`` and ``_SKILL_CACHE`` now LRU-evict via ``OrderedDict.popitem(last=False)`` instead of full ``clear()`` at capacity. Full clears converted a steady-state cached workload into a periodic full-DB-load oscillation as the cache repopulated from zero and cleared again. Reads now ``move_to_end`` so the just-touched entry survives the next eviction. Mirrors the pre-existing LRU pattern in ``_remember_container_owner``. * ``LiteLLM_ManagedObjectTable.file_purpose`` Literal now includes ``"container"`` so Pydantic validation accepts rows written by the ownership store. * chore(container,skills): drop legacy-access opt-out env vars LITELLM_ALLOW_UNTRACKED_CONTAINER_ACCESS and LITELLM_ALLOW_UNOWNED_SKILL_ACCESS were operator-toggleable opt-outs for the cross-tenant access primitive this PR closes — flipping either on re-enabled exactly the VERIA-20 read path. Default-secure with no escape hatch matches sibling fixes (vector-store cred isolation, semantic cache key isolation, user_config strip): all rejected the opt-out-of-security pattern. Untracked containers and unowned skills (rows that pre-date this enforcement) are admin-only. Non-admin owners need to either re-create via the now-tracked flow or have an admin assign ``created_by`` on the existing row. Update tests to assert the strict-only behaviour. * fix(ownership): reject identity-less callers instead of sharing a sentinel scope UNSCOPED_RESOURCE_OWNER_SCOPE collapsed every caller without an identity field (no user_id / team_id / org_id / api_key / token) into a single shared owner — a cross-tenant access primitive: any two such callers could see and delete each other's containers and skills. Drop the sentinel. ``get_primary_resource_owner_scope`` returns ``None`` and ``get_resource_owner_scopes`` returns ``[]`` for identity-less callers. ``record_container_owner`` and ``LiteLLMSkillsHandler.create_skill`` now reject creates from identity-less callers with a 403 instead of stamping the placeholder. Read paths already deny ``owner is None`` correctly so legacy rows (if any) are admin-only. * fix(proxy): include request-blocked callback params in auth bans * fix: keep skills handler FastAPI-free; fold gcs deny list into the body bouncer Two cleanups: * ``LiteLLMSkillsHandler.create_skill`` raised ``HTTPException`` for identity-less callers, importing FastAPI from a ``litellm/llms/`` module — that violates the project rule that FastAPI lives only under ``proxy/``. Switch to ``ValueError`` (the same shape the rest of the handler uses for not-found/forbidden) and update the test. * The proxy-auth body bouncer derived its observability ban list from ``_supported_callback_params`` only, missing ``_request_blocked_callback_params`` (where ``gcs_bucket_name`` and ``gcs_path_service_account`` live). Two recently-merged sibling PRs (#27019 added the deny list, #27081 added the test asserting these are rejected at the request body root) crossed without folding them together. Union the GCS deny list into the bouncer's derivation so the single source of truth covers both code paths. * fix(proxy): normalize managed resource team owner field * chore: simplify ownership tracking — drop thin stores, in-memory fallback, hand-rolled cache Substantial reduction (~765 LOC) without changing the security boundary: * Drop ContainerOwnershipStore and LiteLLMSkillsStore — both were one-method-per-Prisma-call wrappers. Inline the calls instead, matching the established pattern in vector_store_endpoints, agent_endpoints, and mcp_server/db.py. * Drop the prisma_client is None in-memory fallback. Production deploys always have Prisma; running ownership-critical paths on a process-local dict is a security footgun in the dev-mode case it was meant to support, and complicates every code path with a branch. Fail-secure: skip recording if Prisma is unavailable, and treat reads as "not found" (admin-only). * Drop the hand-rolled module-level cache. Replace with the existing litellm.caching.in_memory_cache.InMemoryCache, which already has TTL + max-size + eviction tested in its own module. Sentinel string for negative caching since InMemoryCache can't disambiguate "miss" from "cached as None". * Tests: drop coverage for removed code paths (in-memory fallback, hand-rolled cache internals). Keep tests for actual behavior (cache hit-rate, negative caching, owner check, list filtering, identity-less reject, admin bypass). * fix(container): cache list-allow-set, track admin-created containers Address Greptile P2 follow-ups from the prior round: * Cache ``_get_allowed_container_ids`` (60s LRU/TTL keyed by sorted owner-scope tuple) so ``GET /v1/containers`` doesn't issue a fresh ``find_many`` against ``litellm_managedobjecttable`` on every list call. Invalidate the caller's own cache entry when they record a new owner so the just-created container shows up on their next list. * Tighten the admin early-return in ``record_container_owner`` to skip ONLY when there's literally no container ID to stamp. An admin with identity (the master-key path populates ``user_id`` + ``api_key``) flows through the normal record path so admin-created containers are tracked like any other caller's. The truly-identity-less admin case still falls through to the 403 below — correct fail-secure default. Skill-cache invalidation gap (also flagged by Greptile) is moot: there is no skill update endpoint exposed; ownership-affecting mutations are only delete (already invalidates) and create (new ID, no cache entry to update). * chore(container): use delete_cache, json-encode scope key, clean test /simplify follow-ups: * Replace the two-``pop`` reach into ``cache_dict``/``ttl_dict`` with the existing public ``InMemoryCache.delete_cache(key)`` — the same idiom used elsewhere in the proxy. Bonus: ``delete_cache`` calls ``_remove_key`` which also handles ``expiration_heap`` consistency the direct pops were silently leaking. * JSON-encode the sorted scope list for the cache key instead of ``"|".join``. ``user_id`` / ``team_id`` / ``org_id`` / ``api_key`` are free-form strings and could contain a literal ``|`` — JSON quoting escapes any in-string separator unambiguously. * Extract ``_allowed_container_ids_cache_key()`` so the read and invalidation sites compute the key the same way. * Fix a placeholder-then-overwrite test construction: the ``__module__.split(".")[0] and "proxy_admin"`` line evaluated to a literal string that was immediately overwritten with the real enum value. Hoist the import and construct directly. * [Fix] Tests: Replace deprecated openrouter/claude-3.7-sonnet with claude-sonnet-4.5 OpenRouter has dropped active endpoints for anthropic/claude-3.7-sonnet, causing test_reasoning_content_completion to fail with a 404 "No endpoints found" error. Switch to anthropic/claude-sonnet-4.5, which is current and supports reasoning streaming. * feat: routing groups ui * fix(security): prevent secret_fields from leaking into spend logs secret_fields (containing raw HTTP headers including Authorization Bearer tokens) was being included in proxy_server_request['body'] because the body snapshot was a copy.copy(data) of the full request dict. This body gets serialized and persisted in the LiteLLM_SpendLogs table, exposing user credentials in the database. Root cause: data['secret_fields'] was set before the body snapshot at data['proxy_server_request']['body'] = copy.copy(data), so the full raw headers (including auth tokens) ended up in the snapshot. Fix (defense in depth): 1. Exclude 'secret_fields' when creating the body snapshot in litellm_pre_call_utils.py (primary fix) 2. Strip 'secret_fields' in _sanitize_request_body_for_spend_logs_payload as a secondary safeguard secret_fields remains available on the live data dict for legitimate downstream consumers (MCP, Responses API). Co-authored-by: Krrish Dholakia * chore: update Next.js build artifacts (2026-05-05 02:13 UTC, node v20.20.2) * [Fix] Proxy: Break managed-resources import cycle on Python 3.13 The Python 3.13 CCI smoke matrix surfaces a partially-initialized-module ImportError when loading the managed files hook chain: litellm.proxy.hooks/__init__ (mid-import) -> enterprise.enterprise_hooks -> litellm_enterprise.proxy.hooks.managed_files -> litellm.llms.base_llm.managed_resources.isolation -> litellm.proxy.management_endpoints.common_utils -> litellm.proxy.utils (re-enters litellm.proxy.hooks) The except ImportError block in hooks/__init__.py silently swallowed the failure, leaving managed_files unregistered and POST /files returning 500 "Managed files hook not found". Two-layer fix: - Inline the 3-line _user_has_admin_view check in isolation.py instead of importing it from litellm.proxy.management_endpoints.common_utils. litellm.llms.* should not depend on litellm.proxy.* — removing this layering violation breaks the cycle at its root. - Define PROXY_HOOKS and get_proxy_hook before the conditional enterprise import in litellm/proxy/hooks/__init__.py, so any future re-entry resolves the public names instead of hitting an ImportError on a partially-initialized module. Also fold in two unrelated CCI repairs surfaced in the same staging run: - tests/otel_tests/test_key_logging_callbacks.py: per-key gcs_bucket_name / gcs_path_service_account are now stripped by initialize_dynamic_callback_params, so the GCS client falls through to the env-only branch. Update the assertion to match the new "GCS_BUCKET_NAME is not set" message. - .circleci/config.yml: tests/pass_through_tests now resolves google-auth-library@10.x via the @google-cloud/vertexai 1.12.0 bump, which uses dynamic ESM imports Jest 29 cannot load without --experimental-vm-modules. Pass that flag in the Vertex JS test step. Adds tests/test_litellm/proxy/hooks/test_proxy_hooks_init.py as a regression guard: managed_files / managed_vector_stores must register, and isolation.py must not transitively import litellm.proxy.utils. * [Fix] Proxy: Address Greptile feedback on hook-cycle PR - Move _user_has_admin_view to litellm.proxy._types as user_api_key_has_admin_view (single source of truth). common_utils.py and isolation.py both import from there now, removing the duplicated role-check that could silently diverge if new admin roles are added. - Add pytest.importorskip("litellm_enterprise") to the two regression tests that assert managed_files / managed_vector_stores are registered; those keys come from ENTERPRISE_PROXY_HOOKS so the tests would fail unconditionally in a checkout without the enterprise extra installed. * [Fix] Lint: Mark _user_has_admin_view re-export in common_utils Ruff F401 flagged the aliased import as unused within common_utils.py because the name is consumed only by external modules (~15 callers across guardrails, spend tracking, MCP, agents, management endpoints). Add `# noqa: F401 re-exported` so the alias survives lint while keeping a single source of truth in litellm.proxy._types. * refactor(azure): move image gen JSON helper; rename image edit finalize hook - Add image_generation/http_utils.azure_deployment_image_generation_json_body; call from azure.py (keeps AzureChatCompletion focused on chat). - Rename finalize_image_edit_multipart_data to finalize_image_edit_request_data with docstring covering multipart and JSON POST payloads (review feedback). Co-authored-by: Cursor * test(proxy): cover health_check_reasoning_effort for completion mode Co-authored-by: Cursor * [Fix] Tests: Use master key for /otel-spans in test_chat_completion_check_otel_spans /otel-spans now requires proxy admin (returns 401 'Only proxy admin can be used to generate, delete, update info for new keys/users/teams. Route=/otel-spans' for non-admin callers). Switch the GET call to use the master key sk-1234 while keeping the generated key for the chat-completion request that produces the spans. * [Fix] Tests: Pick chat-completion OTEL trace by content, not recency The /otel-spans endpoint returns process-wide spans and tags most_recent_parent by max start_time. After tightening that route to proxy_admin (sk-1234), the GET /otel-spans request itself emits auth spans that beat the chat-completion spans on start_time, so most_recent_parent now points at the request's own auth trace (['postgres', 'postgres']) and the >=5-span assertion fails. Pick the chat-completion trace by content: it is the only trace whose span list is a superset of {postgres, redis, raw_gen_ai_request, batch_write_to_db}. Verified locally end-to-end against otel_test_config.yaml + OTEL_EXPORTER=in_memory: 3/3 runs green. * [Fix] CI: Enable VCR replay for test_azure_o_series The Azure o-series tests were excluded from the conftest's VCR auto-marker because of a respx/vcrpy transport-patching conflict, but the only respx reference in the file was an unused `MockRouter` import. Drop the dead import and remove the file from the conflict set so cassettes record on first run and replay thereafter, eliminating the 60-95s live Azure latency that was crashing xdist workers under --timeout=120 thread-mode timeouts. * [Fix] Tests: Restore /metrics access for prometheus test suite /metrics now requires auth by default; tests/otel_tests/test_prometheus.py makes 4+ unauthenticated GETs against http://0.0.0.0:4000/metrics, so every prometheus test in CI now fails the metric assertion. Set require_auth_for_metrics_endpoint: false in otel_test_config.yaml to opt out for this test job, which scrapes /metrics directly. Verified locally: 8/8 prometheus tests green (one flaky retry on test_proxy_success_metrics that pre-dates this PR). Also drop the -x stop-on-first-failure flag from the otel test command so all failures in the job surface in a single CI run rather than hiding behind whichever one trips first. * [Perf] CI: Skip Redundant Playwright Apt Install in E2E UI Job The cimg/python:3.12-browsers base image already ships every Chromium system dependency Playwright needs (libnss3, libatk-bridge2.0-0, libcups2, etc. — the install log shows them all as "already the newest version"). Passing --with-deps to `npx playwright install` therefore runs an apt-get update + install for nothing, but pays the full cost of hitting Ubuntu mirrors. On a recent run those mirrors stalled hard: apt-get update alone took 6m53s at 81.5 kB/s with several archives returning connection refused. Drop --with-deps and persist ~/.cache/ms-playwright alongside node_modules so the Chromium binary is also reused across runs. Bump the cache key to v2 so the existing v1 entry (which only contained node_modules) is not loaded and skipped over the new browser path. * [Fix] Docker: Remove Hardcoded Prisma Binary Target For Multi-Arch Builds PRISMA_CLI_BINARY_TARGETS="debian-openssl-3.0.x" was hardcoded in docker/Dockerfile.non_root by #17695. On a buildx linux/arm64 leg this forces prisma to download the amd64 schema-engine into an arm64 image, so 'prisma migrate deploy' fails at startup with 'Could not find schema-engine binary'. Removing the env lets prisma auto-detect per build platform: amd64 builds still resolve to debian-openssl-3.0.x (Wolfi falls back to debian, same binary as before), and arm64 builds now correctly fetch linux-arm64-openssl-3.0.x. The offline-cache pre-warm goal of #17695 is preserved — only which binaries fill the cache changes. Fixes #19458 * [Fix] UI: Clear Admin Session Cookies Before Establishing Invited User's Session (#27227) The invite-signup form was writing the new user's token via raw `document.cookie` at `path=/`, while the rest of the auth surface uses `storeLoginToken` (which writes at `path=/ui` and mirrors to sessionStorage). After signup the inviter's `path=/ui` cookie kept winning path-specificity matching, and sessionStorage still held the inviter's token, so the dashboard rendered as the inviter rather than the newly created user. Treat invite signup as a principal-change boundary — clear prior session cookies first, then store the new token via the canonical helper. * test: add 24hr Redis-backed VCR cache to additional test suites (#27159) * test: add 24hr Redis-backed VCR cache to additional test suites Extracts the existing llm_translation VCR plumbing into a reusable helper (tests/_vcr_conftest_common.py) and wires it into the conftest.py files of the test directories listed in LIT-2787: audio_tests, batches_tests, guardrails_tests, image_gen_tests, litellm_utils_tests, local_testing, logging_callback_tests, pass_through_unit_tests, router_unit_tests, unified_google_tests The same helper is also adopted by the pre-existing llm_translation and llm_responses_api_testing conftests to remove the copy-pasted VCR setup. Each consuming conftest: - registers the Redis persister via pytest_recording_configure - auto-marks collected tests with pytest.mark.vcr (skipping respx-using files where applicable, since respx and vcrpy both patch httpx) - gates cassette writes on test success via _vcr_outcome_gate The cache is opt-in via CASSETTE_REDIS_URL; when unset, VCR is disabled and tests hit live providers as before. LITELLM_VCR_DISABLE=1 still forces a bypass for ad-hoc local runs. Test directories that run LiteLLM proxy in Docker (build_and_test, proxy_logging_guardrails_model_info_tests, proxy_store_model_in_db_tests) are intentionally not included: VCR.py patches the in-process httpx transport and cannot intercept calls made from inside a Docker container. The installing_litellm_on_python* jobs make no LLM calls and don't benefit from caching. https://linear.app/litellm-ai/issue/LIT-2787/add-24hr-caching-to-additional-test-suites * test(vcr): add safe-body matcher to handle JSONL and binary request bodies vcrpy's stock body matcher inspects Content-Type and unconditionally runs json.loads on application/json bodies. JSON Lines payloads (used by the Bedrock batch S3 PUT and other upload paths) crash that with json.JSONDecodeError: Extra data, before the matcher can return 'not a match'. This was the root cause of the batches_testing CI job failing on test_async_create_file once VCR auto-marking was applied to the batches_tests directory. Add a conservative byte-equality body matcher and use it in place of 'body' in the shared match_on tuple. The matcher is strictly more conservative than vcrpy's default — the only thing it gives up is 'different JSON key order is treated as the same body', which doesn't apply to deterministic litellm-built request payloads. It can never produce a false positive that the default would have rejected, so there is no cross-contamination risk. Co-authored-by: Mateo Wang * test(vcr): exclude tests that VCR replay actively breaks A few tests are incompatible with cassette replay and were failing on the latest CI run after VCR auto-marking was extended to local_testing and logging_callback_tests: - test_amazing_s3_logs.py (logging_callback_tests): the test asserts on a per-run response_id that should round-trip through a real S3 PUT/LIST. vcrpy's boto3 stub intercepts the PUT and the LIST replays stale keys, so the freshly-generated id is never found. - test_async_embedding_azure (logging_callback_tests) and test_amazing_sync_embedding (local_testing): the failure branches deliberately pass api_key='my-bad-key' to assert that the failure callback fires. We scrub auth headers from cassettes (so the bad-key request matches the prior good-key request), and vcrpy replays the recorded 200 — the failure callback never fires. - test_assistants.py (local_testing): the OpenAI Assistants polling APIs mint fresh thread/run IDs every recording session and then poll until status=='completed'. Replays of those polled GETs can never match a freshly-generated run id, so every CI run effectively re-records and the suite blows past the 15m no_output_timeout. Skip these from VCR auto-marking so they continue to hit live providers as they did before this change. The remaining tests in each directory still get cached. Co-authored-by: Mateo Wang * test(vcr): expand skip lists for second batch of incompatible tests Followup to the previous commit. After re-running CI on the rebuilt branch, three more tests surfaced as VCR-replay-incompatible: - litellm_utils_testing :: test_get_valid_models_from_dynamic_api_key Calls GET /v1/models with api_key='123' to assert the result is empty. We scrub auth headers, so the bad-key request matches the prior good-key cassette and replays the recorded model list. - litellm_utils_testing :: test_litellm_overhead.py Measures litellm_overhead_time_ms as a percentage of total wall-clock time. With cached responses the upstream 'network' time collapses to microseconds, blowing past the 40%% threshold the test asserts on. Skip the whole file (every parametrization is at risk). - local_testing_part1 :: test_async_custom_handler_completion and test_async_custom_handler_embedding Same bad-key failure-callback pattern as the already-skipped test_amazing_sync_embedding. - litellm_router_testing :: test_router_caching.py Asserts on litellm's own router-level response cache by comparing response1.id to response2.id across repeat upstream calls (test bypasses litellm cache via ttl=0 and expects upstream to return a *new* id). With VCR replay both upstream calls return the same cassette body, so the ids are identical. Skip the whole file. - logging_callback_tests :: test_async_chat_azure (preemptive) Same shape as already-skipped test_async_embedding_azure; was masked by upstream OpenAI rate-limit failures on baseline. Co-authored-by: Mateo Wang * test(vcr): use item.path and tighten matcher docstring - Replace pytest's deprecated item.fspath with item.path in apply_vcr_auto_marker_to_items so we don't emit deprecation warnings under pytest 8. - Clarify _safe_body_matcher docstring to reflect actual behavior (direct == first, then UTF-8 bytes comparison, no repr fallback). Addresses Greptile review feedback on PR #27159. * test(vcr): swallow all RedisError on cassette save/load Cassette persistence is strictly best-effort: any Redis-side failure (connection blip, timeout, OutOfMemoryError when the maxmemory cap is hit, READONLY replicas, etc.) should degrade to 'test passed but cassette not cached' rather than fail the test on teardown. Previously the persister only caught ConnectionError and TimeoutError, so OutOfMemoryError — which Redis Cloud raises when the cassette cache hits its memory cap and there are no evictable keys — propagated out of vcrpy's autouse fixture and ERRORed otherwise-passing tests on teardown. This caused the litellm_utils_testing CircleCI job to fail on the latest commit's run, even though the underlying test was a unit test that used mock_response and produced no real upstream traffic (the cassette was dirtied by a background langfuse callback). The rerun only succeeded because Redis evictions happened to free enough room before the SET — i.e. it was timing-dependent flakiness. Catch redis.exceptions.RedisError (the common base of all server- and client-side Redis exceptions) on both save and load, and parametrize the regression tests across ConnectionError, TimeoutError, and OutOfMemoryError to pin the new behavior. * test(vcr): surface cassette-cache failures with warnings + session banner When the persister silently swallows a Redis OOM (or any RedisError) on save/load there is otherwise no visible signal that the cache is degraded — tests pass, the cassette just isn't persisted, and the next session still hits the same Redis at the same near-cap memory. Add three layers of observability so that failure mode is loud: 1. Per-process health counters ("save_failures", "load_failures", and the last error string for each), exposed via cassette_cache_health() and reset via reset_cassette_cache_health(). The persister increments these in addition to logging. 2. VCRCassetteCacheWarning (UserWarning subclass) emitted via warnings.warn() inside the persister's except block. Pytest's built-in warnings summary at session end automatically lists every such warning, so the failure is visible in CI logs without any conftest-level wiring. 3. Session-end banner via emit_cassette_cache_session_banner() and a stderr-fallback atexit handler registered from register_persister_if_enabled(). Two states: - red "VCR CASSETTE CACHE DEGRADED" when save_failures or load_failures > 0 - yellow "VCR CASSETTE CACHE NEAR CAPACITY" (no failures, but used_memory >= 85% of maxmemory) so the next session knows the Redis is approaching OOM before any SET actually fails Capacity comes from a best-effort INFO memory probe (cassette_cache_capacity_snapshot) that returns None on any failure or when maxmemory is uncapped. The atexit handler skips xdist workers so only the controller emits. Tests: parametrize the existing save/load swallow-error tests across ConnectionError/TimeoutError/OutOfMemoryError, add direct tests for the health counters and warning emission, and a new test_vcr_conftest_common_banner.py covering banner output for every state (silent/red/yellow/disabled/xdist-worker). * test(vcr): bucket cassettes by API key fingerprint, drop bad-key skips Tests that deliberately call an LLM API with a bad key (e.g. to assert that the failure callback fires, or that check_valid_key returns False) were being silently served the prior good-key cassette: we scrub the real Authorization / x-api-key header from the cassette before storing it, so a follow-up bad-key call is byte-identical to the good-key call under the existing match_on tuple. Add a 'key_fingerprint' custom matcher that distinguishes requests by the SHA-256 of their API-key headers. The fingerprint is stamped into a synthetic 'x-litellm-key-fp' header by a new before_record_request hook, which then strips the real auth headers (we have to do the scrubbing here instead of via vcrpy's filter_headers knob, because filter_headers runs *first* and would erase the value we want to hash). Bad-key requests now get a different cassette bucket than good-key requests, so vcrpy will not replay a recorded 200 in place of the expected 401. The fingerprint is a one-way hash of the secret, so cassettes never contain the key. This permanently removes the 'bad-key' category of skips: - tests/local_testing: dropped ::test_amazing_sync_embedding, ::test_async_custom_handler_completion, ::test_async_custom_handler_embedding - tests/logging_callback_tests: dropped ::test_async_chat_azure, ::test_async_embedding_azure - tests/litellm_utils_tests: dropped ::test_get_valid_models_from_dynamic_api_key Coverage: 7 new unit tests in tests/test_litellm/test_vcr_safe_body_matcher.py covering header stripping, fingerprint determinism, no-auth bucketing, good-vs-bad key discrimination, x-api-key (Anthropic/Azure) discrimination, and idempotence under replay. Co-authored-by: Mateo Wang * test(vcr): drop redundant comments and docstrings Trim narration of code that is already self-evident from function and variable names. Keep the two genuinely non-obvious bits: - ordering constraint between filter_headers and before_record_request, which would invite a maintainer to re-introduce the bug if removed - the per-directory _VCR_INCOMPATIBLE_FILES rationale, since 'why exactly is this skipped' is not knowable from the test name alone Also drop the 40-line commented-out drop-in conftest snippet at the bottom of _vcr_conftest_common.py — the consuming conftests are the canonical reference. Co-authored-by: Mateo Wang * test(vcr): make _before_record_request idempotent vcrpy invokes before_record_request more than once per request: can_play_response_for calls it, then __contains__ / _responses (reached via play_response) call it again on the result. The second invocation sees a request whose auth headers we already stripped, so a naive recompute yields "no-key" and overwrites the real fingerprint stored in the header. This makes can_play_response_for and play_response disagree on matchability — the former says "yes, we have a stored response for this" (matching no-key to no-key) and the latter throws UnhandledHTTPRequestError because it computes a fresh real fingerprint that doesn't match the stored no-key. In CI this manifested as ~30 failing tests across guardrails_testing, audio_testing, batches_testing, image_gen_testing, llm_responses_api, litellm_router_unit_testing, etc. Skip the recompute when the header is already set, so re-applying the hook is a no-op. Adds a regression test that fires the hook twice on the same dict and asserts the fingerprint stays put. Co-authored-by: Mateo Wang * test(vcr): drop more redundant docstrings and headers * test(vcr): enable 24hr cache for ocr_tests and search_tests These two directories were the only non-dockerized test suites in the build_and_test workflow that make live LLM/provider API calls but were not VCR-enabled by this PR. Together they account for 96 tests: - tests/ocr_tests/ (31): Mistral OCR, Azure AI OCR, Azure Document Intelligence, Vertex AI OCR. Pure-unit tests inside the same files (e.g. TestAzureDocumentIntelligencePagesParam) make no HTTP calls and become benign VCR NOOPs. - tests/search_tests/ (65): Brave, DataForSEO, DuckDuckGo, Exa, Firecrawl, Google PSE, Linkup, Parallel.ai, Perplexity, SearchAPI, Searxng, Serper, Tavily. Both directories use the canonical minimal conftest pattern from tests/audio_tests/conftest.py with no skip lists. None of the test files use respx, none assert on per-call upstream non-determinism (no response1.id != response2.id, no overhead-as-fraction-of-total, no live polling), so the default match_on tuple should cache cleanly. If a flake surfaces during the first cassette-recording CI run, we can add a targeted skip the same way we did for the other dirs. Co-authored-by: Mateo Wang --------- Co-authored-by: Claude Co-authored-by: Cursor Agent Co-authored-by: Mateo Wang * [Fix] Team UI: handle legacy dict shape for metadata.guardrails (#27224) * [Fix] Team UI: handle legacy dict shape for metadata.guardrails A team can have metadata.guardrails stored as {"modify_guardrails": bool} (the permission-flag shape introduced in PR #4810) rather than the expected string[]. The opt-out logic added in PR #25575 calls .filter() on this field, which throws TypeError on a dict and crashes the team detail page. Add a safeGuardrailsList helper that returns [] when the field is not an array, and route the three read sites through it. * [Fix] Team UI: inline Array.isArray guards for guardrails metadata Replace the safeGuardrailsList helper with inline Array.isArray checks at each call site, and apply the same guard to opted_out_global_guardrails for consistency. No known legacy dict rows for opted_out_global_guardrails, but the unguarded `|| []` pattern is the same shape risk. Six call sites now defended directly: three for metadata.guardrails and three for metadata.opted_out_global_guardrails. * chore: update Next.js build artifacts (2026-05-05 22:45 UTC, node v20.20.2) (#27240) * [Infra] Bump deps (#27157) * bump: version 0.4.70 → 0.4.71 * bump: version 0.1.39 → 0.1.40 * uv lock --------- Co-authored-by: Michael Riad Zaky Co-authored-by: Mateo Wang <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: ryan-crabbe-berri Co-authored-by: user <70670632+stuxf@users.noreply.github.com> Co-authored-by: Cursor Agent Co-authored-by: Claude Co-authored-by: shivam Co-authored-by: Mateo Wang Co-authored-by: Yassin Kortam Co-authored-by: Krrish Dholakia Co-authored-by: shin-berri Co-authored-by: Sameer Kankute Co-authored-by: Sameer Kankute Co-authored-by: Michael-RZ-Berri Co-authored-by: harish-berri Co-authored-by: Yassin Kortam Co-authored-by: Michael Riad Zaky Co-authored-by: Krrish Dholakia --- .circleci/config.yml | 16 +- .../workflows/check-lazy-openapi-snapshot.yml | 75 - .github/workflows/create-release.yml | 6 +- .gitignore | 4 +- Dockerfile | 6 +- Makefile | 3 + README.md | 2 +- .../requirements.txt | 2 +- docker/Dockerfile.alpine | 2 +- docker/Dockerfile.database | 6 +- docker/Dockerfile.dev | 2 +- docker/Dockerfile.health_check | 2 +- docker/Dockerfile.non_root | 8 +- docs/my-website/docs/providers/crusoe.md | 196 ++ .../enterprise_hooks/banned_keywords.py | 26 +- .../google_text_moderation.py | 9 +- .../enterprise_hooks/openai_moderation.py | 8 +- .../enterprise_callbacks/secret_detection.py | 64 +- .../proxy/auth/custom_sso_handler.py | 54 +- .../proxy/hooks/managed_files.py | 318 ++- .../management_endpoints/project_endpoints.py | 83 +- enterprise/pyproject.toml | 6 +- litellm-js/proxy/package-lock.json | 2054 +++++++++++++++++ litellm-js/proxy/package.json | 6 +- litellm-js/spend-logs/package-lock.json | 8 +- litellm-js/spend-logs/package.json | 2 +- .../migration.sql | 20 + .../litellm_proxy_extras/schema.prisma | 16 +- litellm-proxy-extras/pyproject.toml | 6 +- litellm/__init__.py | 7 +- litellm/_logging.py | 69 +- litellm/anthropic_beta_headers_config.json | 4 +- litellm/batches/batch_utils.py | 78 +- litellm/caching/caching.py | 3 +- litellm/caching/caching_handler.py | 99 +- litellm/caching/dual_cache.py | 19 + litellm/caching/qdrant_semantic_cache.py | 194 +- litellm/caching/redis_cache.py | 10 +- litellm/caching/redis_semantic_cache.py | 172 +- litellm/constants.py | 11 +- litellm/cost_calculator.py | 6 +- litellm/files/main.py | 24 + litellm/integrations/arize/_utils.py | 42 +- .../arize/arize_phoenix_client.py | 15 +- .../arize/arize_phoenix_prompt_manager.py | 11 +- .../bitbucket/bitbucket_client.py | 25 +- .../bitbucket/bitbucket_prompt_manager.py | 11 +- litellm/integrations/custom_sso_handler.py | 11 + litellm/integrations/gcs_bucket/gcs_bucket.py | 13 +- .../gcs_bucket/gcs_bucket_base.py | 13 +- .../gitlab/gitlab_prompt_manager.py | 11 +- litellm/integrations/langfuse/langfuse.py | 43 +- .../integrations/langfuse/langfuse_handler.py | 4 +- .../langfuse/langfuse_prompt_management.py | 19 +- litellm/integrations/langsmith.py | 45 +- litellm/integrations/opentelemetry.py | 53 +- litellm/integrations/prometheus.py | 44 +- .../prometheus_helpers/prometheus_api.py | 24 +- litellm/litellm_core_utils/cli_token_utils.py | 22 +- .../cloud_storage_security.py | 175 ++ .../exception_mapping_utils.py | 21 +- .../initialize_dynamic_callback_params.py | 13 +- litellm/litellm_core_utils/litellm_logging.py | 9 +- .../litellm_core_utils/llm_request_utils.py | 6 +- .../prompt_templates/factory.py | 48 + .../litellm_core_utils/secret_redaction.py | 81 + .../litellm_core_utils/streaming_handler.py | 2 +- litellm/litellm_core_utils/url_utils.py | 168 +- .../llms/anthropic/batches/transformation.py | 4 +- litellm/llms/anthropic/chat/transformation.py | 231 +- litellm/llms/anthropic/common_utils.py | 13 +- .../adapters/handler.py | 37 +- .../adapters/transformation.py | 23 +- .../messages/transformation.py | 62 + litellm/llms/anthropic/files/handler.py | 6 +- .../llms/anthropic/files/transformation.py | 10 +- .../llms/anthropic/skills/transformation.py | 4 +- litellm/llms/azure/azure.py | 41 +- litellm/llms/azure/cost_calculation.py | 6 +- .../llms/azure/image_edit/transformation.py | 18 + .../llms/azure/image_generation/__init__.py | 2 + .../llms/azure/image_generation/http_utils.py | 17 + .../llms/azure/responses/transformation.py | 11 +- litellm/llms/azure_ai/agents/handler.py | 18 +- .../llms/azure_ai/anthropic/transformation.py | 22 +- litellm/llms/azure_ai/cost_calculator.py | 2 + .../document_intelligence/transformation.py | 23 +- litellm/llms/base_llm/chat/transformation.py | 4 +- .../base_llm/image_edit/transformation.py | 12 + .../base_managed_resource.py | 33 +- .../base_llm/managed_resources/isolation.py | 99 + .../bedrock/chat/converse_transformation.py | 139 +- .../chat/invoke_agent/transformation.py | 10 +- .../anthropic_claude3_transformation.py | 1 - .../bedrock/count_tokens/transformation.py | 3 +- litellm/llms/bedrock/files/handler.py | 74 +- litellm/llms/bedrock/files/transformation.py | 47 +- .../anthropic_claude3_transformation.py | 16 + .../bedrock/vector_stores/transformation.py | 6 +- .../black_forest_labs/image_edit/handler.py | 23 + .../image_generation/handler.py | 23 + litellm/llms/bytez/chat/transformation.py | 4 +- .../llms/cloudflare/chat/transformation.py | 14 +- .../llms/custom_httpx/container_handler.py | 4 +- litellm/llms/custom_httpx/llm_http_handler.py | 37 +- .../llms/databricks/chat/transformation.py | 30 +- .../text_to_speech/transformation.py | 6 +- litellm/llms/gemini/files/transformation.py | 20 +- .../gemini/interactions/transformation.py | 16 +- litellm/llms/hosted_vllm/embedding/README.md | 13 +- litellm/llms/litellm_proxy/skills/handler.py | 187 +- .../litellm_proxy/skills/transformation.py | 65 +- litellm/llms/manus/files/transformation.py | 10 +- .../llms/manus/responses/transformation.py | 6 +- .../llms/openai/chat/gpt_5_transformation.py | 8 +- .../llms/openai/containers/transformation.py | 22 +- litellm/llms/openai/evals/transformation.py | 22 +- .../llms/openai/responses/transformation.py | 21 +- .../vector_store_files/transformation.py | 18 +- .../openai/vector_stores/transformation.py | 6 +- litellm/llms/openai/videos/transformation.py | 34 +- litellm/llms/openai_like/providers.json | 8 + .../pg_vector/vector_stores/transformation.py | 6 +- litellm/llms/ragflow/chat/transformation.py | 6 +- .../llms/runwayml/videos/transformation.py | 16 +- litellm/llms/vertex_ai/batches/handler.py | 12 +- litellm/llms/vertex_ai/common_utils.py | 17 +- litellm/llms/vertex_ai/files/handler.py | 102 +- .../llms/vertex_ai/files/transformation.py | 496 +++- .../llms/vertex_ai/gemini/transformation.py | 42 +- .../vertex_and_google_ai_studio_gemini.py | 11 +- .../batch_embed_content_handler.py | 69 +- .../batch_embed_content_transformation.py | 183 +- .../search_api/transformation.py | 9 +- .../transformation.py | 9 +- .../anthropic/output_params_utils.py | 48 + .../anthropic/transformation.py | 7 +- .../vertex_ai/vertex_model_garden/main.py | 23 +- .../volcengine/responses/transformation.py | 21 +- litellm/llms/xai/chat/transformation.py | 36 + litellm/llms/xai/cost_calculator.py | 15 +- litellm/main.py | 13 +- ...odel_prices_and_context_window_backup.json | 566 ++++- .../mcp_server/auth/user_api_key_auth_mcp.py | 174 +- .../mcp_server/discoverable_endpoints.py | 22 +- .../mcp_server/mcp_server_manager.py | 69 +- .../proxy/_experimental/mcp_server/server.py | 89 +- litellm/proxy/_experimental/out/404.html | 2 +- .../_experimental/out/__next.__PAGE__.txt | 47 +- .../proxy/_experimental/out/__next._full.txt | 97 +- .../proxy/_experimental/out/__next._head.txt | 2 +- .../proxy/_experimental/out/__next._index.txt | 4 +- .../proxy/_experimental/out/__next._tree.txt | 4 +- .../_buildManifest.js | 0 .../_clientMiddlewareManifest.json | 0 .../_ssgManifest.js | 0 .../_next/static/chunks/0377ae18aae60c57.js | 1 + .../_next/static/chunks/038e83c8eab81a79.js | 84 - .../_next/static/chunks/03c715f5e0f1425c.js | 1 + .../_next/static/chunks/0493aafc4891dd29.js | 1 + .../_next/static/chunks/052aaa8d01e02cd3.js | 1 - .../_next/static/chunks/05d900c88781d712.js | 1 - ...83ca9892d2d63cf.js => 0606c92ecd600e0c.js} | 4 +- .../_next/static/chunks/06b2ea8c776c2e9b.js | 1 + .../_next/static/chunks/088fea506f07e1cd.js | 1 + .../_next/static/chunks/0b470ffc60999bf4.js | 1 + ...c36bfe1ba5e3ba8.js => 0c3e8651e0e97232.js} | 12 +- ...aa9f9b9bb3e054b.js => 0cdfadbcf4b8c9e4.js} | 2 +- .../_next/static/chunks/0e03d69b502b3be9.js | 1 + .../_next/static/chunks/0e6dadb6a51341b5.js | 1 - .../_next/static/chunks/0f59b35ee0664fe0.js | 7 - ...e830ceee904c386.js => 102e659fcec2585e.js} | 4 +- .../_next/static/chunks/10dc4591ef08a91f.js | 598 +++++ .../_next/static/chunks/11429586d5e74f7f.js | 1 + .../_next/static/chunks/1198c9038aaedc3a.js | 420 ++++ .../_next/static/chunks/171a03c36a999407.js | 84 + .../_next/static/chunks/17816faaae727f81.js | 3 + .../_next/static/chunks/18a9536fce05dc33.js | 1 + .../_next/static/chunks/1ab44e07f0b1cd5e.js | 1 + .../_next/static/chunks/1abad0fb1abdc83c.js | 2 + .../_next/static/chunks/1d0991370c308b4d.js | 1 - .../_next/static/chunks/1d37f4159623f97f.js | 8 - .../_next/static/chunks/1fe0596a309ad6cf.js | 12 - .../_next/static/chunks/2005c732f6d6cbb4.js | 84 - .../_next/static/chunks/23491c78faf959c9.js | 1 + .../_next/static/chunks/264fd32eefec52b6.js | 1 + .../_next/static/chunks/276409aa6cbc14db.js | 1 + .../_next/static/chunks/277cc236a763c2bc.js | 3 - .../_next/static/chunks/2975ec0f3dbe2fc7.js | 1 + ...73d847ad9c91666.js => 2a5f4a7388e54210.js} | 4 +- .../_next/static/chunks/2b682a7f2932def8.js | 11 + .../_next/static/chunks/2d8285e144d4452a.js | 1 + .../_next/static/chunks/2ea722d0a9ce35c8.js | 1 + .../_next/static/chunks/2f29909dc244a7c0.js | 10 - .../_next/static/chunks/3397155a65b7d83c.js | 1 - .../_next/static/chunks/341e7c75250f4f40.js | 598 ----- .../_next/static/chunks/34465d13a9152473.js | 1 - .../_next/static/chunks/355b9871de1cf382.js | 1 + .../_next/static/chunks/35e1b31334447d6e.js | 1 - ...38efbc0d941f9d2.js => 37e77c06e99eb8ff.js} | 2 +- .../_next/static/chunks/37e7834517e667e4.js | 1 - .../_next/static/chunks/3ac3a9a88413bb27.js | 1 - .../_next/static/chunks/3ba782adb71e77d0.js | 7 + .../_next/static/chunks/3c2d67ecf9619f2b.js | 1 + .../_next/static/chunks/3e917c79aadd945b.js | 84 + ...230559fcabaea23.js => 406bbb9c89fee7ee.js} | 2 +- .../_next/static/chunks/40ec1228b231a0d1.js | 1 - .../_next/static/chunks/44fd25e5d70e1a25.js | 1 - .../_next/static/chunks/45249a290b3ea558.js | 1 - .../_next/static/chunks/465e732e5d52ae39.js | 1 + .../_next/static/chunks/47a838c67cdd745e.js | 1 - .../_next/static/chunks/47be83d4515c6599.js | 1 - .../_next/static/chunks/496544a8be968b8b.js | 10 - .../_next/static/chunks/4a97ab1044d56ea9.js | 8 - .../_next/static/chunks/4b9bda626d5a281b.js | 10 - .../_next/static/chunks/4dfbb7412144f148.js | 7 - ...b8dcb3ad5dfb8de.js => 4e06277331e725da.js} | 12 +- .../_next/static/chunks/4e17b625d75327a7.js | 7 + .../_next/static/chunks/4f6e5b838f18b8e6.js | 10 - .../_next/static/chunks/50d8a95e62930b35.js | 1 - .../_next/static/chunks/5387bd8bd4bcf195.js | 14 + .../_next/static/chunks/54563d12ee8915f4.js | 1 + .../_next/static/chunks/570d770996d98e0f.js | 1 + .../_next/static/chunks/57a2860decebc0b6.js | 1 + .../_next/static/chunks/59e0c0c187697b37.js | 14 + .../_next/static/chunks/5a6ef256a98646ae.js | 1 - .../_next/static/chunks/5b23ca2957db2e3d.js | 8 - .../_next/static/chunks/5e34b4b8074089e6.js | 420 ++++ .../_next/static/chunks/5f2d62a75803a3f7.js | 1 + .../_next/static/chunks/5f9c3b92a016f382.js | 14 + .../_next/static/chunks/6214d842aef0673e.js | 1 + .../_next/static/chunks/623eaea02d123060.js | 7 - .../_next/static/chunks/6392214b899e5c07.js | 1 - .../_next/static/chunks/65968777d52ff874.js | 7 - .../_next/static/chunks/6665fdc6e86f173a.js | 1 - .../_next/static/chunks/673491d4036a0cfe.js | 1 + .../_next/static/chunks/679dbd657c8b5aef.js | 31 + .../_next/static/chunks/6967a3b4ecbd3785.js | 10 + .../_next/static/chunks/6ac5e2383054326d.js | 10 + ...492aee8924914ae.js => 6ba62be8e5f988a4.js} | 2 +- .../_next/static/chunks/6dc89cea942b737a.js | 8 - .../_next/static/chunks/6ec1a92c34e842cb.js | 1 + .../_next/static/chunks/7142b7d05b1b4b2e.js | 1 + .../_next/static/chunks/71f6f0fcaef91598.js | 1 + .../_next/static/chunks/72debc51022299b8.js | 1 - .../_next/static/chunks/7425e467262c0658.js | 14 + .../_next/static/chunks/74ce31aa0fb2adc9.js | 14 - .../_next/static/chunks/79080debc00288de.js | 8 - .../_next/static/chunks/7c552f88245cdd96.js | 1 + .../_next/static/chunks/7cb344c72a271ca2.js | 1 + .../_next/static/chunks/7e2dbe0d25a79405.js | 1 + .../_next/static/chunks/7e4551c11f7f1e8a.js | 1 - .../_next/static/chunks/7ede3688da5c7a5f.js | 1 - .../_next/static/chunks/7f7819822e72bcae.js | 2 + ...6b6374a992fbca0.js => 80749a6dab9b96b4.js} | 6 +- .../_next/static/chunks/8127cf0d5ad2772a.js | 1 - .../_next/static/chunks/836ef19edead05fe.js | 1 + ...faf62c238d105eb.js => 8489ea6f0be86483.js} | 2 +- ...a7c40f46cb1b417.js => 84f351822ff5289f.js} | 2 +- .../_next/static/chunks/86828bdbafb8b581.js | 1 + ...149faf92f484aca.js => 878832edb30e99a4.js} | 12 +- .../_next/static/chunks/89aa55578de861b7.js | 1 - .../_next/static/chunks/89aeafdc07090814.js | 1 + .../_next/static/chunks/8a26922c4b7235a4.js | 1 + .../_next/static/chunks/8b6eb21a51b719e1.js | 8 + .../_next/static/chunks/8c17e934bd227606.js | 231 ++ .../_next/static/chunks/8e3d0ce9505a304f.js | 1 + .../_next/static/chunks/8f3bf592254c6c3b.js | 1 + .../_next/static/chunks/90d0e7aef65b5dc7.js | 1 + .../_next/static/chunks/91037395c95e366d.css | 1 + ...abd1c9341cacb49.js => 92516c9f878f0819.js} | 2 +- ...3b50c3314123d9d.js => 928d0c629f28babb.js} | 4 +- ...908525d8a1d1a33.js => 93c3938d8d8704b3.js} | 4 +- ...c797521435cb59c.js => 94f7208f5087e27c.js} | 2 +- .../_next/static/chunks/951e5ff2dc4928c2.js | 1 - .../_next/static/chunks/95b1023fa868f012.js | 14 + .../_next/static/chunks/95bd09d7d0345fe5.js | 1 - .../_next/static/chunks/975f380f5d2c2b7d.js | 2 + .../_next/static/chunks/980f4b2cf05dae8e.js | 1 - .../_next/static/chunks/98ddd18b25554abd.js | 1 - .../_next/static/chunks/993822065369ee18.js | 14 + .../_next/static/chunks/9969d80f8608d1dc.js | 8 - ...daef8922b68e600.js => 9b0ee76cbdef1a2a.js} | 16 +- .../_next/static/chunks/9b19f9f63c383201.js | 1 - .../_next/static/chunks/9b4c8a50e297b9ad.js | 1 - .../_next/static/chunks/9b8d229c6e7826fb.js | 17 - .../_next/static/chunks/9bbebdeb3f1cb03f.js | 3 + .../_next/static/chunks/9bfe1d85217d0efc.js | 8 - .../_next/static/chunks/9cca003867a68aa9.js | 1 + .../_next/static/chunks/9ce7fbf2fad5f6f4.js | 17 - ...8170e1c551aede4.js => 9fbdf10b9cf445d9.js} | 2 +- .../_next/static/chunks/a06cc76a774dd182.js | 13 + .../_next/static/chunks/a0b3f7d6c7b4d358.js | 8 - .../_next/static/chunks/a0ce6f40daef039a.js | 1 + .../_next/static/chunks/a1abfc2f35c701cc.js | 8 - .../_next/static/chunks/a1b5b0c54192471e.js | 3 - .../_next/static/chunks/a2ba050d0179d93d.js | 420 ---- .../_next/static/chunks/a31b02ea00f8e98b.js | 1 + .../_next/static/chunks/a4949852bdd27c8e.js | 1 - .../_next/static/chunks/a5b10ff77096a982.js | 10 - .../_next/static/chunks/a5de56db893c490c.js | 8 - .../_next/static/chunks/a61a87ca92d576e9.js | 420 ---- .../_next/static/chunks/a7b074c8fcc9fd7a.js | 1 + .../_next/static/chunks/a8de8fe39e2c0fd8.js | 8 - .../_next/static/chunks/a9d351f6a8fa66f1.js | 1 - .../_next/static/chunks/aba51a6559eb06c7.js | 14 + .../_next/static/chunks/acd6db33552053fb.js | 1 - .../_next/static/chunks/adf8db17652cf9aa.js | 1 + .../_next/static/chunks/ae420624472238ad.js | 19 + .../_next/static/chunks/b01279f88358b7f5.js | 1 - .../_next/static/chunks/b12bdf0901df004a.js | 1 - .../_next/static/chunks/b368552eef8c1611.js | 1 + .../_next/static/chunks/b3d198d6c56a21b8.js | 13 + .../_next/static/chunks/b9341b4c942e3943.js | 14 + .../_next/static/chunks/b98447395b5d37ef.js | 72 + .../_next/static/chunks/baadbd26839e7b66.js | 1 + .../_next/static/chunks/bacdab4ef587dc3f.js | 1 - .../_next/static/chunks/bbe974da1fd4f044.js | 1 - .../_next/static/chunks/bde2340071127430.js | 1 + .../_next/static/chunks/be5ddb5784b2b78a.js | 10 - .../_next/static/chunks/c0b640cc12a2b90e.js | 13 - .../_next/static/chunks/c1def3f9c2ccf0b5.js | 1 - .../_next/static/chunks/c1efd92d6b02ddc9.js | 1 + .../_next/static/chunks/c2f31fa6e9a867a9.js | 1 - ...023bf9fd490e7e0.js => c3c84f2fc1b1e9db.js} | 2 +- .../_next/static/chunks/c53c9c7afec96700.js | 14 - .../_next/static/chunks/c5b9f85e6738bf6f.js | 8 - .../_next/static/chunks/c77d417e8a84d57c.js | 17 + .../_next/static/chunks/c93d5122cac84bc6.js | 14 + .../_next/static/chunks/ca93fa690ed9c42b.js | 1 + .../_next/static/chunks/cb8d72a0c642f1d3.js | 8 - ...511168aa335c4db.js => cbfd53da3104be2a.js} | 6 +- .../_next/static/chunks/cd677ff381b90c30.js | 1 - .../_next/static/chunks/ce44d74054c76c03.js | 31 + .../_next/static/chunks/cf9c81fc7166f4d4.js | 1 - ...0a1c5ed19f4bfe2.js => cfa0acae44b4288b.js} | 4 +- .../_next/static/chunks/d11611f992bddf33.js | 1 - .../_next/static/chunks/d2cd8ba8b54ac12f.js | 420 ++++ .../_next/static/chunks/d6be8091255a78cc.js | 1 - .../_next/static/chunks/d7aa89e52e3d1758.js | 1 + .../_next/static/chunks/d84d93ec5e05aece.js | 1 + .../_next/static/chunks/d8cd2d44272d51c8.js | 1 - .../_next/static/chunks/d9963e0e4e9ceea5.js | 1 + .../_next/static/chunks/da505418e8e8af34.js | 20 + .../_next/static/chunks/da87cea37abf71ef.js | 8 - .../_next/static/chunks/daaa2e6529d97969.js | 7 - .../_next/static/chunks/dae72c93f180b49f.js | 1 + .../_next/static/chunks/ddcd1fd842a79e55.js | 21 - .../_next/static/chunks/de0c9305cb137e96.js | 8 - .../_next/static/chunks/dfb7190882d30d33.js | 3 + ...a8dcdcf9803fe4f.js => e000783224957b5f.js} | 4 +- .../_next/static/chunks/e00ff4e948e36ad2.js | 1 + .../_next/static/chunks/e0371069bf08d367.js | 8 - .../_next/static/chunks/e0cb6755699177c1.css | 1 - .../_next/static/chunks/e1ddb2a5fb23f5a5.js | 1 - .../_next/static/chunks/e1f572e8226962e3.js | 72 - .../_next/static/chunks/e2e17b99dc4f7bfa.js | 1 + .../_next/static/chunks/e2f70fb83dabbe21.js | 1 + .../_next/static/chunks/e3752298bfbbee9d.js | 1 + .../_next/static/chunks/e436f7eccebb809d.js | 420 ---- .../_next/static/chunks/e55673f6717e443a.js | 7 - .../_next/static/chunks/e5af85ebd6f84f2f.js | 19 - .../_next/static/chunks/e637f1fc0218b4f2.js | 1 - .../_next/static/chunks/e77ff93ed9180690.js | 1 - .../_next/static/chunks/e7cc7b98b893b20d.js | 231 -- .../_next/static/chunks/e871b803455fadee.js | 1 - .../_next/static/chunks/e8b12a8b1fe94fe9.js | 8 - .../_next/static/chunks/ead0794ce27b66ce.js | 1 + .../_next/static/chunks/ec6c2f1c9b8d05be.js | 1 - .../_next/static/chunks/ef8798600e862605.js | 1 - .../_next/static/chunks/efc1a6ef38353eda.js | 10 - .../_next/static/chunks/f1d2e3f3196db455.js | 1 + .../_next/static/chunks/f5fc27663c2424f7.js | 1 - .../_next/static/chunks/f62432147248db5e.js | 1 - .../_next/static/chunks/f7c95eaa060d1f99.js | 3 - .../_next/static/chunks/f7e1d08418645368.js | 1 + ...c8c73d0d20d640f.js => fa36bea8808c8054.js} | 2 +- ...a91b0fa4d619698.js => fb125648f2dae104.js} | 2 +- .../_next/static/chunks/fb9deab6544b2a7a.js | 1 + .../_next/static/chunks/fba48608afe1d559.js | 1 - .../_next/static/chunks/fbe12a36d22e9554.js | 1 + .../_next/static/chunks/fd504c53206427f5.js | 1 + .../_next/static/chunks/fd61c33cefa996af.js | 1 + .../_next/static/chunks/fe5abdcdb57db543.js | 1 - .../_next/static/chunks/fef9c8b7c44b1dfc.js | 1 - .../proxy/_experimental/out/_not-found.html | 2 +- .../proxy/_experimental/out/_not-found.txt | 4 +- .../out/_not-found/__next._full.txt | 4 +- .../out/_not-found/__next._head.txt | 2 +- .../out/_not-found/__next._index.txt | 4 +- .../_not-found/__next._not-found.__PAGE__.txt | 2 +- .../out/_not-found/__next._not-found.txt | 2 +- .../out/_not-found/__next._tree.txt | 4 +- .../_experimental/out/api-reference.html | 2 +- .../proxy/_experimental/out/api-reference.txt | 12 +- ...KGRhc2hib2FyZCk.api-reference.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.api-reference.txt | 2 +- .../api-reference/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/api-reference/__next._full.txt | 12 +- .../out/api-reference/__next._head.txt | 2 +- .../out/api-reference/__next._index.txt | 4 +- .../out/api-reference/__next._tree.txt | 4 +- .../_experimental/out/assets/logos/qohash.jpg | Bin 0 -> 11581 bytes .../out/assets/logos/xecguard.svg | 4 + litellm/proxy/_experimental/out/chat.html | 1 + litellm/proxy/_experimental/out/chat.txt | 22 + .../_experimental/out/chat/__next._full.txt | 22 + .../_experimental/out/chat/__next._head.txt | 6 + .../_experimental/out/chat/__next._index.txt | 8 + .../_experimental/out/chat/__next._tree.txt | 4 + .../out/chat/__next.chat.__PAGE__.txt | 9 + .../_experimental/out/chat/__next.chat.txt | 4 + .../out/experimental/api-playground.html | 2 +- .../out/experimental/api-playground.txt | 10 +- ...k.experimental.api-playground.__PAGE__.txt | 4 +- ...2hib2FyZCk.experimental.api-playground.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../api-playground/__next._full.txt | 10 +- .../api-playground/__next._head.txt | 2 +- .../api-playground/__next._index.txt | 4 +- .../api-playground/__next._tree.txt | 4 +- .../out/experimental/budgets.html | 2 +- .../out/experimental/budgets.txt | 12 +- ...ib2FyZCk.experimental.budgets.__PAGE__.txt | 4 +- ....!KGRhc2hib2FyZCk.experimental.budgets.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../budgets/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/experimental/budgets/__next._full.txt | 12 +- .../out/experimental/budgets/__next._head.txt | 2 +- .../experimental/budgets/__next._index.txt | 4 +- .../out/experimental/budgets/__next._tree.txt | 4 +- .../out/experimental/caching.html | 2 +- .../out/experimental/caching.txt | 10 +- ...ib2FyZCk.experimental.caching.__PAGE__.txt | 4 +- ....!KGRhc2hib2FyZCk.experimental.caching.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../caching/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/experimental/caching/__next._full.txt | 10 +- .../out/experimental/caching/__next._head.txt | 2 +- .../experimental/caching/__next._index.txt | 4 +- .../out/experimental/caching/__next._tree.txt | 4 +- .../out/experimental/claude-code-plugins.html | 2 +- .../out/experimental/claude-code-plugins.txt | 10 +- ...erimental.claude-code-plugins.__PAGE__.txt | 4 +- ...FyZCk.experimental.claude-code-plugins.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../claude-code-plugins/__next._full.txt | 10 +- .../claude-code-plugins/__next._head.txt | 2 +- .../claude-code-plugins/__next._index.txt | 4 +- .../claude-code-plugins/__next._tree.txt | 4 +- .../out/experimental/old-usage.html | 2 +- .../out/experimental/old-usage.txt | 12 +- ...2FyZCk.experimental.old-usage.__PAGE__.txt | 4 +- ...KGRhc2hib2FyZCk.experimental.old-usage.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../old-usage/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../experimental/old-usage/__next._full.txt | 12 +- .../experimental/old-usage/__next._head.txt | 2 +- .../experimental/old-usage/__next._index.txt | 4 +- .../experimental/old-usage/__next._tree.txt | 4 +- .../out/experimental/prompts.html | 2 +- .../out/experimental/prompts.txt | 12 +- ...ib2FyZCk.experimental.prompts.__PAGE__.txt | 4 +- ....!KGRhc2hib2FyZCk.experimental.prompts.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../prompts/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/experimental/prompts/__next._full.txt | 12 +- .../out/experimental/prompts/__next._head.txt | 2 +- .../experimental/prompts/__next._index.txt | 4 +- .../out/experimental/prompts/__next._tree.txt | 4 +- .../out/experimental/tag-management.html | 2 +- .../out/experimental/tag-management.txt | 12 +- ...k.experimental.tag-management.__PAGE__.txt | 4 +- ...2hib2FyZCk.experimental.tag-management.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.experimental.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../tag-management/__next._full.txt | 12 +- .../tag-management/__next._head.txt | 2 +- .../tag-management/__next._index.txt | 4 +- .../tag-management/__next._tree.txt | 4 +- .../proxy/_experimental/out/guardrails.html | 2 +- .../proxy/_experimental/out/guardrails.txt | 37 +- ...t.!KGRhc2hib2FyZCk.guardrails.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.guardrails.txt | 2 +- .../guardrails/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/guardrails/__next._full.txt | 37 +- .../out/guardrails/__next._head.txt | 2 +- .../out/guardrails/__next._index.txt | 4 +- .../out/guardrails/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/index.html | 2 +- litellm/proxy/_experimental/out/index.txt | 97 +- litellm/proxy/_experimental/out/login.html | 2 +- litellm/proxy/_experimental/out/login.txt | 6 +- .../_experimental/out/login/__next._full.txt | 6 +- .../_experimental/out/login/__next._head.txt | 2 +- .../_experimental/out/login/__next._index.txt | 4 +- .../_experimental/out/login/__next._tree.txt | 4 +- .../out/login/__next.login.__PAGE__.txt | 4 +- .../_experimental/out/login/__next.login.txt | 2 +- litellm/proxy/_experimental/out/logs.html | 2 +- litellm/proxy/_experimental/out/logs.txt | 37 +- .../__next.!KGRhc2hib2FyZCk.logs.__PAGE__.txt | 4 +- .../out/logs/__next.!KGRhc2hib2FyZCk.logs.txt | 2 +- .../out/logs/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../_experimental/out/logs/__next._full.txt | 37 +- .../_experimental/out/logs/__next._head.txt | 2 +- .../_experimental/out/logs/__next._index.txt | 4 +- .../_experimental/out/logs/__next._tree.txt | 4 +- .../_experimental/out/mcp/oauth/callback.html | 2 +- .../_experimental/out/mcp/oauth/callback.txt | 4 +- .../out/mcp/oauth/callback/__next._full.txt | 4 +- .../out/mcp/oauth/callback/__next._head.txt | 2 +- .../out/mcp/oauth/callback/__next._index.txt | 4 +- .../out/mcp/oauth/callback/__next._tree.txt | 4 +- .../__next.mcp.oauth.callback.__PAGE__.txt | 2 +- .../callback/__next.mcp.oauth.callback.txt | 2 +- .../mcp/oauth/callback/__next.mcp.oauth.txt | 2 +- .../out/mcp/oauth/callback/__next.mcp.txt | 2 +- .../proxy/_experimental/out/model-hub.html | 2 +- litellm/proxy/_experimental/out/model-hub.txt | 37 +- ...xt.!KGRhc2hib2FyZCk.model-hub.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.model-hub.txt | 2 +- .../out/model-hub/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/model-hub/__next._full.txt | 37 +- .../out/model-hub/__next._head.txt | 2 +- .../out/model-hub/__next._index.txt | 4 +- .../out/model-hub/__next._tree.txt | 4 +- .../proxy/_experimental/out/model_hub.html | 2 +- litellm/proxy/_experimental/out/model_hub.txt | 6 +- .../out/model_hub/__next._full.txt | 6 +- .../out/model_hub/__next._head.txt | 2 +- .../out/model_hub/__next._index.txt | 4 +- .../out/model_hub/__next._tree.txt | 4 +- .../model_hub/__next.model_hub.__PAGE__.txt | 4 +- .../out/model_hub/__next.model_hub.txt | 2 +- .../_experimental/out/model_hub_table.html | 2 +- .../_experimental/out/model_hub_table.txt | 33 +- .../out/model_hub_table/__next._full.txt | 33 +- .../out/model_hub_table/__next._head.txt | 2 +- .../out/model_hub_table/__next._index.txt | 4 +- .../out/model_hub_table/__next._tree.txt | 4 +- .../__next.model_hub_table.__PAGE__.txt | 4 +- .../__next.model_hub_table.txt | 2 +- .../out/models-and-endpoints.html | 2 +- .../out/models-and-endpoints.txt | 12 +- ...ib2FyZCk.models-and-endpoints.__PAGE__.txt | 4 +- ....!KGRhc2hib2FyZCk.models-and-endpoints.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/models-and-endpoints/__next._full.txt | 12 +- .../out/models-and-endpoints/__next._head.txt | 2 +- .../models-and-endpoints/__next._index.txt | 4 +- .../out/models-and-endpoints/__next._tree.txt | 4 +- .../proxy/_experimental/out/onboarding.html | 2 +- .../proxy/_experimental/out/onboarding.txt | 6 +- .../out/onboarding/__next._full.txt | 6 +- .../out/onboarding/__next._head.txt | 2 +- .../out/onboarding/__next._index.txt | 4 +- .../out/onboarding/__next._tree.txt | 4 +- .../onboarding/__next.onboarding.__PAGE__.txt | 4 +- .../out/onboarding/__next.onboarding.txt | 2 +- .../_experimental/out/organizations.html | 2 +- .../proxy/_experimental/out/organizations.txt | 12 +- ...KGRhc2hib2FyZCk.organizations.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.organizations.txt | 2 +- .../organizations/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/organizations/__next._full.txt | 12 +- .../out/organizations/__next._head.txt | 2 +- .../out/organizations/__next._index.txt | 4 +- .../out/organizations/__next._tree.txt | 4 +- .../proxy/_experimental/out/playground.html | 2 +- .../proxy/_experimental/out/playground.txt | 37 +- ...t.!KGRhc2hib2FyZCk.playground.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.playground.txt | 2 +- .../playground/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/playground/__next._full.txt | 37 +- .../out/playground/__next._head.txt | 2 +- .../out/playground/__next._index.txt | 4 +- .../out/playground/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/policies.html | 2 +- litellm/proxy/_experimental/out/policies.txt | 37 +- ...ext.!KGRhc2hib2FyZCk.policies.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.policies.txt | 2 +- .../out/policies/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/policies/__next._full.txt | 37 +- .../out/policies/__next._head.txt | 2 +- .../out/policies/__next._index.txt | 4 +- .../out/policies/__next._tree.txt | 4 +- .../out/settings/admin-settings.html | 2 +- .../out/settings/admin-settings.txt | 12 +- ...FyZCk.settings.admin-settings.__PAGE__.txt | 4 +- ...GRhc2hib2FyZCk.settings.admin-settings.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.settings.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../settings/admin-settings/__next._full.txt | 12 +- .../settings/admin-settings/__next._head.txt | 2 +- .../settings/admin-settings/__next._index.txt | 4 +- .../settings/admin-settings/__next._tree.txt | 4 +- .../out/settings/logging-and-alerts.html | 2 +- .../out/settings/logging-and-alerts.txt | 12 +- ...k.settings.logging-and-alerts.__PAGE__.txt | 4 +- ...2hib2FyZCk.settings.logging-and-alerts.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.settings.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../logging-and-alerts/__next._full.txt | 12 +- .../logging-and-alerts/__next._head.txt | 2 +- .../logging-and-alerts/__next._index.txt | 4 +- .../logging-and-alerts/__next._tree.txt | 4 +- .../out/settings/router-settings.html | 2 +- .../out/settings/router-settings.txt | 12 +- ...yZCk.settings.router-settings.__PAGE__.txt | 4 +- ...Rhc2hib2FyZCk.settings.router-settings.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.settings.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.txt | 4 +- .../settings/router-settings/__next._full.txt | 12 +- .../settings/router-settings/__next._head.txt | 2 +- .../router-settings/__next._index.txt | 4 +- .../settings/router-settings/__next._tree.txt | 4 +- .../_experimental/out/settings/ui-theme.html | 2 +- .../_experimental/out/settings/ui-theme.txt | 10 +- .../__next.!KGRhc2hib2FyZCk.settings.txt | 2 +- ...c2hib2FyZCk.settings.ui-theme.__PAGE__.txt | 4 +- ...ext.!KGRhc2hib2FyZCk.settings.ui-theme.txt | 2 +- .../ui-theme/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/settings/ui-theme/__next._full.txt | 10 +- .../out/settings/ui-theme/__next._head.txt | 2 +- .../out/settings/ui-theme/__next._index.txt | 4 +- .../out/settings/ui-theme/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/skills.html | 2 +- litellm/proxy/_experimental/out/skills.txt | 37 +- ..._next.!KGRhc2hib2FyZCk.skills.__PAGE__.txt | 4 +- .../skills/__next.!KGRhc2hib2FyZCk.skills.txt | 2 +- .../out/skills/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../_experimental/out/skills/__next._full.txt | 37 +- .../_experimental/out/skills/__next._head.txt | 2 +- .../out/skills/__next._index.txt | 4 +- .../_experimental/out/skills/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/teams.html | 2 +- litellm/proxy/_experimental/out/teams.txt | 37 +- ...__next.!KGRhc2hib2FyZCk.teams.__PAGE__.txt | 4 +- .../teams/__next.!KGRhc2hib2FyZCk.teams.txt | 2 +- .../out/teams/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../_experimental/out/teams/__next._full.txt | 37 +- .../_experimental/out/teams/__next._head.txt | 2 +- .../_experimental/out/teams/__next._index.txt | 4 +- .../_experimental/out/teams/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/test-key.html | 2 +- litellm/proxy/_experimental/out/test-key.txt | 37 +- ...ext.!KGRhc2hib2FyZCk.test-key.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.test-key.txt | 2 +- .../out/test-key/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/test-key/__next._full.txt | 37 +- .../out/test-key/__next._head.txt | 2 +- .../out/test-key/__next._index.txt | 4 +- .../out/test-key/__next._tree.txt | 4 +- .../_experimental/out/tools/mcp-servers.html | 2 +- .../_experimental/out/tools/mcp-servers.txt | 12 +- ...c2hib2FyZCk.tools.mcp-servers.__PAGE__.txt | 4 +- ...ext.!KGRhc2hib2FyZCk.tools.mcp-servers.txt | 2 +- .../__next.!KGRhc2hib2FyZCk.tools.txt | 2 +- .../mcp-servers/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/tools/mcp-servers/__next._full.txt | 12 +- .../out/tools/mcp-servers/__next._head.txt | 2 +- .../out/tools/mcp-servers/__next._index.txt | 4 +- .../out/tools/mcp-servers/__next._tree.txt | 4 +- .../out/tools/vector-stores.html | 2 +- .../_experimental/out/tools/vector-stores.txt | 12 +- .../__next.!KGRhc2hib2FyZCk.tools.txt | 2 +- ...hib2FyZCk.tools.vector-stores.__PAGE__.txt | 4 +- ...t.!KGRhc2hib2FyZCk.tools.vector-stores.txt | 2 +- .../vector-stores/__next.!KGRhc2hib2FyZCk.txt | 4 +- .../out/tools/vector-stores/__next._full.txt | 12 +- .../out/tools/vector-stores/__next._head.txt | 2 +- .../out/tools/vector-stores/__next._index.txt | 4 +- .../out/tools/vector-stores/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/usage.html | 2 +- litellm/proxy/_experimental/out/usage.txt | 37 +- .../out/usage/__next.!KGRhc2hib2FyZCk.txt | 4 +- ...__next.!KGRhc2hib2FyZCk.usage.__PAGE__.txt | 4 +- .../usage/__next.!KGRhc2hib2FyZCk.usage.txt | 2 +- .../_experimental/out/usage/__next._full.txt | 37 +- .../_experimental/out/usage/__next._head.txt | 2 +- .../_experimental/out/usage/__next._index.txt | 4 +- .../_experimental/out/usage/__next._tree.txt | 4 +- litellm/proxy/_experimental/out/users.html | 2 +- litellm/proxy/_experimental/out/users.txt | 37 +- .../out/users/__next.!KGRhc2hib2FyZCk.txt | 4 +- ...__next.!KGRhc2hib2FyZCk.users.__PAGE__.txt | 4 +- .../users/__next.!KGRhc2hib2FyZCk.users.txt | 2 +- .../_experimental/out/users/__next._full.txt | 37 +- .../_experimental/out/users/__next._head.txt | 2 +- .../_experimental/out/users/__next._index.txt | 4 +- .../_experimental/out/users/__next._tree.txt | 4 +- .../proxy/_experimental/out/virtual-keys.html | 2 +- .../proxy/_experimental/out/virtual-keys.txt | 37 +- .../virtual-keys/__next.!KGRhc2hib2FyZCk.txt | 4 +- ...!KGRhc2hib2FyZCk.virtual-keys.__PAGE__.txt | 4 +- .../__next.!KGRhc2hib2FyZCk.virtual-keys.txt | 2 +- .../out/virtual-keys/__next._full.txt | 37 +- .../out/virtual-keys/__next._head.txt | 2 +- .../out/virtual-keys/__next._index.txt | 4 +- .../out/virtual-keys/__next._tree.txt | 4 +- litellm/proxy/_lazy_openapi_snapshot.json | 94 +- litellm/proxy/_lazy_openapi_snapshot.py | 78 +- litellm/proxy/_types.py | 117 +- litellm/proxy/agent_endpoints/endpoints.py | 60 +- litellm/proxy/auth/auth_checks.py | 477 ++-- litellm/proxy/auth/auth_utils.py | 518 ++++- litellm/proxy/auth/handle_jwt.py | 77 +- litellm/proxy/auth/ip_address_utils.py | 59 + litellm/proxy/auth/oauth2_proxy_hook.py | 92 +- litellm/proxy/auth/route_checks.py | 187 +- litellm/proxy/auth/trusted_proxy_utils.py | 118 + litellm/proxy/auth/user_api_key_auth.py | 355 ++- litellm/proxy/client/cli/commands/auth.py | 16 +- litellm/proxy/client/cli/main.py | 5 +- litellm/proxy/client/client.py | 11 +- litellm/proxy/common_request_processing.py | 70 + .../proxy/common_utils/cache_coordinator.py | 25 +- .../common_utils/cache_pydantic_utils.py | 93 + litellm/proxy/common_utils/debug_utils.py | 17 +- .../expired_ui_session_key_cleanup_manager.py | 4 +- .../proxy/common_utils/resource_ownership.py | 92 + .../proxy/common_utils/user_api_key_cache.py | 162 ++ .../proxy/container_endpoints/endpoints.py | 74 +- .../container_endpoints/handler_factory.py | 161 +- .../proxy/container_endpoints/ownership.py | 334 +++ litellm/proxy/db/db_spend_update_writer.py | 72 +- litellm/proxy/db/spend_counter_reseed.py | 183 +- .../example_config_yaml/otel_test_config.yaml | 3 + litellm/proxy/guardrails/_content_utils.py | 236 ++ .../proxy/guardrails/guardrail_endpoints.py | 6 +- .../guardrails/guardrail_hooks/aim/aim.py | 68 +- .../guardrail_hooks/azure/text_moderation.py | 32 +- .../ibm_guardrails/ibm_detector.py | 173 +- .../guardrail_hooks/lakera_ai_v2.py | 69 +- .../guardrails/guardrail_hooks/lasso/lasso.py | 25 +- .../litellm_content_filter/content_filter.py | 145 +- .../guardrails/guardrail_hooks/presidio.py | 28 +- .../guardrail_hooks/qohash/__init__.py | 35 + .../guardrail_hooks/qohash/qohash.py | 81 + .../semantic_guard/semantic_guard.py | 25 +- .../guardrail_hooks/tool_permission.py | 180 +- .../guardrail_hooks/xecguard/xecguard.py | 31 +- litellm/proxy/health_check.py | 15 + .../health_endpoints/_health_endpoints.py | 293 ++- litellm/proxy/hooks/__init__.py | 30 +- litellm/proxy/hooks/azure_content_safety.py | 27 +- litellm/proxy/hooks/batch_rate_limiter.py | 165 +- .../proxy/hooks/dynamic_rate_limiter_v3.py | 182 +- litellm/proxy/hooks/litellm_skills/main.py | 14 +- litellm/proxy/hooks/max_budget_limiter.py | 17 +- .../hooks/parallel_request_limiter_v3.py | 382 +++ .../proxy/hooks/proxy_track_cost_callback.py | 301 ++- litellm/proxy/litellm_pre_call_utils.py | 130 +- .../access_group_endpoints.py | 35 +- .../budget_management_endpoints.py | 5 +- .../cache_settings_endpoints.py | 123 +- .../management_endpoints/common_utils.py | 34 +- .../config_override_endpoints.py | 146 +- .../internal_user_endpoints.py | 46 +- .../jwt_key_mapping_endpoints.py | 7 +- .../key_management_endpoints.py | 140 +- .../mcp_management_endpoints.py | 50 +- .../organization_endpoints.py | 44 + .../router_settings_endpoints.py | 11 +- .../scim/scim_transformations.py | 6 +- .../management_endpoints/scim/scim_v2.py | 163 +- .../team_callback_endpoints.py | 50 +- .../management_endpoints/team_endpoints.py | 30 +- litellm/proxy/management_endpoints/ui_sso.py | 88 +- .../usage_endpoints/ai_usage_chat.py | 9 + .../usage_endpoints/endpoints.py | 6 +- .../team_member_permission_checks.py | 4 +- .../middleware/prometheus_auth_middleware.py | 60 +- .../openai_files_endpoints/common_utils.py | 8 + .../openai_files_endpoints/files_endpoints.py | 3 + .../llm_passthrough_endpoints.py | 27 +- .../assembly_passthrough_logging_handler.py | 11 +- .../pass_through_endpoints.py | 12 +- .../policy_engine/attachment_registry.py | 1 + .../proxy/policy_engine/policy_registry.py | 1 + litellm/proxy/proxy_server.py | 1046 ++++++--- .../public_endpoints/public_endpoints.py | 11 +- litellm/proxy/rag_endpoints/endpoints.py | 93 + litellm/proxy/route_llm_request.py | 19 + litellm/proxy/schema.prisma | 16 +- .../spend_tracking/budget_reservation.py | 1029 +++++++++ .../spend_tracking/cloudzero_endpoints.py | 7 +- .../spend_tracking/spend_log_error_logger.py | 85 + .../spend_management_endpoints.py | 6 +- .../spend_tracking/spend_tracking_utils.py | 17 +- .../proxy/spend_tracking/vantage_endpoints.py | 6 +- .../proxy_setting_endpoints.py | 7 + litellm/proxy/utils.py | 18 +- .../proxy/vector_store_endpoints/endpoints.py | 99 +- .../management_endpoints.py | 92 +- litellm/proxy/vector_store_endpoints/utils.py | 115 + .../vector_store_files_endpoints/endpoints.py | 100 +- .../vertex_ai_endpoints/langfuse_endpoints.py | 154 +- litellm/responses/streaming_iterator.py | 739 ++++-- litellm/router.py | 892 ++++--- litellm/router_strategy/tag_based_routing.py | 3 +- litellm/router_utils/common_utils.py | 27 +- litellm/secret_managers/main.py | 13 + litellm/skills/main.py | 29 +- litellm/types/guardrails.py | 5 + litellm/types/llms/anthropic.py | 1 + litellm/types/llms/bedrock.py | 1 + litellm/types/llms/openai.py | 5 +- litellm/types/llms/vertex_ai.py | 7 + .../router_settings_endpoints.py | 8 + .../guardrails/guardrail_hooks/qohash.py | 16 + litellm/types/router.py | 15 + litellm/types/utils.py | 1 + litellm/utils.py | 45 +- litellm/vector_stores/main.py | 8 +- model_prices_and_context_window.json | 223 +- package-lock.json | 172 +- package.json | 5 +- provider_endpoints_support.json | 18 + pyproject.toml | 22 +- schema.prisma | 16 +- tests/_flush_vcr_cache.py | 44 + tests/_vcr_conftest_common.py | 443 ++++ tests/_vcr_redis_persister.py | 265 +++ tests/audio_tests/conftest.py | 50 + tests/batches_tests/conftest.py | 48 +- .../test_openai_batches_and_files.py | 2 + tests/code_coverage_tests/liccheck.ini | 2 + .../test_prometheus_logging_callbacks.py | 90 +- tests/guardrails_tests/conftest.py | 42 + tests/guardrails_tests/test_semantic_guard.py | 19 + tests/image_gen_tests/conftest.py | 50 +- .../request_payloads/azure_gpt_image_1.json | 1 - tests/image_gen_tests/test_image_edits.py | 11 +- .../image_gen_tests/test_image_generation.py | 1 + tests/litellm/llms/azure/__init__.py | 0 .../llms/azure/test_azure_embedding.py | 94 + .../test_model_based_routing_files_batches.py | 39 + tests/litellm_utils_tests/conftest.py | 65 +- .../test_anthropic_token_counter.py | 2 +- .../test_bedrock_token_counter.py | 8 +- tests/llm_responses_api_testing/conftest.py | 54 +- .../test_anthropic_responses_api.py | 4 +- .../test_responses_hooks.py | 894 ++++++- tests/llm_translation/Readme.md | 68 +- tests/llm_translation/base_llm_unit_tests.py | 2 +- tests/llm_translation/conftest.py | 81 +- .../test_anthropic_completion.py | 39 + tests/llm_translation/test_azure_o_series.py | 1 - tests/llm_translation/test_cloudflare.py | 81 + tests/llm_translation/test_crusoe.py | 108 + tests/llm_translation/test_gemini.py | 156 +- .../test_vcr_conftest_common_banner.py | 181 ++ .../test_vcr_redis_persister.py | 424 ++++ tests/local_testing/conftest.py | 72 + tests/local_testing/test_caching_handler.py | 389 +++- tests/local_testing/test_embedding.py | 30 +- tests/local_testing/test_function_calling.py | 2 +- tests/local_testing/test_get_llm_provider.py | 1 + .../test_responses_stream_cache_keys.py | 141 ++ tests/local_testing/test_router_debug_logs.py | 4 + tests/local_testing/test_streaming.py | 6 +- tests/logging_callback_tests/conftest.py | 67 + .../test_langfuse_dynamic_credentials.py | 129 ++ .../test_langsmith_dynamic_credentials.py | 50 + tests/ocr_tests/conftest.py | 57 + .../otel_tests/test_key_logging_callbacks.py | 2 +- tests/otel_tests/test_otel.py | 25 +- .../base_anthropic_messages_test.py | 4 +- tests/pass_through_tests/package-lock.json | 368 ++- tests/pass_through_tests/package.json | 9 +- .../test_anthropic_passthrough.py | 2 +- tests/pass_through_unit_tests/conftest.py | 50 + .../test_assemblyai_unit_tests_passthrough.py | 59 + .../ui_unit_tests/package-lock.json | 122 +- .../ui_unit_tests/package.json | 7 +- tests/proxy_unit_tests/test_auth_checks.py | 328 ++- tests/proxy_unit_tests/test_proxy_server.py | 47 +- .../test_user_api_key_auth.py | 7 +- tests/router_unit_tests/conftest.py | 51 +- .../test_router_endpoints.py | 111 +- tests/search_tests/conftest.py | 58 + .../test_spend_accuracy_tests.py | 6 +- tests/test_health.py | 21 +- tests/test_litellm/caching/test_dual_cache.py | 70 + .../caching/test_qdrant_semantic_cache.py | 256 +- .../caching/test_redis_semantic_cache.py | 401 +++- .../test_azure_container_transformation.py | 256 +- .../containers/test_container_handler_url.py | 28 + .../test_container_proxy_ownership.py | 915 ++++++++ .../test_container_transformation.py | 17 + .../proxy/test_managed_files_access_check.py | 69 +- .../integrations/arize/test_arize_phoenix.py | 52 + .../integrations/arize/test_arize_utils.py | 85 + .../bitbucket/test_bitbucket_integration.py | 43 + .../gcs_bucket/test_gcs_bucket_base.py | 44 +- .../integrations/test_langsmith_init.py | 84 + .../integrations/test_opentelemetry.py | 183 ++ .../test_prometheus_api_promql_escape.py | 150 ++ .../integrations/test_prompt_manager_ssti.py | 125 + ...test_gemini_interactions_transformation.py | 15 + .../llm_cost_calc/test_llm_cost_calc_utils.py | 40 + ...llm_core_utils_prompt_templates_factory.py | 242 +- .../test_decode_special_tokens.py | 37 + ...test_initialize_dynamic_callback_params.py | 19 +- .../test_streaming_handler.py | 33 + .../litellm_core_utils/test_url_utils.py | 143 +- .../llms/anthropic/chat/conftest.py | 23 + .../test_anthropic_chat_transformation.py | 297 ++- .../test_handler_output_config_passthrough.py | 232 ++ .../test_reasoning_effort_translation.py | 193 ++ .../test_anthropic_files_transformation.py | 21 + .../test_azure_image_edit_transformation.py | 51 + .../test_azure_image_generation_init.py | 177 +- .../response/test_azure_transformation.py | 22 + .../llms/azure/test_azure_cost_calculation.py | 75 + .../test_azure_anthropic_transformation.py | 94 + .../azure_ai/test_azure_ai_agents_handler.py | 57 + .../azure_ai/test_azure_ai_cost_calculator.py | 48 + ...ocument_intelligence_ocr_transformation.py | 33 + .../base_llm/test_base_managed_resource.py | 131 ++ .../test_managed_resource_isolation.py | 156 ++ ...ations_anthropic_claude3_transformation.py | 19 +- .../chat/test_converse_transformation.py | 178 ++ ...est_bedrock_count_tokens_transformation.py | 21 + .../files/test_bedrock_files_handler.py | 206 ++ .../test_bedrock_files_transformation.py | 66 +- .../test_bedrock_agent_transformation.py | 37 +- .../test_anthropic_claude3_transformation.py | 259 ++- ...est_bedrock_vector_store_transformation.py | 22 + .../chat/test_bytez_chat_transformation.py | 23 + .../test_cloudflare_transformation.py | 27 + tests/test_litellm/llms/crusoe/__init__.py | 0 tests/test_litellm/llms/crusoe/test_crusoe.py | 135 ++ ...levenlabs_text_to_speech_transformation.py | 33 + .../files/test_gemini_files_transformation.py | 48 +- .../litellm_proxy/test_skills_ownership.py | 516 +++++ .../test_manus_responses_transformation.py | 15 + .../evals/test_openai_evals_transformation.py | 28 + .../test_openai_responses_transformation.py | 25 +- .../llms/openai/test_gpt5_transformation.py | 75 + ...penai_vector_store_files_transformation.py | 31 + ...est_openai_vector_stores_transformation.py | 18 + .../test_openai_video_transformation.py | 70 + .../test_pg_vector_transformation.py | 18 + .../chat/test_ragflow_chat_transformation.py | 18 + .../test_runway_video_transformation.py | 15 + .../llms/test_polling_url_origin_match.py | 177 ++ .../files/test_vertex_ai_files_handler.py | 126 +- .../test_vertex_ai_files_transformation.py | 999 +++++++- .../test_vertex_ai_gemini_transformation.py | 117 + .../vertex_ai/gemini_embeddings/__init__.py | 0 ...test_batch_embed_content_transformation.py | 290 +++ .../test_vertex_ai_batch_transformation.py | 45 + .../vertex_ai/test_vertex_ai_common_utils.py | 12 + ...x_ai_search_vector_store_transformation.py | 40 + .../test_vertex_model_garden_openapi.py | 41 + ...partner_models_anthropic_transformation.py | 235 +- ...est_volcengine_responses_transformation.py | 17 + .../llms/xai/test_xai_chat_transformation.py | 121 + .../llms/xai/test_xai_cost_calculator.py | 37 +- .../auth/test_user_api_key_auth_mcp.py | 272 +++ .../mcp_server/test_discoverable_endpoints.py | 165 +- .../mcp_server/test_mcp_hook_extra_headers.py | 100 + .../mcp_server/test_mcp_server.py | 394 ++++ .../mcp_server/test_openapi_tool_auth.py | 220 ++ .../auth/test_admin_viewer_handler_access.py | 168 ++ .../proxy/auth/test_auth_checks.py | 228 +- .../proxy/auth/test_auth_utils.py | 552 ++++- .../proxy/auth/test_handle_jwt.py | 123 +- .../proxy/auth/test_oauth2_proxy_hook.py | 211 ++ .../proxy/auth/test_route_checks.py | 410 ++++ .../test_router_override_fallback_auth.py | 237 ++ .../proxy/auth/test_user_api_key_auth.py | 336 ++- .../proxy/client/cli/test_auth_commands.py | 44 + .../proxy/common_utils/test_cache_codec.py | 126 + .../common_utils/test_user_api_key_cache.py | 219 ++ .../proxy/db/test_db_spend_update_writer.py | 25 +- .../azure/test_azure_text_moderation.py | 46 + .../content_filter/test_content_filter.py | 65 + .../guardrail_hooks/test_presidio.py | 97 + .../guardrail_hooks/test_tool_permission.py | 227 +- .../guardrail_hooks/test_xecguard.py | 21 +- .../proxy/guardrails/test_content_utils.py | 303 +++ .../test_deferred_guardrail_logging.py | 54 + .../guardrails/test_guardrail_coverage.py | 811 +++++++ .../test_qostodian_nexus_guardrail.py | 252 ++ .../health_endpoints/test_health_endpoints.py | 882 ++++++- .../proxy/hooks/test_batch_file_validation.py | 285 +++ .../proxy/hooks/test_max_budget_limiter.py | 208 ++ .../hooks/test_parallel_request_limiter_v3.py | 77 + .../proxy/hooks/test_proxy_hooks_init.py | 51 + .../hooks/test_proxy_track_cost_callback.py | 523 ++++- .../proxy/hooks/test_rate_limiter_toctou.py | 489 ++++ .../scim/test_scim_key_deactivation.py | 543 +++++ .../scim/test_scim_patch_user.py | 7 + .../test_access_group_endpoints.py | 57 +- .../test_activity_tenant_scoping.py | 385 +++ .../test_cache_settings_endpoints.py | 144 +- .../management_endpoints/test_common_utils.py | 36 + .../test_config_override_endpoints.py | 189 +- .../test_internal_user_endpoints.py | 217 +- .../test_key_management_endpoints.py | 293 +++ .../test_mcp_management_endpoints.py | 175 +- .../test_organization_endpoints.py | 130 ++ .../test_project_org_authz.py | 195 ++ .../test_router_settings_endpoints.py | 51 + .../test_team_callback_endpoints.py | 254 +- .../test_team_endpoints.py | 3 + .../proxy/management_endpoints/test_ui_sso.py | 460 +++- .../usage_endpoints/test_ai_usage_chat.py | 57 + .../test_prometheus_auth_middleware.py | 100 +- .../public_endpoints/test_public_endpoints.py | 31 +- .../test_spend_log_error_logger.py | 139 ++ .../test_spend_tracking_utils.py | 64 + .../proxy/test_budget_reservation.py | 1495 ++++++++++++ ...test_filter_models_by_team_access_group.py | 236 ++ .../proxy/test_health_check_max_tokens.py | 40 + .../test_langfuse_passthrough_security.py | 102 + .../proxy/test_lazy_openapi_snapshot.py | 118 + .../proxy/test_litellm_pre_call_utils.py | 173 ++ .../proxy/test_pricing_field_strip.py | 312 +++ .../test_provider_url_destination_guard.py | 139 ++ tests/test_litellm/proxy/test_proxy_server.py | 688 +++++- tests/test_litellm/proxy/test_pyroscope.py | 165 +- .../proxy/test_redis_auth_cache_flag.py | 145 ++ .../proxy/test_route_llm_request.py | 47 + .../proxy/test_sensitive_route_auth.py | 34 + .../proxy/test_swagger_chat_completions.py | 99 +- .../test_proxy_setting_endpoints.py | 77 + .../test_vector_store_endpoints.py | 206 +- .../test_vector_store_tenant_guard.py | 540 +++++ .../test_router_routing_groups.py | 631 +++++ .../test_router_tag_routing.py | 28 + .../test_router_utils_common_utils.py | 154 ++ .../test_secret_managers_main.py | 16 +- .../test_anthropic_skills_transformation.py | 9 + ...penai_embedding_encoding_format_default.py | 124 + tests/test_litellm/test_router.py | 430 ++++ tests/test_litellm/test_secret_redaction.py | 26 +- tests/test_litellm/test_utils.py | 7 +- .../test_vcr_safe_body_matcher.py | 168 ++ tests/unified_google_tests/conftest.py | 50 +- ui/litellm-dashboard/.nvmrc | 1 + ui/litellm-dashboard/package-lock.json | 208 +- ui/litellm-dashboard/package.json | 17 +- .../public/assets/logos/qohash.jpg | Bin 0 -> 11581 bytes .../(dashboard)/hooks/projects/useProjects.ts | 5 +- .../hooks/routingGroups/useRoutingGroups.ts | 51 + .../ModelsAndEndpointsView.tsx | 261 ++- .../src/app/login/LoginPage.test.tsx | 81 + .../src/app/login/LoginPage.tsx | 15 - .../app/onboarding/OnboardingForm.test.tsx | 54 + .../src/app/onboarding/OnboardingForm.tsx | 8 +- ui/litellm-dashboard/src/app/page.tsx | 3 - .../src/components/AIHub/ModelHubTable.tsx | 18 +- .../AccessGroups/AccessGroupsPage.tsx | 55 +- .../RouterSettings/Fallbacks/Fallbacks.tsx | 69 +- .../UsagePage/components/UsagePageView.tsx | 10 +- .../UsageViewSelect/UsageViewSelect.tsx | 9 +- .../VirtualKeysPage/VirtualKeysTable.test.tsx | 92 +- .../VirtualKeysPage/VirtualKeysTable.tsx | 31 +- .../src/components/budgets/budget_panel.tsx | 42 +- .../src/components/general_settings.tsx | 9 +- .../guardrails/guardrail_info_helpers.tsx | 2 + .../src/components/leftnav.test.tsx | 52 +- .../src/components/leftnav.tsx | 17 +- .../components/mcp_tools/mcp_server_view.tsx | 7 +- .../components/model_add/credentials.test.tsx | 67 +- .../src/components/model_add/credentials.tsx | 45 +- .../src/components/prompts.tsx | 24 +- .../components/provider_info_helpers.test.tsx | 14 + .../src/components/provider_info_helpers.tsx | 4 + .../routing_groups/RoutingGroupModal.tsx | 194 ++ .../routing_groups/RoutingGroupsTable.tsx | 241 ++ .../src/components/routing_groups/index.tsx | 177 ++ .../src/components/routing_groups/types.ts | 12 + .../src/components/team/TeamInfo.tsx | 16 +- .../src/components/user_dashboard.tsx | 34 +- .../src/components/view_users.tsx | 4 +- .../src/components/view_users/columns.tsx | 26 +- .../src/components/view_users/table.test.tsx | 91 + .../src/components/view_users/types.ts | 1 + ui/litellm-dashboard/src/utils/roles.test.ts | 32 +- ui/litellm-dashboard/src/utils/roles.ts | 9 + ui/litellm-dashboard/tests/setupTests.ts | 95 +- ui/litellm-dashboard/tsconfig.json | 2 +- ui/litellm-dashboard/tsconfig.tsbuildinfo | 2 +- uv.lock | 719 +++--- 1092 files changed, 54847 insertions(+), 9580 deletions(-) delete mode 100644 .github/workflows/check-lazy-openapi-snapshot.yml create mode 100644 docs/my-website/docs/providers/crusoe.md create mode 100644 litellm-js/proxy/package-lock.json create mode 100644 litellm-proxy-extras/litellm_proxy_extras/migrations/20260501195714_managed_resource_team_owner/migration.sql create mode 100644 litellm/litellm_core_utils/cloud_storage_security.py create mode 100644 litellm/litellm_core_utils/secret_redaction.py create mode 100644 litellm/llms/azure/image_generation/http_utils.py create mode 100644 litellm/llms/base_llm/managed_resources/isolation.py create mode 100644 litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/output_params_utils.py rename litellm/proxy/_experimental/out/_next/static/{zxkD4-EPlgfKHDTw8O869 => 8TZ2JbOi7SZ6BCj9ScTHW}/_buildManifest.js (100%) rename litellm/proxy/_experimental/out/_next/static/{zxkD4-EPlgfKHDTw8O869 => 8TZ2JbOi7SZ6BCj9ScTHW}/_clientMiddlewareManifest.json (100%) rename litellm/proxy/_experimental/out/_next/static/{zxkD4-EPlgfKHDTw8O869 => 8TZ2JbOi7SZ6BCj9ScTHW}/_ssgManifest.js (100%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0377ae18aae60c57.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/038e83c8eab81a79.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/03c715f5e0f1425c.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0493aafc4891dd29.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/052aaa8d01e02cd3.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/05d900c88781d712.js rename litellm/proxy/_experimental/out/_next/static/chunks/{b83ca9892d2d63cf.js => 0606c92ecd600e0c.js} (53%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/06b2ea8c776c2e9b.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/088fea506f07e1cd.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0b470ffc60999bf4.js rename litellm/proxy/_experimental/out/_next/static/chunks/{7c36bfe1ba5e3ba8.js => 0c3e8651e0e97232.js} (63%) rename litellm/proxy/_experimental/out/_next/static/chunks/{eaa9f9b9bb3e054b.js => 0cdfadbcf4b8c9e4.js} (99%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0e03d69b502b3be9.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0e6dadb6a51341b5.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/0f59b35ee0664fe0.js rename litellm/proxy/_experimental/out/_next/static/chunks/{7e830ceee904c386.js => 102e659fcec2585e.js} (73%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/10dc4591ef08a91f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/11429586d5e74f7f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1198c9038aaedc3a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/171a03c36a999407.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/17816faaae727f81.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/18a9536fce05dc33.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1ab44e07f0b1cd5e.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1abad0fb1abdc83c.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1d0991370c308b4d.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1d37f4159623f97f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/1fe0596a309ad6cf.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2005c732f6d6cbb4.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/23491c78faf959c9.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/264fd32eefec52b6.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/276409aa6cbc14db.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/277cc236a763c2bc.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2975ec0f3dbe2fc7.js rename litellm/proxy/_experimental/out/_next/static/chunks/{673d847ad9c91666.js => 2a5f4a7388e54210.js} (88%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2b682a7f2932def8.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2d8285e144d4452a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2ea722d0a9ce35c8.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/2f29909dc244a7c0.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/3397155a65b7d83c.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/341e7c75250f4f40.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/34465d13a9152473.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/355b9871de1cf382.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/35e1b31334447d6e.js rename litellm/proxy/_experimental/out/_next/static/chunks/{738efbc0d941f9d2.js => 37e77c06e99eb8ff.js} (87%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/37e7834517e667e4.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/3ac3a9a88413bb27.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/3ba782adb71e77d0.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/3c2d67ecf9619f2b.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/3e917c79aadd945b.js rename litellm/proxy/_experimental/out/_next/static/chunks/{a230559fcabaea23.js => 406bbb9c89fee7ee.js} (99%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/40ec1228b231a0d1.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/44fd25e5d70e1a25.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/45249a290b3ea558.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/465e732e5d52ae39.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/47a838c67cdd745e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/47be83d4515c6599.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/496544a8be968b8b.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/4a97ab1044d56ea9.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/4b9bda626d5a281b.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/4dfbb7412144f148.js rename litellm/proxy/_experimental/out/_next/static/chunks/{4b8dcb3ad5dfb8de.js => 4e06277331e725da.js} (78%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/4e17b625d75327a7.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/4f6e5b838f18b8e6.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/50d8a95e62930b35.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5387bd8bd4bcf195.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/54563d12ee8915f4.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/570d770996d98e0f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/57a2860decebc0b6.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/59e0c0c187697b37.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5a6ef256a98646ae.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5b23ca2957db2e3d.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5e34b4b8074089e6.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5f2d62a75803a3f7.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/5f9c3b92a016f382.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6214d842aef0673e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/623eaea02d123060.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6392214b899e5c07.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/65968777d52ff874.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6665fdc6e86f173a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/673491d4036a0cfe.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/679dbd657c8b5aef.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6967a3b4ecbd3785.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6ac5e2383054326d.js rename litellm/proxy/_experimental/out/_next/static/chunks/{9492aee8924914ae.js => 6ba62be8e5f988a4.js} (93%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6dc89cea942b737a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/6ec1a92c34e842cb.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7142b7d05b1b4b2e.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/71f6f0fcaef91598.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/72debc51022299b8.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7425e467262c0658.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/74ce31aa0fb2adc9.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/79080debc00288de.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7c552f88245cdd96.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7cb344c72a271ca2.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7e2dbe0d25a79405.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7e4551c11f7f1e8a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7ede3688da5c7a5f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/7f7819822e72bcae.js rename litellm/proxy/_experimental/out/_next/static/chunks/{76b6374a992fbca0.js => 80749a6dab9b96b4.js} (58%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8127cf0d5ad2772a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/836ef19edead05fe.js rename litellm/proxy/_experimental/out/_next/static/chunks/{2faf62c238d105eb.js => 8489ea6f0be86483.js} (79%) rename litellm/proxy/_experimental/out/_next/static/chunks/{aa7c40f46cb1b417.js => 84f351822ff5289f.js} (80%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/86828bdbafb8b581.js rename litellm/proxy/_experimental/out/_next/static/chunks/{7149faf92f484aca.js => 878832edb30e99a4.js} (62%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/89aa55578de861b7.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/89aeafdc07090814.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8a26922c4b7235a4.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8b6eb21a51b719e1.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8c17e934bd227606.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8e3d0ce9505a304f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/8f3bf592254c6c3b.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/90d0e7aef65b5dc7.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/91037395c95e366d.css rename litellm/proxy/_experimental/out/_next/static/chunks/{eabd1c9341cacb49.js => 92516c9f878f0819.js} (76%) rename litellm/proxy/_experimental/out/_next/static/chunks/{73b50c3314123d9d.js => 928d0c629f28babb.js} (80%) rename litellm/proxy/_experimental/out/_next/static/chunks/{8908525d8a1d1a33.js => 93c3938d8d8704b3.js} (63%) rename litellm/proxy/_experimental/out/_next/static/chunks/{7c797521435cb59c.js => 94f7208f5087e27c.js} (60%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/951e5ff2dc4928c2.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/95b1023fa868f012.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/95bd09d7d0345fe5.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/975f380f5d2c2b7d.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/980f4b2cf05dae8e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/98ddd18b25554abd.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/993822065369ee18.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9969d80f8608d1dc.js rename litellm/proxy/_experimental/out/_next/static/chunks/{3daef8922b68e600.js => 9b0ee76cbdef1a2a.js} (77%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9b19f9f63c383201.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9b4c8a50e297b9ad.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9b8d229c6e7826fb.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9bbebdeb3f1cb03f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9bfe1d85217d0efc.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9cca003867a68aa9.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/9ce7fbf2fad5f6f4.js rename litellm/proxy/_experimental/out/_next/static/chunks/{58170e1c551aede4.js => 9fbdf10b9cf445d9.js} (76%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a06cc76a774dd182.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a0b3f7d6c7b4d358.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a0ce6f40daef039a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a1abfc2f35c701cc.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a1b5b0c54192471e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a2ba050d0179d93d.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a31b02ea00f8e98b.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a4949852bdd27c8e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a5b10ff77096a982.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a5de56db893c490c.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a61a87ca92d576e9.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a7b074c8fcc9fd7a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a8de8fe39e2c0fd8.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/a9d351f6a8fa66f1.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/aba51a6559eb06c7.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/acd6db33552053fb.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/adf8db17652cf9aa.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ae420624472238ad.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b01279f88358b7f5.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b12bdf0901df004a.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b368552eef8c1611.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b3d198d6c56a21b8.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b9341b4c942e3943.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/b98447395b5d37ef.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/baadbd26839e7b66.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/bacdab4ef587dc3f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/bbe974da1fd4f044.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/bde2340071127430.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/be5ddb5784b2b78a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c0b640cc12a2b90e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c1def3f9c2ccf0b5.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c1efd92d6b02ddc9.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c2f31fa6e9a867a9.js rename litellm/proxy/_experimental/out/_next/static/chunks/{5023bf9fd490e7e0.js => c3c84f2fc1b1e9db.js} (96%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c53c9c7afec96700.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c5b9f85e6738bf6f.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c77d417e8a84d57c.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/c93d5122cac84bc6.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ca93fa690ed9c42b.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/cb8d72a0c642f1d3.js rename litellm/proxy/_experimental/out/_next/static/chunks/{6511168aa335c4db.js => cbfd53da3104be2a.js} (54%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/cd677ff381b90c30.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ce44d74054c76c03.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/cf9c81fc7166f4d4.js rename litellm/proxy/_experimental/out/_next/static/chunks/{c0a1c5ed19f4bfe2.js => cfa0acae44b4288b.js} (77%) delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d11611f992bddf33.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d2cd8ba8b54ac12f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d6be8091255a78cc.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d7aa89e52e3d1758.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d84d93ec5e05aece.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d8cd2d44272d51c8.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/d9963e0e4e9ceea5.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/da505418e8e8af34.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/da87cea37abf71ef.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/daaa2e6529d97969.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/dae72c93f180b49f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ddcd1fd842a79e55.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/de0c9305cb137e96.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/dfb7190882d30d33.js rename litellm/proxy/_experimental/out/_next/static/chunks/{fa8dcdcf9803fe4f.js => e000783224957b5f.js} (64%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e00ff4e948e36ad2.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e0371069bf08d367.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e0cb6755699177c1.css delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e1ddb2a5fb23f5a5.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e1f572e8226962e3.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e2e17b99dc4f7bfa.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e2f70fb83dabbe21.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e3752298bfbbee9d.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e436f7eccebb809d.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e55673f6717e443a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e5af85ebd6f84f2f.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e637f1fc0218b4f2.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e77ff93ed9180690.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e7cc7b98b893b20d.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e871b803455fadee.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/e8b12a8b1fe94fe9.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ead0794ce27b66ce.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ec6c2f1c9b8d05be.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/ef8798600e862605.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/efc1a6ef38353eda.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/f1d2e3f3196db455.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/f5fc27663c2424f7.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/f62432147248db5e.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/f7c95eaa060d1f99.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/f7e1d08418645368.js rename litellm/proxy/_experimental/out/_next/static/chunks/{9c8c73d0d20d640f.js => fa36bea8808c8054.js} (78%) rename litellm/proxy/_experimental/out/_next/static/chunks/{ca91b0fa4d619698.js => fb125648f2dae104.js} (78%) create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fb9deab6544b2a7a.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fba48608afe1d559.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fbe12a36d22e9554.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fd504c53206427f5.js create mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fd61c33cefa996af.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fe5abdcdb57db543.js delete mode 100644 litellm/proxy/_experimental/out/_next/static/chunks/fef9c8b7c44b1dfc.js create mode 100644 litellm/proxy/_experimental/out/assets/logos/qohash.jpg create mode 100644 litellm/proxy/_experimental/out/assets/logos/xecguard.svg create mode 100644 litellm/proxy/_experimental/out/chat.html create mode 100644 litellm/proxy/_experimental/out/chat.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next._full.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next._head.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next._index.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next._tree.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next.chat.__PAGE__.txt create mode 100644 litellm/proxy/_experimental/out/chat/__next.chat.txt create mode 100644 litellm/proxy/auth/trusted_proxy_utils.py create mode 100644 litellm/proxy/common_utils/cache_pydantic_utils.py create mode 100644 litellm/proxy/common_utils/resource_ownership.py create mode 100644 litellm/proxy/common_utils/user_api_key_cache.py create mode 100644 litellm/proxy/container_endpoints/ownership.py create mode 100644 litellm/proxy/guardrails/_content_utils.py create mode 100644 litellm/proxy/guardrails/guardrail_hooks/qohash/__init__.py create mode 100644 litellm/proxy/guardrails/guardrail_hooks/qohash/qohash.py create mode 100644 litellm/proxy/spend_tracking/budget_reservation.py create mode 100644 litellm/proxy/spend_tracking/spend_log_error_logger.py create mode 100644 litellm/types/proxy/guardrails/guardrail_hooks/qohash.py create mode 100644 tests/_flush_vcr_cache.py create mode 100644 tests/_vcr_conftest_common.py create mode 100644 tests/_vcr_redis_persister.py create mode 100644 tests/audio_tests/conftest.py create mode 100644 tests/litellm/llms/azure/__init__.py create mode 100644 tests/litellm/llms/azure/test_azure_embedding.py create mode 100644 tests/llm_translation/test_crusoe.py create mode 100644 tests/llm_translation/test_vcr_conftest_common_banner.py create mode 100644 tests/llm_translation/test_vcr_redis_persister.py create mode 100644 tests/local_testing/test_responses_stream_cache_keys.py create mode 100644 tests/logging_callback_tests/test_langfuse_dynamic_credentials.py create mode 100644 tests/logging_callback_tests/test_langsmith_dynamic_credentials.py create mode 100644 tests/ocr_tests/conftest.py create mode 100644 tests/pass_through_unit_tests/conftest.py create mode 100644 tests/search_tests/conftest.py create mode 100644 tests/test_litellm/containers/test_container_handler_url.py create mode 100644 tests/test_litellm/containers/test_container_proxy_ownership.py create mode 100644 tests/test_litellm/integrations/test_prometheus_api_promql_escape.py create mode 100644 tests/test_litellm/integrations/test_prompt_manager_ssti.py create mode 100644 tests/test_litellm/litellm_core_utils/test_decode_special_tokens.py create mode 100644 tests/test_litellm/llms/anthropic/chat/conftest.py create mode 100644 tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_handler_output_config_passthrough.py create mode 100644 tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_reasoning_effort_translation.py create mode 100644 tests/test_litellm/llms/azure/image_edit/test_azure_image_edit_transformation.py create mode 100644 tests/test_litellm/llms/azure/test_azure_cost_calculation.py create mode 100644 tests/test_litellm/llms/azure_ai/test_azure_ai_agents_handler.py create mode 100644 tests/test_litellm/llms/azure_ai/test_azure_document_intelligence_ocr_transformation.py create mode 100644 tests/test_litellm/llms/base_llm/test_base_managed_resource.py create mode 100644 tests/test_litellm/llms/base_llm/test_managed_resource_isolation.py create mode 100644 tests/test_litellm/llms/bedrock/files/test_bedrock_files_handler.py create mode 100644 tests/test_litellm/llms/cloudflare/test_cloudflare_transformation.py create mode 100644 tests/test_litellm/llms/crusoe/__init__.py create mode 100644 tests/test_litellm/llms/crusoe/test_crusoe.py create mode 100644 tests/test_litellm/llms/elevenlabs/test_elevenlabs_text_to_speech_transformation.py create mode 100644 tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py create mode 100644 tests/test_litellm/llms/openai/videos/test_openai_video_transformation.py create mode 100644 tests/test_litellm/llms/test_polling_url_origin_match.py create mode 100644 tests/test_litellm/llms/vertex_ai/gemini_embeddings/__init__.py create mode 100644 tests/test_litellm/llms/vertex_ai/gemini_embeddings/test_batch_embed_content_transformation.py create mode 100644 tests/test_litellm/llms/vertex_ai/test_vertex_ai_search_vector_store_transformation.py create mode 100644 tests/test_litellm/llms/vertex_ai/test_vertex_model_garden_openapi.py create mode 100644 tests/test_litellm/llms/xai/test_xai_chat_transformation.py create mode 100644 tests/test_litellm/proxy/_experimental/mcp_server/test_openapi_tool_auth.py create mode 100644 tests/test_litellm/proxy/auth/test_admin_viewer_handler_access.py create mode 100644 tests/test_litellm/proxy/auth/test_oauth2_proxy_hook.py create mode 100644 tests/test_litellm/proxy/auth/test_router_override_fallback_auth.py create mode 100644 tests/test_litellm/proxy/common_utils/test_cache_codec.py create mode 100644 tests/test_litellm/proxy/common_utils/test_user_api_key_cache.py create mode 100644 tests/test_litellm/proxy/guardrails/test_content_utils.py create mode 100644 tests/test_litellm/proxy/guardrails/test_guardrail_coverage.py create mode 100644 tests/test_litellm/proxy/guardrails/test_qostodian_nexus_guardrail.py create mode 100644 tests/test_litellm/proxy/hooks/test_batch_file_validation.py create mode 100644 tests/test_litellm/proxy/hooks/test_max_budget_limiter.py create mode 100644 tests/test_litellm/proxy/hooks/test_proxy_hooks_init.py create mode 100644 tests/test_litellm/proxy/hooks/test_rate_limiter_toctou.py create mode 100644 tests/test_litellm/proxy/management_endpoints/scim/test_scim_key_deactivation.py create mode 100644 tests/test_litellm/proxy/management_endpoints/test_activity_tenant_scoping.py create mode 100644 tests/test_litellm/proxy/management_endpoints/test_project_org_authz.py create mode 100644 tests/test_litellm/proxy/spend_tracking/test_spend_log_error_logger.py create mode 100644 tests/test_litellm/proxy/test_budget_reservation.py create mode 100644 tests/test_litellm/proxy/test_filter_models_by_team_access_group.py create mode 100644 tests/test_litellm/proxy/test_langfuse_passthrough_security.py create mode 100644 tests/test_litellm/proxy/test_lazy_openapi_snapshot.py create mode 100644 tests/test_litellm/proxy/test_pricing_field_strip.py create mode 100644 tests/test_litellm/proxy/test_provider_url_destination_guard.py create mode 100644 tests/test_litellm/proxy/test_redis_auth_cache_flag.py create mode 100644 tests/test_litellm/proxy/test_sensitive_route_auth.py create mode 100644 tests/test_litellm/proxy/vector_store_endpoints/test_vector_store_tenant_guard.py create mode 100644 tests/test_litellm/router_strategy/test_router_routing_groups.py create mode 100644 tests/test_litellm/test_openai_embedding_encoding_format_default.py create mode 100644 tests/test_litellm/test_vcr_safe_body_matcher.py create mode 100644 ui/litellm-dashboard/.nvmrc create mode 100644 ui/litellm-dashboard/public/assets/logos/qohash.jpg create mode 100644 ui/litellm-dashboard/src/app/(dashboard)/hooks/routingGroups/useRoutingGroups.ts create mode 100644 ui/litellm-dashboard/src/components/routing_groups/RoutingGroupModal.tsx create mode 100644 ui/litellm-dashboard/src/components/routing_groups/RoutingGroupsTable.tsx create mode 100644 ui/litellm-dashboard/src/components/routing_groups/index.tsx create mode 100644 ui/litellm-dashboard/src/components/routing_groups/types.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index d2c4906ef6..3019fabd6f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1475,7 +1475,7 @@ jobs: - run: name: Run tests command: | - uv run --no-sync python -m pytest -v tests/otel_tests -x --junitxml=test-results/junit.xml --durations=5 + uv run --no-sync python -m pytest -v tests/otel_tests --junitxml=test-results/junit.xml --durations=5 no_output_timeout: 15m # Clean up first container - run: @@ -1935,7 +1935,7 @@ jobs: name: Run Vertex AI, Google AI Studio Node.js tests command: | cd tests/pass_through_tests - npx jest . --verbose + NODE_OPTIONS=--experimental-vm-modules npx jest . --verbose no_output_timeout: 30m - run: name: Run tests @@ -2138,17 +2138,23 @@ jobs: - ~/.cache/uv - restore_cache: keys: - - ui-e2e-node-deps-v1-{{ checksum "ui/litellm-dashboard/package-lock.json" }} + - ui-e2e-node-deps-v2-{{ checksum "ui/litellm-dashboard/package-lock.json" }} - run: name: Install Node dependencies and Playwright + # The cimg/python:3.12-browsers image already ships the Chromium system + # libraries Playwright needs (libnss3, libatk-bridge2.0-0, libcups2, etc.). + # `--with-deps` triggers a redundant apt-get update + install that adds + # 5-10 minutes to the job and frequently stalls on flaky Ubuntu mirrors, + # so we install just the browser binary. command: | cd ui/litellm-dashboard npm ci - npx playwright install chromium --with-deps + npx playwright install chromium - save_cache: - key: ui-e2e-node-deps-v1-{{ checksum "ui/litellm-dashboard/package-lock.json" }} + key: ui-e2e-node-deps-v2-{{ checksum "ui/litellm-dashboard/package-lock.json" }} paths: - ui/litellm-dashboard/node_modules + - ~/.cache/ms-playwright - run: name: Build UI from source # Prior version used `cp -r out/ ../../litellm/proxy/_experimental/out/`. diff --git a/.github/workflows/check-lazy-openapi-snapshot.yml b/.github/workflows/check-lazy-openapi-snapshot.yml deleted file mode 100644 index 2e4ed3637f..0000000000 --- a/.github/workflows/check-lazy-openapi-snapshot.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Check Lazy OpenAPI Snapshot - -on: - pull_request: - branches: - - main - - litellm_internal_staging - - "litellm_**" - -permissions: - contents: read - checks: write - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - verify: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - with: - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - with: - python-version: "3.12" - - - name: Set up uv - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7 - with: - version: "0.10.9" - - - name: Cache uv dependencies - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 - with: - path: | - ~/.cache/uv - .venv - key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }} - restore-keys: | - ${{ runner.os }}-uv- - - - name: Install dependencies - run: uv sync --frozen --all-groups --all-extras - - - name: Regenerate snapshot to /tmp - id: regen - run: | - cp litellm/proxy/_lazy_openapi_snapshot.json /tmp/snapshot.committed.json - uv run --no-sync python -m litellm.proxy._lazy_openapi_snapshot - mv litellm/proxy/_lazy_openapi_snapshot.json /tmp/snapshot.fresh.json - mv /tmp/snapshot.committed.json litellm/proxy/_lazy_openapi_snapshot.json - - - name: Compare - id: diff - continue-on-error: true - run: | - diff -q /tmp/snapshot.fresh.json litellm/proxy/_lazy_openapi_snapshot.json - - - name: Mark neutral if drift - if: steps.diff.outcome == 'failure' - uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2.0.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: lazy-openapi-snapshot - conclusion: neutral - output: | - { - "title": "Lazy openapi snapshot is stale", - "summary": "Run `python -m litellm.proxy._lazy_openapi_snapshot` and commit the regenerated `litellm/proxy/_lazy_openapi_snapshot.json`. Not blocking — the snapshot will regenerate at release if not committed." - } diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 39d078267f..a726a921a2 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: tag: - description: "Release tag (e.g. 1.84.0, 1.84.0rc1, 1.84.0.dev42, 1.84.0.post1; legacy v1.83.10-stable still accepted)" + description: "Release tag (e.g. 1.84.0, 1.84.0rc1, 1.84.0.dev42, 1.84.0-dev.2, 1.84.0.post1; legacy v1.83.10-stable still accepted)" required: true type: string commit_hash: @@ -46,9 +46,11 @@ jobs: const commitHash = process.env.COMMIT_HASH; // Mark RC / dev / nightly / alpha / beta tags as GitHub pre-releases. + // Accept both PEP 440 (`.dev`) and SemVer (`-dev`) separators so tags + // like `1.84.0.dev2` and `1.84.0-dev.2` are both detected. // PEP 440 post-releases (e.g. `1.84.0.post1`) and legacy `-stable[.patch.N]` // are stable maintenance releases, not pre-releases. - const isPrerelease = /(?:rc|nightly|alpha|beta|\.dev)/i.test(tag); + const isPrerelease = /(?:rc|nightly|alpha|beta|[-.]dev)/i.test(tag); const cosignSection = [ `## Verify Docker Image Signature`, diff --git a/.gitignore b/.gitignore index 38bf9554b5..59812ed6ed 100644 --- a/.gitignore +++ b/.gitignore @@ -90,7 +90,6 @@ test.py litellm_config.yaml !.github/observatory/litellm_config.yaml .cursor -.vscode/launch.json litellm/proxy/to_delete_loadtest_work/* update_model_cost_map.py tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py @@ -100,4 +99,5 @@ STABILIZATION_TODO.md **/test-results **/playwright-report **/*.storageState.json -**/coverage \ No newline at end of file +**/coverage +test-config \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 03779d6c88..915daff999 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # Base image for building -ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f +ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 # Runtime image -ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin diff --git a/Makefile b/Makefile index b6b674ff3b..5dbd308a3e 100644 --- a/Makefile +++ b/Makefile @@ -185,3 +185,6 @@ test-llm-translation-single: install-test-deps $(UV_RUN) pytest tests/llm_translation/$(FILE) \ --junitxml=test-results/junit.xml \ -v --tb=short --maxfail=100 --timeout=300 + +test-llm-translation-flush-vcr-cache: + $(UV_RUN) python tests/_flush_vcr_cache.py diff --git a/README.md b/README.md index d72fb746ed..72fd43925c 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Managing LLM calls across providers gets complicated fast — different SDKs, au Stripe image Google ADK - Greptile + Greptile OpenHands

Netflix

OpenAI Agents SDK diff --git a/cookbook/litellm-ollama-docker-image/requirements.txt b/cookbook/litellm-ollama-docker-image/requirements.txt index 815a42a679..9b9181b236 100644 --- a/cookbook/litellm-ollama-docker-image/requirements.txt +++ b/cookbook/litellm-ollama-docker-image/requirements.txt @@ -1 +1 @@ -litellm==1.83.5 \ No newline at end of file +litellm==1.83.14 diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 2cfc5ef03f..5de588cf4e 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -3,7 +3,7 @@ ARG LITELLM_BUILD_IMAGE=python:3.11-alpine@sha256:f07e2ace46f560f09a6eeec7b4913b # Runtime image ARG LITELLM_RUNTIME_IMAGE=python:3.11-alpine@sha256:f07e2ace46f560f09a6eeec7b4913b80ee99546e749ef82342a419a326620856 -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin diff --git a/docker/Dockerfile.database b/docker/Dockerfile.database index e3edcece61..671f374ca2 100644 --- a/docker/Dockerfile.database +++ b/docker/Dockerfile.database @@ -1,9 +1,9 @@ # Base image for building -ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f +ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 # Runtime image -ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index e2dc185783..ebc92a22d5 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -3,7 +3,7 @@ ARG LITELLM_BUILD_IMAGE=python:3.13-slim@sha256:739e7213785e88c0f702dcdc12c0973a # Runtime image ARG LITELLM_RUNTIME_IMAGE=python:3.13-slim@sha256:739e7213785e88c0f702dcdc12c0973afcbd606dbf021a589cab77d6b00b579d -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin diff --git a/docker/Dockerfile.health_check b/docker/Dockerfile.health_check index 07d35b5e29..a2e5cb9f71 100644 --- a/docker/Dockerfile.health_check +++ b/docker/Dockerfile.health_check @@ -1,4 +1,4 @@ -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin FROM python:3.13-slim@sha256:739e7213785e88c0f702dcdc12c0973afcbd606dbf021a589cab77d6b00b579d diff --git a/docker/Dockerfile.non_root b/docker/Dockerfile.non_root index 8512ae8ad9..3fa73f4243 100644 --- a/docker/Dockerfile.non_root +++ b/docker/Dockerfile.non_root @@ -1,8 +1,8 @@ # Base images -ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f -ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:f26d42a15d09d9a643b231df929fa3cf609bedc58a728eb445be89a9d8d1da9f +ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 +ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base@sha256:3258be472764337fd13095bcbb3182da170243b5819fd67ad4c0754590588b31 ARG PROXY_EXTRAS_SOURCE=published -ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:733b4042187702f832f7fdecb3aff14a61b288c4ca37af188bb5715c1caebaf8 +ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.11.7@sha256:240fb85ab0f263ef12f492d8476aa3a2e4e1e333f7d67fbdd923d00a506a516a FROM $UV_IMAGE AS uvbin @@ -32,7 +32,6 @@ ENV UV_PROJECT_ENVIRONMENT=/app/.venv \ PATH="/app/.venv/bin:${PATH}" \ LITELLM_NON_ROOT=true \ PRISMA_BINARY_CACHE_DIR=/app/.cache/prisma-python/binaries \ - PRISMA_CLI_BINARY_TARGETS="debian-openssl-3.0.x" \ XDG_CACHE_HOME=/app/.cache # Copy dependency metadata first for layer caching @@ -114,7 +113,6 @@ COPY --from=builder /app/docker/supervisord.conf /etc/supervisord.conf ENV PATH="/app/.venv/bin:${PATH}" \ PRISMA_BINARY_CACHE_DIR=/app/.cache/prisma-python/binaries \ - PRISMA_CLI_BINARY_TARGETS="debian-openssl-3.0.x" \ HOME=/app \ LITELLM_NON_ROOT=true \ XDG_CACHE_HOME=/app/.cache \ diff --git a/docs/my-website/docs/providers/crusoe.md b/docs/my-website/docs/providers/crusoe.md new file mode 100644 index 0000000000..aa737cbdcd --- /dev/null +++ b/docs/my-website/docs/providers/crusoe.md @@ -0,0 +1,196 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Crusoe + +## Overview + +| Property | Details | +|-------|-------| +| Description | Crusoe Cloud provides GPU-accelerated inference for open-source large language models, optimized for performance and cost efficiency. | +| Provider Route on LiteLLM | `crusoe/` | +| Link to Provider Doc | [Crusoe Managed Inference Documentation ↗](https://docs.crusoecloud.com/managed-inference/overview/index.html) | +| Base URL | `https://managed-inference-api-proxy.crusoecloud.com/v1` | +| Supported Operations | [`/chat/completions`](#sample-usage) | + +
+
+ +**We support ALL Crusoe models, just set `crusoe/` as a prefix when sending completion requests** + +## Available Models + +| Model | Description | Context Window | +|-------|-------------|----------------| +| `crusoe/deepseek-ai/DeepSeek-R1-0528` | DeepSeek R1 reasoning model (May 2025) | 163,840 tokens | +| `crusoe/deepseek-ai/DeepSeek-V3-0324` | DeepSeek V3 chat model (March 2025) | 163,840 tokens | +| `crusoe/google/gemma-3-12b-it` | Google Gemma 3 12B instruction-tuned | 131,072 tokens | +| `crusoe/meta-llama/Llama-3.3-70B-Instruct` | Llama 3.3 70B instruction-tuned | 131,072 tokens | +| `crusoe/moonshotai/Kimi-K2-Thinking` | Kimi K2 extended thinking model | 262,144 tokens | +| `crusoe/openai/gpt-oss-120b` | OpenAI 120B open-source model | 131,072 tokens | +| `crusoe/Qwen/Qwen3-235B-A22B-Instruct-2507` | Qwen3 235B MoE instruction-tuned | 262,144 tokens | + +## Required Variables + +```python showLineNumbers title="Environment Variables" +os.environ["CRUSOE_API_KEY"] = "" # your Crusoe API key +``` + +## Usage - LiteLLM Python SDK + +### Non-streaming + +```python showLineNumbers title="Crusoe Non-streaming Completion" +import os +import litellm +from litellm import completion + +os.environ["CRUSOE_API_KEY"] = "" # your Crusoe API key + +messages = [{"content": "Hello, how are you?", "role": "user"}] + +# Crusoe call +response = completion( + model="crusoe/meta-llama/Llama-3.3-70B-Instruct", + messages=messages +) + +print(response) +``` + +### Streaming + +```python showLineNumbers title="Crusoe Streaming Completion" +import os +import litellm +from litellm import completion + +os.environ["CRUSOE_API_KEY"] = "" # your Crusoe API key + +messages = [{"content": "Write a short story about AI", "role": "user"}] + +# Crusoe call with streaming +response = completion( + model="crusoe/meta-llama/Llama-3.3-70B-Instruct", + messages=messages, + stream=True +) + +for chunk in response: + print(chunk) +``` + +### Function Calling + +```python showLineNumbers title="Crusoe Function Calling" +import os +import litellm +from litellm import completion + +os.environ["CRUSOE_API_KEY"] = "" # your Crusoe API key + +tools = [{ + "type": "function", + "function": { + "name": "get_weather", + "description": "Get the current weather in a location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "The city and state, e.g. San Francisco, CA" + } + }, + "required": ["location"] + } + } +}] + +messages = [{"role": "user", "content": "What's the weather in Boston?"}] + +response = completion( + model="crusoe/meta-llama/Llama-3.3-70B-Instruct", + messages=messages, + tools=tools, + tool_choice="auto" +) + +print(response) +``` + +## Usage - LiteLLM Proxy Server + +```yaml showLineNumbers title="config.yaml" +model_list: + - model_name: llama-3.3-70b + litellm_params: + model: crusoe/meta-llama/Llama-3.3-70B-Instruct + api_key: os.environ/CRUSOE_API_KEY + - model_name: deepseek-r1 + litellm_params: + model: crusoe/deepseek-ai/DeepSeek-R1-0528 + api_key: os.environ/CRUSOE_API_KEY + - model_name: deepseek-v3 + litellm_params: + model: crusoe/deepseek-ai/DeepSeek-V3-0324 + api_key: os.environ/CRUSOE_API_KEY + - model_name: qwen3-235b + litellm_params: + model: crusoe/Qwen/Qwen3-235B-A22B-Instruct-2507 + api_key: os.environ/CRUSOE_API_KEY + - model_name: kimi-k2 + litellm_params: + model: crusoe/moonshotai/Kimi-K2-Thinking + api_key: os.environ/CRUSOE_API_KEY +``` + +## Custom API Base + +**Option 1: Environment variable** + +```python showLineNumbers title="Custom API Base via env var" +import os +from litellm import completion + +os.environ["CRUSOE_API_BASE"] = "https://custom.crusoecloud.com/v1" +os.environ["CRUSOE_API_KEY"] = "" # your API key + +response = completion( + model="crusoe/meta-llama/Llama-3.3-70B-Instruct", + messages=[{"content": "Hello!", "role": "user"}], +) +``` + +**Option 2: Pass directly** + +```python showLineNumbers title="Custom API Base via parameter" +from litellm import completion + +response = completion( + model="crusoe/meta-llama/Llama-3.3-70B-Instruct", + messages=[{"content": "Hello!", "role": "user"}], + api_base="https://custom.crusoecloud.com/v1", + api_key="your-api-key", +) +``` + +## Supported OpenAI Parameters + +- `temperature` +- `max_tokens` +- `max_completion_tokens` +- `top_p` +- `frequency_penalty` +- `presence_penalty` +- `stop` +- `n` +- `stream` +- `tools` +- `tool_choice` +- `response_format` +- `seed` +- `user` +- `logit_bias` +- `logprobs` +- `top_logprobs` diff --git a/enterprise/enterprise_hooks/banned_keywords.py b/enterprise/enterprise_hooks/banned_keywords.py index 4df138939a..47421c9605 100644 --- a/enterprise/enterprise_hooks/banned_keywords.py +++ b/enterprise/enterprise_hooks/banned_keywords.py @@ -11,6 +11,10 @@ from typing import Literal import litellm from litellm.caching.caching import DualCache from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.guardrails._content_utils import ( + is_text_content_call_type, + iter_message_text, +) from litellm.integrations.custom_logger import CustomLogger from litellm._logging import verbose_proxy_logger from fastapi import HTTPException @@ -73,10 +77,9 @@ class _ENTERPRISE_BannedKeywords(CustomLogger): - check if user id part of blocked list """ self.print_verbose("Inside Banned Keyword List Pre-Call Hook") - if call_type == "completion" and "messages" in data: - for m in data["messages"]: - if "content" in m and isinstance(m["content"], str): - self.test_violation(test_str=m["content"]) + if is_text_content_call_type(call_type): + for text in iter_message_text(data): + self.test_violation(test_str=text) except HTTPException as e: raise e @@ -93,11 +96,16 @@ class _ENTERPRISE_BannedKeywords(CustomLogger): user_api_key_dict: UserAPIKeyAuth, response, ): - if isinstance(response, litellm.ModelResponse) and isinstance( - response.choices[0], litellm.utils.Choices - ): - for word in self.banned_keywords_list: - self.test_violation(test_str=response.choices[0].message.content or "") + if not isinstance(response, litellm.ModelResponse): + return + + for choice in response.choices: + if not isinstance(choice, litellm.utils.Choices): + continue + message = getattr(choice, "message", None) + content = getattr(message, "content", None) + if isinstance(content, str): + self.test_violation(test_str=content) async def async_post_call_streaming_hook( self, diff --git a/enterprise/enterprise_hooks/google_text_moderation.py b/enterprise/enterprise_hooks/google_text_moderation.py index 1f26d52adf..5b2d71c5cc 100644 --- a/enterprise/enterprise_hooks/google_text_moderation.py +++ b/enterprise/enterprise_hooks/google_text_moderation.py @@ -12,6 +12,7 @@ import litellm from litellm._logging import verbose_proxy_logger from litellm.integrations.custom_logger import CustomLogger from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.guardrails._content_utils import iter_message_text from litellm.types.utils import CallTypesLiteral @@ -94,11 +95,9 @@ class _ENTERPRISE_GoogleTextModeration(CustomLogger): - Calls Google's Text Moderation API - Rejects request if it fails safety check """ - if "messages" in data and isinstance(data["messages"], list): - text = "" - for m in data["messages"]: # assume messages is a list - if "content" in m and isinstance(m["content"], str): - text += m["content"] + # Covers multimodal list content + Responses-API input. + text = "".join(iter_message_text(data)) + if text: document = self.language_document(content=text, type_=self.document_type) request = self.moderate_text_request( diff --git a/enterprise/enterprise_hooks/openai_moderation.py b/enterprise/enterprise_hooks/openai_moderation.py index a1db9818e5..2162370804 100644 --- a/enterprise/enterprise_hooks/openai_moderation.py +++ b/enterprise/enterprise_hooks/openai_moderation.py @@ -19,6 +19,7 @@ import litellm from litellm._logging import verbose_proxy_logger from litellm.integrations.custom_logger import CustomLogger from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.guardrails._content_utils import iter_message_text from litellm.types.utils import CallTypesLiteral @@ -37,11 +38,8 @@ class _ENTERPRISE_OpenAI_Moderation(CustomLogger): user_api_key_dict: UserAPIKeyAuth, call_type: CallTypesLiteral, ): - text = "" - if "messages" in data and isinstance(data["messages"], list): - for m in data["messages"]: # assume messages is a list - if "content" in m and isinstance(m["content"], str): - text += m["content"] + # Covers multimodal list content + Responses-API input. + text = "".join(iter_message_text(data)) from litellm.proxy.proxy_server import llm_router diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/secret_detection.py b/enterprise/litellm_enterprise/enterprise_callbacks/secret_detection.py index 8a7a82df68..f441ce71ab 100644 --- a/enterprise/litellm_enterprise/enterprise_callbacks/secret_detection.py +++ b/enterprise/litellm_enterprise/enterprise_callbacks/secret_detection.py @@ -18,6 +18,7 @@ from litellm._logging import verbose_proxy_logger from litellm.caching.caching import DualCache from litellm.integrations.custom_guardrail import CustomGuardrail from litellm.proxy._types import UserAPIKeyAuth +from litellm.proxy.guardrails._content_utils import walk_user_text GUARDRAIL_NAME = "hide_secrets" @@ -473,23 +474,19 @@ class _ENTERPRISE_SecretDetection(CustomGuardrail): if await self.should_run_check(user_api_key_dict) is False: return - if "messages" in data and isinstance(data["messages"], list): - for message in data["messages"]: - if "content" in message and isinstance(message["content"], str): - detected_secrets = self.scan_message_for_secrets(message["content"]) + # Covers multimodal list content + Responses-API input. + def _redact_message_text(text: str) -> str: + detected_secrets = self.scan_message_for_secrets(text) + for secret in detected_secrets: + text = text.replace(secret["value"], "[REDACTED]") + if detected_secrets: + secret_types = [secret["type"] for secret in detected_secrets] + verbose_proxy_logger.warning( + f"Detected and redacted secrets in message: {secret_types}" + ) + return text - for secret in detected_secrets: - message["content"] = message["content"].replace( - secret["value"], "[REDACTED]" - ) - - if len(detected_secrets) > 0: - secret_types = [secret["type"] for secret in detected_secrets] - verbose_proxy_logger.warning( - f"Detected and redacted secrets in message: {secret_types}" - ) - else: - verbose_proxy_logger.debug("No secrets detected on input.") + walk_user_text(data, _redact_message_text) if "prompt" in data: if isinstance(data["prompt"], str): @@ -504,11 +501,15 @@ class _ENTERPRISE_SecretDetection(CustomGuardrail): f"Detected and redacted secrets in prompt: {secret_types}" ) elif isinstance(data["prompt"], list): - for item in data["prompt"]: + # Index back into the list — assigning to ``item`` would only + # rebind the loop variable and leave ``data["prompt"]`` + # carrying the unredacted secret. + for idx, item in enumerate(data["prompt"]): if isinstance(item, str): detected_secrets = self.scan_message_for_secrets(item) for secret in detected_secrets: item = item.replace(secret["value"], "[REDACTED]") + data["prompt"][idx] = item if len(detected_secrets) > 0: secret_types = [ secret["type"] for secret in detected_secrets @@ -517,31 +518,6 @@ class _ENTERPRISE_SecretDetection(CustomGuardrail): f"Detected and redacted secrets in prompt: {secret_types}" ) - if "input" in data: - if isinstance(data["input"], str): - detected_secrets = self.scan_message_for_secrets(data["input"]) - for secret in detected_secrets: - data["input"] = data["input"].replace(secret["value"], "[REDACTED]") - if len(detected_secrets) > 0: - secret_types = [secret["type"] for secret in detected_secrets] - verbose_proxy_logger.warning( - f"Detected and redacted secrets in input: {secret_types}" - ) - elif isinstance(data["input"], list): - _input_in_request = data["input"] - for idx, item in enumerate(_input_in_request): - if isinstance(item, str): - detected_secrets = self.scan_message_for_secrets(item) - for secret in detected_secrets: - _input_in_request[idx] = item.replace( - secret["value"], "[REDACTED]" - ) - if len(detected_secrets) > 0: - secret_types = [ - secret["type"] for secret in detected_secrets - ] - verbose_proxy_logger.warning( - f"Detected and redacted secrets in input: {secret_types}" - ) - verbose_proxy_logger.debug("Data after redacting input %s", data) + # ``data["input"]`` (Responses API and embeddings/moderation) is + # already covered by ``walk_user_text`` above. return diff --git a/enterprise/litellm_enterprise/proxy/auth/custom_sso_handler.py b/enterprise/litellm_enterprise/proxy/auth/custom_sso_handler.py index a368232038..e8f104c262 100644 --- a/enterprise/litellm_enterprise/proxy/auth/custom_sso_handler.py +++ b/enterprise/litellm_enterprise/proxy/auth/custom_sso_handler.py @@ -10,28 +10,21 @@ has already authenticated the user) and you need to extract user information fro custom headers or other request attributes. """ -from typing import TYPE_CHECKING, Dict, Optional, Union, cast +from typing import cast from fastapi import Request from fastapi.responses import RedirectResponse -if TYPE_CHECKING: - from fastapi_sso.sso.base import OpenID -else: - from typing import Any as OpenID - -from litellm.proxy.management_endpoints.types import CustomOpenID - class EnterpriseCustomSSOHandler: """ Enterprise Custom SSO Handler for LiteLLM Proxy - + This class provides methods for handling custom SSO authentication flows where users can implement their own authentication logic by processing request headers and returning user information in OpenID format. """ - + @staticmethod async def handle_custom_ui_sso_sign_in( request: Request, @@ -40,16 +33,16 @@ class EnterpriseCustomSSOHandler: Allow a user to execute their custom code to parse incoming request headers and return a OpenID object Use this when you have an OAuth proxy in front of LiteLLM (where the OAuth proxy has already authenticated the user) - + Args: request: The FastAPI request object containing headers and other request data - + Returns: RedirectResponse: Redirect response that sends the user to the LiteLLM UI with authentication token - + Raises: ValueError: If custom_ui_sso_sign_in_handler is not configured - + Example: This method is typically called when a user has already been authenticated by an external OAuth proxy and the proxy has added custom headers containing user information. @@ -60,27 +53,44 @@ class EnterpriseCustomSSOHandler: from litellm.integrations.custom_sso_handler import CustomSSOLoginHandler from litellm.proxy.proxy_server import ( CommonProxyErrors, + general_settings, premium_user, user_custom_ui_sso_sign_in_handler, ) + from litellm.proxy.auth.trusted_proxy_utils import ( + require_trusted_proxy_request, + ) + if premium_user is not True: raise ValueError(CommonProxyErrors.not_premium_user.value) - + if user_custom_ui_sso_sign_in_handler is None: - raise ValueError("custom_ui_sso_sign_in_handler is not configured. Please set it in general_settings.") - - custom_sso_login_handler = cast(CustomSSOLoginHandler, user_custom_ui_sso_sign_in_handler) - openid_response: OpenID = await custom_sso_login_handler.handle_custom_ui_sso_sign_in( + raise ValueError( + "custom_ui_sso_sign_in_handler is not configured. Please set it in general_settings." + ) + + require_trusted_proxy_request( request=request, + general_settings=general_settings, + feature_name="Custom UI SSO", ) - + + custom_sso_login_handler = cast( + CustomSSOLoginHandler, user_custom_ui_sso_sign_in_handler + ) + openid_response: OpenID = ( + await custom_sso_login_handler.handle_custom_ui_sso_sign_in( + request=request, + ) + ) + # Import here to avoid circular imports from litellm.proxy.management_endpoints.ui_sso import SSOAuthenticationHandler - + return await SSOAuthenticationHandler.get_redirect_response_from_openid( result=openid_response, request=request, received_response=None, generic_client_id=None, ui_access_mode=None, - ) \ No newline at end of file + ) diff --git a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py index 60c564072a..5ed4907034 100644 --- a/enterprise/litellm_enterprise/proxy/hooks/managed_files.py +++ b/enterprise/litellm_enterprise/proxy/hooks/managed_files.py @@ -15,6 +15,11 @@ from litellm.caching.caching import DualCache from litellm.integrations.custom_logger import CustomLogger from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.files.transformation import BaseFileEndpoints +from litellm.llms.base_llm.managed_resources.isolation import ( + build_list_page, + build_owner_filter, + can_access_resource, +) from litellm.proxy._types import ( CallTypes, LiteLLM_ManagedFileTable, @@ -99,6 +104,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): model_mappings=model_mappings, flat_model_file_ids=list(model_mappings.values()), created_by=user_api_key_dict.user_id, + team_id=user_api_key_dict.team_id, updated_by=user_api_key_dict.user_id, ) await self.internal_usage_cache.async_set_cache( @@ -114,6 +120,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): "model_mappings": json.dumps(model_mappings), "flat_model_file_ids": list(model_mappings.values()), "created_by": user_api_key_dict.user_id, + "team_id": user_api_key_dict.team_id, "updated_by": user_api_key_dict.user_id, } @@ -125,7 +132,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): db_data["storage_backend"] = hidden_params["storage_backend"] if "storage_url" in hidden_params: db_data["storage_url"] = hidden_params["storage_url"] - + verbose_logger.debug( f"Storage metadata: storage_backend={db_data.get('storage_backend')}, " f"storage_url={db_data.get('storage_url')}" @@ -171,6 +178,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): "model_object_id": model_object_id, "file_purpose": file_purpose, "created_by": user_api_key_dict.user_id, + "team_id": user_api_key_dict.team_id, "updated_by": user_api_key_dict.user_id, "status": file_object.status, }, @@ -229,15 +237,16 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): async def can_user_call_unified_file_id( self, unified_file_id: str, user_api_key_dict: UserAPIKeyAuth ) -> bool: - ## check if the user has access to the unified file id - - user_id = user_api_key_dict.user_id managed_file = await self.prisma_client.db.litellm_managedfiletable.find_first( where={"unified_file_id": unified_file_id} ) if managed_file: - return managed_file.created_by == user_id + return can_access_resource( + user_api_key_dict=user_api_key_dict, + created_by=managed_file.created_by, + resource_team_id=managed_file.team_id, + ) raise HTTPException( status_code=404, detail=f"File not found: {unified_file_id}", @@ -246,8 +255,6 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): async def can_user_call_unified_object_id( self, unified_object_id: str, user_api_key_dict: UserAPIKeyAuth ) -> bool: - ## check if the user has access to the unified object id - user_id = user_api_key_dict.user_id managed_object = ( await self.prisma_client.db.litellm_managedobjecttable.find_first( where={"unified_object_id": unified_object_id} @@ -255,7 +262,11 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) if managed_object: - return managed_object.created_by == user_id + return can_access_resource( + user_api_key_dict=user_api_key_dict, + created_by=managed_object.created_by, + resource_team_id=managed_object.team_id, + ) raise HTTPException( status_code=404, detail=f"Object not found: {unified_object_id}", @@ -285,28 +296,27 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): raise Exception( "Filtering by 'target_model_names' is not supported when using managed batches." ) - - where_clause: Dict[str, Any] = {"file_purpose": "batch"} - - # Filter by user who created the batch - if user_api_key_dict.user_id: - where_clause["created_by"] = user_api_key_dict.user_id - + + owner_filter = build_owner_filter(user_api_key_dict) + if owner_filter is None: + return build_list_page([]) + + where_clause: Dict[str, Any] = {"file_purpose": "batch", **owner_filter} + if after: where_clause["id"] = {"gt": after} - - # Fetch more than needed to allow for post-fetch filtering + fetch_limit = limit or 20 if target_model_names: - # Fetch extra to account for filtering + # Oversample so post-fetch model-name filtering still has enough rows. fetch_limit = max(fetch_limit * 3, 100) - + batches = await self.prisma_client.db.litellm_managedobjecttable.find_many( where=where_clause, take=fetch_limit, order={"created_at": "desc"}, ) - + batch_objects: List[LiteLLMBatch] = [] for batch in batches: try: @@ -314,7 +324,11 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): if len(batch_objects) >= (limit or 20): break - batch_data = json.loads(batch.file_object) if isinstance(batch.file_object, str) else batch.file_object + batch_data = ( + json.loads(batch.file_object) + if isinstance(batch.file_object, str) + else batch.file_object + ) batch_obj = LiteLLMBatch(**batch_data) batch_obj.id = batch.unified_object_id batch_objects.append(batch_obj) @@ -324,27 +338,29 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): f"Failed to parse batch object {batch.unified_object_id}: {e}" ) continue - - return { - "object": "list", - "data": batch_objects, - "first_id": batch_objects[0].id if batch_objects else None, - "last_id": batch_objects[-1].id if batch_objects else None, - "has_more": len(batch_objects) == (limit or 20), - } + + return build_list_page( + batch_objects, has_more=len(batch_objects) == (limit or 20) + ) async def get_user_created_file_ids( self, user_api_key_dict: UserAPIKeyAuth, model_object_ids: List[str] ) -> List[OpenAIFileObject]: """ - Get all file ids created by the user for a list of model object ids + Get all file ids the caller is allowed to see for a list of model + object ids. Service-account keys (no user_id) are scoped to their + team via ``team_id``; admins see all matches. Returns: - List of OpenAIFileObject's """ + owner_filter = build_owner_filter(user_api_key_dict) + if owner_filter is None: + return [] + file_ids = await self.prisma_client.db.litellm_managedfiletable.find_many( where={ - "created_by": user_api_key_dict.user_id, + **owner_filter, "flat_model_file_ids": {"hasSome": model_object_ids}, } ) @@ -377,11 +393,11 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): """ Check if the user has access to a list of file IDs. Only checks managed (unified) file IDs. - + Args: file_ids: List of file IDs to check access for user_api_key_dict: User API key authentication details - + Raises: HTTPException: If user doesn't have access to any of the files """ @@ -419,10 +435,10 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ### HANDLE TRANSFORMATIONS ### # Check both completion and acompletion call types is_completion_call = ( - call_type == CallTypes.completion.value + call_type == CallTypes.completion.value or call_type == CallTypes.acompletion.value ) - + if is_completion_call: messages = data.get("messages") model = data.get("model", "") @@ -431,22 +447,27 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): if file_ids: # Check user has access to all managed files await self.check_file_ids_access(file_ids, user_api_key_dict) - + # Check if any files are stored in storage backends and need base64 conversion # This is needed for Vertex AI/Gemini which requires base64 content - is_vertex_ai = model and ("vertex_ai" in model or "gemini" in model.lower()) + is_vertex_ai = model and ( + "vertex_ai" in model or "gemini" in model.lower() + ) if is_vertex_ai: await self._convert_storage_files_to_base64( messages=messages, file_ids=file_ids, litellm_parent_otel_span=user_api_key_dict.parent_otel_span, ) - + model_file_id_mapping = await self.get_model_file_id_mapping( file_ids, user_api_key_dict.parent_otel_span ) data["model_file_id_mapping"] = model_file_id_mapping - elif call_type == CallTypes.aresponses.value or call_type == CallTypes.responses.value: + elif ( + call_type == CallTypes.aresponses.value + or call_type == CallTypes.responses.value + ): # Handle managed files in responses API input and tools file_ids = [] @@ -611,7 +632,9 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): if model_id is None: model_id = cast( Optional[str], - kwargs.get("litellm_metadata", {}).get("model_info", {}).get("id", None), + kwargs.get("litellm_metadata", {}) + .get("model_info", {}) + .get("id", None), ) mapped_file_id: Optional[str] = None if input_file_id and model_file_id_mapping and model_id: @@ -648,7 +671,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) -> List[str]: """ Gets file ids from responses API input. - + The input can be: - A string (no files) - A list of input items, where each item can have: @@ -656,32 +679,35 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): - content: a list that can contain items with type: "input_file" and file_id """ file_ids: List[str] = [] - + if isinstance(input, str): return file_ids - + if not isinstance(input, list): return file_ids - + for item in input: if not isinstance(item, dict): continue - + # Check for direct input_file type if item.get("type") == "input_file": file_id = item.get("file_id") if file_id: file_ids.append(file_id) - + # Check for input_file in content array content = item.get("content") if isinstance(content, list): for content_item in content: - if isinstance(content_item, dict) and content_item.get("type") == "input_file": + if ( + isinstance(content_item, dict) + and content_item.get("type") == "input_file" + ): file_id = content_item.get("file_id") if file_id: file_ids.append(file_id) - + return file_ids def get_file_ids_from_responses_tools( @@ -689,7 +715,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) -> List[str]: """ Gets file ids from responses API tools parameter. - + The tools can contain code_interpreter with container.file_ids: [ { @@ -699,14 +725,14 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ] """ file_ids: List[str] = [] - + if not isinstance(tools, list): return file_ids - + for tool in tools: if not isinstance(tool, dict): continue - + # Check for code_interpreter with container file_ids if tool.get("type") == "code_interpreter": container = tool.get("container") @@ -716,7 +742,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): for file_id in container_file_ids: if isinstance(file_id, str): file_ids.append(file_id) - + return file_ids def get_vector_store_ids_from_file_search_tools( @@ -916,10 +942,17 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): # Emit Prometheus metrics for managed file creation prom_logger = self._get_prometheus_logger() if prom_logger: - first_model = target_model_names_list[0] if target_model_names_list else None + first_model = ( + target_model_names_list[0] if target_model_names_list else None + ) first_provider = "" if responses: - first_provider = getattr(responses[0], "_hidden_params", {}).get("custom_llm_provider") or "" + first_provider = ( + getattr(responses[0], "_hidden_params", {}).get( + "custom_llm_provider" + ) + or "" + ) prom_logger.record_managed_file_created( model=first_model or "", api_provider=first_provider, @@ -1073,16 +1106,24 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): model_name=resolved_model_name, ) setattr(response, file_attr, unified_file_id) - + # Use llm_router credentials when available. Without credentials, # Azure and other auth-required providers return 500/401. file_object = None try: # Import module and use getattr for better testability with mocks import litellm.proxy.proxy_server as proxy_server_module - _llm_router = getattr(proxy_server_module, 'llm_router', None) + + _llm_router = getattr( + proxy_server_module, "llm_router", None + ) if _llm_router is not None and model_id: - _creds = _llm_router.get_deployment_credentials_with_provider(model_id) or {} + _creds = ( + _llm_router.get_deployment_credentials_with_provider( + model_id + ) + or {} + ) file_object = await litellm.afile_retrieve( file_id=original_file_id, **_creds, @@ -1099,7 +1140,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): verbose_logger.warning( f"Failed to retrieve file object for {file_attr}={original_file_id}: {str(e)}. Storing with None and will fetch on-demand." ) - + await self.store_unified_file_id( file_id=unified_file_id, file_object=file_object, @@ -1128,6 +1169,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): from litellm.litellm_core_utils.get_llm_provider_logic import ( get_llm_provider, ) + _, batch_provider, _, _ = get_llm_provider(model=model_name) except Exception: if "/" in model_name: @@ -1199,7 +1241,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): # Case 1 : This is not a managed file if not stored_file_object: raise Exception(f"LiteLLM Managed File object with id={file_id} not found") - + # Case 2: Managed file and the file object exists in the database # The stored file_object has the raw provider ID. Replace with the unified ID # so callers see a consistent ID (matching Case 3 which does response.id = file_id). @@ -1217,13 +1259,21 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) try: - model_id, model_file_id = next(iter(stored_file_object.model_mappings.items())) - credentials = llm_router.get_deployment_credentials_with_provider(model_id) or {} - response = await litellm.afile_retrieve(file_id=model_file_id, **credentials) + model_id, model_file_id = next( + iter(stored_file_object.model_mappings.items()) + ) + credentials = ( + llm_router.get_deployment_credentials_with_provider(model_id) or {} + ) + response = await litellm.afile_retrieve( + file_id=model_file_id, **credentials + ) response.id = file_id # Replace with unified ID return response except Exception as e: - raise Exception(f"Failed to retrieve file {file_id} from provider: {str(e)}") from e + raise Exception( + f"Failed to retrieve file {file_id} from provider: {str(e)}" + ) from e async def afile_list( self, @@ -1245,19 +1295,19 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): import litellm.proxy.proxy_server as proxy_server_module # Check if the scheduler has the batch cost checking job registered - scheduler = getattr(proxy_server_module, 'scheduler', None) + scheduler = getattr(proxy_server_module, "scheduler", None) if scheduler is None: return False - + # Check if the check_batch_cost_job exists in the scheduler try: - job = scheduler.get_job('check_batch_cost_job') + job = scheduler.get_job("check_batch_cost_job") if job is not None: return True except Exception: # Job not found or scheduler doesn't support get_job pass - + return False except Exception as e: verbose_logger.warning( @@ -1265,28 +1315,26 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) return False - async def _get_batches_referencing_file( - self, file_id: str - ) -> List[Dict[str, Any]]: + async def _get_batches_referencing_file(self, file_id: str) -> List[Dict[str, Any]]: """ Find batches that reference this file and still need cost tracking. Find batches that are in non-terminal state and have not yet been processed by CheckBatchCost. Args: file_id: The unified file ID to check - + Returns: List of batch objects referencing this file in non-terminal state (max 10 for error message display) """ # Prepare list of file IDs to check (both unified and provider IDs) file_ids_to_check = [file_id] - + # Get model-specific file IDs for this unified file ID if it's a managed file try: model_file_id_mapping = await self.get_model_file_id_mapping( [file_id], litellm_parent_otel_span=None ) - + if model_file_id_mapping and file_id in model_file_id_mapping: # Add all provider file IDs for this unified file provider_file_ids = list(model_file_id_mapping[file_id].values()) @@ -1296,59 +1344,67 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): f"Could not get model file ID mapping for {file_id}: {e}. " f"Will only check unified file ID." ) - MAX_MATCHES_TO_RETURN = 10 - + MAX_MATCHES_TO_RETURN = 10 + batches = await self.prisma_client.db.litellm_managedobjecttable.find_many( where={ "file_purpose": "batch", "batch_processed": False, - "status": {"not_in": ["failed", "expired", "cancelled"]} + "status": {"not_in": ["failed", "expired", "cancelled"]}, }, take=MAX_MATCHES_TO_RETURN, order={"created_at": "desc"}, ) - + referencing_batches = [] for batch in batches: try: # Parse the batch file_object to check for file references - batch_data = json.loads(batch.file_object) if isinstance(batch.file_object, str) else batch.file_object - + batch_data = ( + json.loads(batch.file_object) + if isinstance(batch.file_object, str) + else batch.file_object + ) + # Extract file IDs from batch # Batches typically reference the unified file ID in input_file_id # Output and error files are generated by the provider input_file_id = batch_data.get("input_file_id") output_file_id = batch_data.get("output_file_id") error_file_id = batch_data.get("error_file_id") - - referenced_file_ids = [fid for fid in [input_file_id, output_file_id, error_file_id] if fid] - + + referenced_file_ids = [ + fid for fid in [input_file_id, output_file_id, error_file_id] if fid + ] + # Check if any referenced file ID matches the file we're trying to delete if any(ref_id in file_ids_to_check for ref_id in referenced_file_ids): - referencing_batches.append({ - "batch_id": batch.unified_object_id, - "status": batch.status, - "created_at": batch.created_at, - }) + referencing_batches.append( + { + "batch_id": batch.unified_object_id, + "status": batch.status, + "created_at": batch.created_at, + } + ) except Exception as e: verbose_logger.warning( f"Error parsing batch object {batch.unified_object_id}: {e}" ) continue - + return referencing_batches async def _check_file_deletion_allowed(self, file_id: str) -> None: """ Check if file deletion should be blocked due to batch references. - + Blocks deletion if: 1. File is referenced by any batch in non-terminal state, AND 2. Batch polling is configured (user wants cost tracking) - + Args: file_id: The unified file ID to check - + Raises: HTTPException: If file deletion should be blocked """ @@ -1356,39 +1412,45 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): if not self._is_batch_polling_enabled(): # Batch polling not configured, allow deletion return - + # Check if file is referenced by any non-terminal batches referencing_batches = await self._get_batches_referencing_file(file_id) - + if referencing_batches: # File is referenced by non-terminal batches and polling is enabled - MAX_BATCHES_IN_ERROR = 5 # Limit batches shown in error message for readability - + MAX_BATCHES_IN_ERROR = ( + 5 # Limit batches shown in error message for readability + ) + # Show up to MAX_BATCHES_IN_ERROR in the error message batches_to_show = referencing_batches[:MAX_BATCHES_IN_ERROR] - batch_statuses = [f"{b['batch_id']}: {b['status']}" for b in batches_to_show] - + batch_statuses = [ + f"{b['batch_id']}: {b['status']}" for b in batches_to_show + ] + # Determine the count message count_message = f"{len(referencing_batches)}" - if len(referencing_batches) >= 10: # MAX_MATCHES_TO_RETURN from _get_batches_referencing_file + if ( + len(referencing_batches) >= 10 + ): # MAX_MATCHES_TO_RETURN from _get_batches_referencing_file count_message = "10+" - + error_message = ( f"Cannot delete file {file_id}. " f"The file is referenced by {count_message} batch(es) in non-terminal state" ) - + # Add specific batch details if not too many if len(referencing_batches) <= MAX_BATCHES_IN_ERROR: error_message += f": {', '.join(batch_statuses)}. " else: error_message += f" (showing {MAX_BATCHES_IN_ERROR} most recent): {', '.join(batch_statuses)}. " - + error_message += ( f"To delete this file before complete cost tracking, please delete or cancel the referencing batch(es) first. " f"Alternatively, wait for all batches to complete and for cost to be computed (batch_processed=true)." ) - + # Record blocked deletion metric prom_logger = self._get_prometheus_logger() if prom_logger: @@ -1419,7 +1481,9 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): specific_model_file_id_mapping = model_file_id_mapping.get(file_id) if specific_model_file_id_mapping: # Remove conflicting keys from data to avoid duplicate keyword arguments - filtered_data = {k: v for k, v in data.items() if k not in ("model", "file_id")} + filtered_data = { + k: v for k, v in data.items() if k not in ("model", "file_id") + } for model_id, model_file_id in specific_model_file_id_mapping.items(): delete_response = await llm_router.afile_delete(model=model_id, file_id=model_file_id, **filtered_data) # type: ignore @@ -1480,7 +1544,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) -> None: """ Convert files stored in storage backends to base64 format for Vertex AI/Gemini. - + This method checks if any managed files are stored in storage backends, downloads them, and converts them to base64 format in the messages. """ @@ -1488,29 +1552,29 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): for file_id in file_ids: # Check if this is a base64 encoded unified file ID decoded_unified_file_id = _is_base64_encoded_unified_file_id(file_id) - + if not decoded_unified_file_id: continue - + # Check database for storage backend info # IMPORTANT: The database stores the base64 encoded unified_file_id (not the decoded version) # So we query with the original file_id (which is base64 encoded) db_file = await self.prisma_client.db.litellm_managedfiletable.find_first( where={"unified_file_id": file_id} ) - + if not db_file or not db_file.storage_backend or not db_file.storage_url: continue - + # File is stored in a storage backend, download and convert to base64 try: from litellm.llms.base_llm.files.storage_backend_factory import ( get_storage_backend, ) - + storage_backend_name = db_file.storage_backend storage_url = db_file.storage_url - + # Get storage backend (uses same env vars as callback) try: storage_backend = get_storage_backend(storage_backend_name) @@ -1519,18 +1583,22 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): f"Storage backend '{storage_backend_name}' error for file {file_id}: {str(e)}" ) continue - + file_content = await storage_backend.download_file(storage_url) - + # Determine content type from file object - content_type = self._get_content_type_from_file_object(db_file.file_object) - + content_type = self._get_content_type_from_file_object( + db_file.file_object + ) + # Convert to base64 base64_data = base64.b64encode(file_content).decode("utf-8") base64_data_uri = f"data:{content_type};base64,{base64_data}" - + # Update messages to use base64 instead of file_id - self._update_messages_with_base64_data(messages, file_id, base64_data_uri, content_type) + self._update_messages_with_base64_data( + messages, file_id, base64_data_uri, content_type + ) except Exception as e: verbose_logger.exception( f"Error converting file {file_id} from storage backend to base64: {str(e)}" @@ -1541,21 +1609,21 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): def _get_content_type_from_file_object(self, file_object: Optional[Any]) -> str: """ Determine content type from file object. - + Uses the MIME type utility for consistent detection and normalization. - + Args: file_object: The file object from the database (can be dict, JSON string, or None) - + Returns: str: MIME type (defaults to "application/octet-stream" if cannot be determined) """ # Use utility function for detection content_type = get_content_type_from_file_object(file_object) - + # Normalize for Gemini/Vertex AI (requires image/jpeg, not image/jpg) content_type = normalize_mime_type_for_provider(content_type, provider="gemini") - + return content_type def _update_messages_with_base64_data( @@ -1567,7 +1635,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): ) -> None: """ Update messages to replace file_id with base64 data URI. - + Args: messages: List of messages to update file_id: The file ID to replace @@ -1582,7 +1650,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): if element.get("type") == "file": file_element = cast(ChatCompletionFileObject, element) file_element_file = file_element.get("file", {}) - + if file_element_file.get("file_id") == file_id: # Replace file_id with base64 data file_element_file["file_data"] = base64_data_uri @@ -1590,7 +1658,7 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints): file_element_file["format"] = content_type # Remove file_id to ensure only file_data is used file_element_file.pop("file_id", None) - + verbose_logger.debug( f"Converted file {file_id} from storage backend to base64 with format {content_type}" ) diff --git a/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py b/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py index f6ed7767c4..75229bacc8 100644 --- a/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py +++ b/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py @@ -588,24 +588,21 @@ async def update_project( # noqa: PLR0915 param="project_id", ) - # Validate team exists and get team object for limit + permission checks - team_id_to_check = data.team_id or existing_project.team_id - team_obj_for_checks = None - if team_id_to_check is not None: - team_obj_for_checks = await _validate_team_exists( - team_id=team_id_to_check, prisma_client=prisma_client + # Permission to *edit* the project must be evaluated against the + # project's CURRENT team. Sourcing the team from `data.team_id` + # would let an admin of any team pass the check by supplying their + # own team_id, hijacking the project (VERIA-55). + target_team_id = data.team_id or existing_project.team_id + target_team_obj = None + if target_team_id is not None: + target_team_obj = await _validate_team_exists( + team_id=target_team_id, prisma_client=prisma_client ) - # Check if user has permission to update this project has_permission = await _check_user_permission_for_project( user_api_key_dict=user_api_key_dict, team_id=existing_project.team_id, prisma_client=prisma_client, - team_object=( - LiteLLM_TeamTable(**team_obj_for_checks.model_dump()) - if team_obj_for_checks - else None - ), ) if not has_permission: @@ -614,10 +611,32 @@ async def update_project( # noqa: PLR0915 detail={"error": "Only admins or team admins can update projects"}, ) + # Reassigning to a different team also requires admin rights on the + # destination team — otherwise a team admin could shed projects into + # an unsuspecting team's namespace. + if data.team_id is not None and data.team_id != existing_project.team_id: + can_assign_to_target = await _check_user_permission_for_project( + user_api_key_dict=user_api_key_dict, + team_id=data.team_id, + prisma_client=prisma_client, + team_object=( + LiteLLM_TeamTable(**target_team_obj.model_dump()) + if target_team_obj + else None + ), + ) + if not can_assign_to_target: + raise HTTPException( + status_code=403, + detail={ + "error": "Cannot reassign project to a team you are not an admin of" + }, + ) + # Validate project limits against team limits - if team_obj_for_checks is not None: + if target_team_obj is not None: _check_team_project_limits( - team_object=LiteLLM_TeamTable(**team_obj_for_checks.model_dump()), + team_object=LiteLLM_TeamTable(**target_team_obj.model_dump()), data=data, ) @@ -857,10 +876,16 @@ async def project_info( where={"team_id": project.team_id} ) if team: - is_team_member = ( - user_api_key_dict.user_id in team.admins - or user_api_key_dict.user_id in team.members - ) + caller_user_id = user_api_key_dict.user_id + for m in team.members_with_roles or []: + m_user_id = ( + m.get("user_id") + if isinstance(m, dict) + else getattr(m, "user_id", None) + ) + if m_user_id == caller_user_id: + is_team_member = True + break if not (is_admin or is_team_member): raise HTTPException( @@ -911,20 +936,20 @@ async def list_projects( include={"litellm_budget_table": True, "object_permission": True} ) else: - # Get projects for teams the user belongs to - user_teams = await prisma_client.db.litellm_teamtable.find_many( - where={ - "OR": [ - {"members": {"has": user_api_key_dict.user_id}}, - {"admins": {"has": user_api_key_dict.user_id}}, - ] - } + # Look up the user's team memberships via the reverse-index on + # LiteLLM_UserTable.teams (maintained by team_member_add alongside + # members_with_roles). This avoids a full scan of all team rows. + user_record = await prisma_client.db.litellm_usertable.find_unique( + where={"user_id": user_api_key_dict.user_id}, + ) + user_team_ids = ( + user_record.teams + if user_record is not None and user_record.teams + else [] ) - team_ids = [team.team_id for team in user_teams] - projects = await prisma_client.db.litellm_projecttable.find_many( - where={"team_id": {"in": team_ids}}, + where={"team_id": {"in": user_team_ids}}, include={"litellm_budget_table": True, "object_permission": True}, ) diff --git a/enterprise/pyproject.toml b/enterprise/pyproject.toml index cfbbe1f494..9698e7912d 100644 --- a/enterprise/pyproject.toml +++ b/enterprise/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "litellm-enterprise" -version = "0.1.39" +version = "0.1.40" description = "Package for LiteLLM Enterprise features" readme = "README.md" requires-python = ">=3.9" @@ -16,7 +16,7 @@ Repository = "https://github.com/BerriAI/litellm" Documentation = "https://docs.litellm.ai" [build-system] -requires = ["uv_build==0.10.7"] +requires = ["uv_build==0.11.8"] build-backend = "uv_build" [tool.uv] @@ -26,7 +26,7 @@ required-version = ">=0.10.9" module-root = "" [tool.commitizen] -version = "0.1.39" +version = "0.1.40" version_files = [ "pyproject.toml:^version", "../pyproject.toml:litellm-enterprise==", diff --git a/litellm-js/proxy/package-lock.json b/litellm-js/proxy/package-lock.json new file mode 100644 index 0000000000..0d09fa1a6c --- /dev/null +++ b/litellm-js/proxy/package-lock.json @@ -0,0 +1,2054 @@ +{ + "name": "proxy", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "hono": "4.12.16", + "openai": "4.29.2" + }, + "devDependencies": { + "@cloudflare/workers-types": "4.20260501.1", + "wrangler": "4.87.0" + } + }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz", + "integrity": "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.1.tgz", + "integrity": "sha512-ECxObrMfyTl5bhQf/lZCXwo5G6xX9IAUo+nDMKK4SZ8m4Jvvxp52vilxyySSWh2YTZz8+HQ07qGH/2rEom1vDw==", + "dev": true, + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": ">1.20260305.0 <2.0.0-0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260430.1.tgz", + "integrity": "sha512-ADohZUHf7NBvPp2PdZig2Opxx+hDkk3ve7jrTne3JRx9kDSB73zc4LzcEeEN8LKkbAcqZmvfRJfpChSlusu0lA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260430.1.tgz", + "integrity": "sha512-/DoYC/1wHs+YRZzzqSQg1/EHB4hiv1yV5U8FnmapRRIzVaPtnt+ApeOXeMrIdKidgKOI8TqQzgBU8xbIM7Cl4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260430.1.tgz", + "integrity": "sha512-koJhBWvEVZPKCVFtMLp2iMHlYr+lFCF47wGbnlKdHVlemV0zTxJEyHI8aLlrhPLhBmOmYLp46rXw09/qJkRIhQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260430.1.tgz", + "integrity": "sha512-hMdapNAzNQZDXGGkg4Slydc3fRJP5FUZLJVVcZCW/+imhhJro9Z1rv5n/wfR+txKoSWhTYR8eOp8Pyi2bzLzlw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260430.1.tgz", + "integrity": "sha512-jS3ffixjb5USOwz4frw4WzCz0HrjVxkgyU3WiYb06N7hBAfN6eOrveAJ4QRef0+suK4V1vQFoB1oKdRBsXe9Dw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workers-types": { + "version": "4.20260501.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20260501.1.tgz", + "integrity": "sha512-B/VX2w3my/sCqxKyWOX7SxUpFC1uD8Gh7I2zbI1d3zA8p7Tx03AFsnuEx8lYLmcd8yONAA93YsAZb1wAaLK83w==", + "dev": true, + "license": "MIT OR Apache-2.0" + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", + "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", + "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", + "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", + "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", + "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", + "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", + "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", + "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", + "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", + "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", + "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", + "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", + "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", + "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", + "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", + "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", + "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", + "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", + "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", + "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", + "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", + "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", + "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", + "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", + "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", + "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@speed-highlight/core": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.15.tgz", + "integrity": "sha512-BMq1K3DsElxDWawkX6eLg9+CKJrTVGCBAWVuHXVUV2u0s2711qiChLSId6ikYPfxhdYocLNt3wWwSvDiTvFabw==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/@types/node": { + "version": "18.19.130", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node-fetch": { + "version": "2.6.13", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz", + "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.4" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/agentkeepalive": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.6.0.tgz", + "integrity": "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==", + "license": "MIT", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "dev": true, + "license": "MIT" + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "license": "BSD-3-Clause", + "engines": { + "node": "*" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "license": "BSD-3-Clause", + "engines": { + "node": "*" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "license": "ISC", + "dependencies": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.27.3", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", + "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.3", + "@esbuild/android-arm": "0.27.3", + "@esbuild/android-arm64": "0.27.3", + "@esbuild/android-x64": "0.27.3", + "@esbuild/darwin-arm64": "0.27.3", + "@esbuild/darwin-x64": "0.27.3", + "@esbuild/freebsd-arm64": "0.27.3", + "@esbuild/freebsd-x64": "0.27.3", + "@esbuild/linux-arm": "0.27.3", + "@esbuild/linux-arm64": "0.27.3", + "@esbuild/linux-ia32": "0.27.3", + "@esbuild/linux-loong64": "0.27.3", + "@esbuild/linux-mips64el": "0.27.3", + "@esbuild/linux-ppc64": "0.27.3", + "@esbuild/linux-riscv64": "0.27.3", + "@esbuild/linux-s390x": "0.27.3", + "@esbuild/linux-x64": "0.27.3", + "@esbuild/netbsd-arm64": "0.27.3", + "@esbuild/netbsd-x64": "0.27.3", + "@esbuild/openbsd-arm64": "0.27.3", + "@esbuild/openbsd-x64": "0.27.3", + "@esbuild/openharmony-arm64": "0.27.3", + "@esbuild/sunos-x64": "0.27.3", + "@esbuild/win32-arm64": "0.27.3", + "@esbuild/win32-ia32": "0.27.3", + "@esbuild/win32-x64": "0.27.3" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==", + "license": "MIT" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "license": "MIT", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hono": { + "version": "4.12.16", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz", + "integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==", + "license": "MIT", + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "license": "MIT" + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "license": "BSD-3-Clause", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/miniflare": { + "version": "4.20260430.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-4.20260430.0.tgz", + "integrity": "sha512-MWvMm3Siho9Yj7lbJZidLs8hbrRvIcOrif2mnsHQZdvoKfedpea+GaN8XJxbpRcq0B2WzNI1BB1ihdnqes3/ZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "^0.34.5", + "undici": "7.24.8", + "workerd": "1.20260430.1", + "ws": "8.18.0", + "youch": "4.1.0-beta.10" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "deprecated": "Use your platform's native DOMException instead", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/openai": { + "version": "4.29.2", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.29.2.tgz", + "integrity": "sha512-cPkT6zjEcE4qU5OW/SoDDuXEsdOLrXlAORhzmaguj5xZSPlgKvLhi27sFWhLKj07Y6WKNWxcwIbzm512FzTBNQ==", + "license": "Apache-2.0", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + }, + "bin": { + "openai": "bin/cli" + } + }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, + "node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/undici": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.24.8.tgz", + "integrity": "sha512-6KQ/+QxK49Z/p3HO6E5ZCZWNnCasyZLa5ExaVYyvPxUwKtbCPMKELJOqh7EqOle0t9cH/7d2TaaTRRa6Nhs4YQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT" + }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/workerd": { + "version": "1.20260430.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260430.1.tgz", + "integrity": "sha512-KEgIWyiw3Jmn+DCd/L3ePo5fmiiYb/UcwKvDWPf/nLLOiwShDFzDSsegU5NY/JcwgvO/QsLHVi2FYrbkcXNY5Q==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260430.1", + "@cloudflare/workerd-darwin-arm64": "1.20260430.1", + "@cloudflare/workerd-linux-64": "1.20260430.1", + "@cloudflare/workerd-linux-arm64": "1.20260430.1", + "@cloudflare/workerd-windows-64": "1.20260430.1" + } + }, + "node_modules/wrangler": { + "version": "4.87.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.87.0.tgz", + "integrity": "sha512-lfhfKwLfQlowwgV0xhlYgE9fU3n0I30d4ccGY/rTCEm/n42Mjvlr0Ng3ZPNqlsrsKBcDR531V7dsPkgELvrk/Q==", + "dev": true, + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.1", + "blake3-wasm": "2.1.5", + "esbuild": "0.27.3", + "miniflare": "4.20260430.0", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260430.1" + }, + "bin": { + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^4.20260430.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + } + } +} diff --git a/litellm-js/proxy/package.json b/litellm-js/proxy/package.json index 275fd8c20d..9fd94cd882 100644 --- a/litellm-js/proxy/package.json +++ b/litellm-js/proxy/package.json @@ -4,11 +4,11 @@ "deploy": "wrangler deploy --minify src/index.ts" }, "dependencies": { - "hono": "4.12.12", + "hono": "4.12.16", "openai": "4.29.2" }, "devDependencies": { - "@cloudflare/workers-types": "4.20240208.0", - "wrangler": "3.32.0" + "@cloudflare/workers-types": "4.20260501.1", + "wrangler": "4.87.0" } } diff --git a/litellm-js/spend-logs/package-lock.json b/litellm-js/spend-logs/package-lock.json index ce1762f402..e9fc4b00f6 100644 --- a/litellm-js/spend-logs/package-lock.json +++ b/litellm-js/spend-logs/package-lock.json @@ -6,7 +6,7 @@ "": { "dependencies": { "@hono/node-server": "1.19.13", - "hono": "4.12.12" + "hono": "4.12.16" }, "devDependencies": { "@types/node": "20.19.25", @@ -548,9 +548,9 @@ } }, "node_modules/hono": { - "version": "4.12.12", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.12.tgz", - "integrity": "sha512-p1JfQMKaceuCbpJKAPKVqyqviZdS0eUxH9v82oWo1kb9xjQ5wA6iP3FNVAPDFlz5/p7d45lO+BpSk1tuSZMF4Q==", + "version": "4.12.16", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz", + "integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==", "license": "MIT", "engines": { "node": ">=16.9.0" diff --git a/litellm-js/spend-logs/package.json b/litellm-js/spend-logs/package.json index d8e6a89544..5a7a95c5de 100644 --- a/litellm-js/spend-logs/package.json +++ b/litellm-js/spend-logs/package.json @@ -4,7 +4,7 @@ }, "dependencies": { "@hono/node-server": "1.19.13", - "hono": "4.12.12" + "hono": "4.12.16" }, "devDependencies": { "@types/node": "20.19.25", diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260501195714_managed_resource_team_owner/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260501195714_managed_resource_team_owner/migration.sql new file mode 100644 index 0000000000..d6f236959b --- /dev/null +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260501195714_managed_resource_team_owner/migration.sql @@ -0,0 +1,20 @@ +-- Adds `team_id` to managed-resource tables so service-account API +-- keys (no `user_id`) can be scoped by team instead of bypassing the +-- `created_by` filter entirely. Existing rows keep `team_id = NULL` +-- and become invisible to team-only callers — that is the intended isolation +-- outcome; backfill manually if legacy rows must remain visible. +-- +-- The composite indexes match the listing query: filter by team owner, sort by +-- created_at DESC. Tables are typically small (resources per tenant, not per +-- request); a future operator with a large table can switch to +-- CREATE INDEX CONCURRENTLY in a follow-up migration. + +ALTER TABLE "LiteLLM_ManagedFileTable" ADD COLUMN IF NOT EXISTS "team_id" TEXT; +ALTER TABLE "LiteLLM_ManagedObjectTable" ADD COLUMN IF NOT EXISTS "team_id" TEXT; +ALTER TABLE "LiteLLM_ManagedVectorStoreTable" ADD COLUMN IF NOT EXISTS "team_id" TEXT; + +-- Index names follow Prisma's auto-generated convention so `prisma migrate diff` +-- against the schema is clean. +CREATE INDEX IF NOT EXISTS "LiteLLM_ManagedFileTable_team_id_created_at_idx" ON "LiteLLM_ManagedFileTable" ("team_id", "created_at" DESC); +CREATE INDEX IF NOT EXISTS "LiteLLM_ManagedObjectTable_team_id_created_at_idx" ON "LiteLLM_ManagedObjectTable" ("team_id", "created_at" DESC); +CREATE INDEX IF NOT EXISTS "LiteLLM_ManagedVectorStoreTable_team_id_created_at_idx" ON "LiteLLM_ManagedVectorStoreTable" ("team_id", "created_at" DESC); diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma index a9d3911c07..84ce99557e 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma +++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma @@ -884,28 +884,32 @@ model LiteLLM_ManagedFileTable { storage_backend String? // Storage backend name (e.g., "azure_storage", "gcs", "default") storage_url String? // The actual storage URL where the file is stored created_at DateTime @default(now()) - created_by String? + created_by String? + team_id String? // Team that owns the resource; populated for service-account keys without a user_id so listings can isolate by team. updated_at DateTime @updatedAt updated_by String? @@index([unified_file_id]) + @@index([team_id, created_at(sort: Desc)]) } -model LiteLLM_ManagedObjectTable { // for batches or finetuning jobs which use the +model LiteLLM_ManagedObjectTable { // for batches or finetuning jobs which use the id String @id @default(uuid()) unified_object_id String @unique // The base64 encoded unified file ID - model_object_id String @unique // the id returned by the backend API provider + model_object_id String @unique // the id returned by the backend API provider file_object Json // Stores the OpenAIFileObject file_purpose String // either 'batch' or 'fine-tune' - status String? // check if batch cost has been tracked + status String? // check if batch cost has been tracked batch_processed Boolean @default(false) // set to true by CheckBatchCost after cost is computed created_at DateTime @default(now()) created_by String? + team_id String? updated_at DateTime @updatedAt - updated_by String? + updated_by String? @@index([unified_object_id]) @@index([model_object_id]) + @@index([team_id, created_at(sort: Desc)]) } model LiteLLM_ManagedVectorStoreTable { @@ -918,10 +922,12 @@ model LiteLLM_ManagedVectorStoreTable { storage_url String? // Storage URL (if applicable) created_at DateTime @default(now()) created_by String? + team_id String? updated_at DateTime @updatedAt updated_by String? @@index([unified_resource_id]) + @@index([team_id, created_at(sort: Desc)]) } model LiteLLM_ManagedVectorStoresTable { diff --git a/litellm-proxy-extras/pyproject.toml b/litellm-proxy-extras/pyproject.toml index b8710da343..cd569ca08e 100644 --- a/litellm-proxy-extras/pyproject.toml +++ b/litellm-proxy-extras/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "litellm-proxy-extras" -version = "0.4.70" +version = "0.4.71" description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package." readme = "README.md" requires-python = ">=3.9" @@ -16,7 +16,7 @@ Repository = "https://github.com/BerriAI/litellm" Documentation = "https://docs.litellm.ai" [build-system] -requires = ["uv_build==0.10.7"] +requires = ["uv_build==0.11.8"] build-backend = "uv_build" [tool.uv] @@ -26,7 +26,7 @@ required-version = ">=0.10.9" module-root = "" [tool.commitizen] -version = "0.4.70" +version = "0.4.71" version_files = [ "pyproject.toml:^version", "../pyproject.toml:litellm-proxy-extras==", diff --git a/litellm/__init__.py b/litellm/__init__.py index 77fa48625d..5305edc9be 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -166,7 +166,7 @@ langfuse_default_tags: Optional[List[str]] = None langsmith_batch_size: Optional[int] = None prometheus_initialize_budget_metrics: Optional[bool] = False prometheus_latency_buckets: Optional[List[float]] = None -require_auth_for_metrics_endpoint: Optional[bool] = False +require_auth_for_metrics_endpoint: Optional[bool] = True argilla_batch_size: Optional[int] = None datadog_use_v1: Optional[bool] = False # if you want to use v1 datadog logged payload. gcs_pub_sub_use_v1: Optional[bool] = ( @@ -280,6 +280,7 @@ ssl_security_level: Optional[str] = None ssl_certificate: Optional[str] = None user_url_validation: bool = True user_url_allowed_hosts: List[str] = [] +provider_url_destination_allowed_hosts: List[str] = [] ssl_ecdh_curve: Optional[str] = ( None # Set to 'X25519' to disable PQC and improve performance ) @@ -288,6 +289,7 @@ disable_token_counter: bool = False disable_add_transform_inline_image_block: bool = False disable_add_user_agent_to_request_tags: bool = False disable_anthropic_gemini_context_caching_transform: bool = False +disable_vertex_batch_output_transformation: bool = False extra_spend_tag_headers: Optional[List[str]] = None in_memory_llm_clients_cache: "LLMClientCache" safe_memory_mode: bool = False @@ -330,6 +332,9 @@ enable_model_config_credential_overrides: bool = False enable_key_alias_format_validation: bool = ( False # opt-in validation of key_alias format on /key/generate and /key/update ) +enable_gemini_default_thinking_level_low: bool = ( + False # opt-in: force thinkingLevel low/minimal for Gemini 3 thinking param mapping +) #################### logging: bool = True enable_loadbalancing_on_batch_endpoints: Optional[bool] = None diff --git a/litellm/_logging.py b/litellm/_logging.py index d072cc549d..5ddafd6c6a 100644 --- a/litellm/_logging.py +++ b/litellm/_logging.py @@ -1,12 +1,12 @@ import ast import logging import os -import re import sys from datetime import datetime from logging import Formatter -from typing import Any, Dict, List, Optional +from typing import Any, Dict, Optional +from litellm.litellm_core_utils.secret_redaction import redact_string from litellm.litellm_core_utils.safe_json_dumps import safe_dumps from litellm.litellm_core_utils.safe_json_loads import safe_json_loads @@ -21,74 +21,11 @@ _ENABLE_SECRET_REDACTION = ( os.getenv("LITELLM_DISABLE_REDACT_SECRETS", "").lower() != "true" ) -_REDACTED = "REDACTED" - - -def _build_secret_patterns() -> re.Pattern: - patterns: List[str] = [ - # ── PEM private key / certificate blocks ── - r"-----BEGIN[A-Z \-]*PRIVATE KEY-----[\s\S]*?-----END[A-Z \-]*PRIVATE KEY-----", - # ── GCP OAuth2 access tokens (ya29.*) ── - r"\bya29\.[A-Za-z0-9_.~+/-]+", - # ── Credential %s formatting (space separator, no key= prefix) ── - r"(?:client_secret|azure_password|azure_username)\s+[^\s,'\"})\]{}>]+", - # AWS access key IDs - r"(?:AKIA|ASIA)[0-9A-Z]{16}", - # AWS secrets / session tokens / access key IDs (key=value) - r"(?:aws_secret_access_key|aws_session_token|aws_access_key_id)" - r"\s*[:=]\s*[A-Za-z0-9/+=]{20,}", - # Bearer tokens (OAuth, JWT, etc.) - r"Bearer\s+[A-Za-z0-9\-._~+/]{10,}=*", - # Basic auth headers - r"Basic\s+[A-Za-z0-9+/]{10,}={0,2}", - # OpenAI / Anthropic sk- prefixed keys - r"sk-[A-Za-z0-9\-_]{20,}", - # Generic api_key / api-key / apikey (handles 'key': 'value' dict repr) - r"(?:api[_-]?key)['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]{8,}", - # x-api-key / api-key header values (handles 'key': 'value' dict repr) - r"(?:x-api-key|api-key)['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+", - # Anthropic internal header keys - r"x-ak-[A-Za-z0-9\-_]{20,}", - # Google API keys - r"AIza[0-9A-Za-z\-_]{35}", - # Password / secret params (handles key=value and 'key': 'value') - # Word boundary prevents O(n^2) backtracking on long word-char runs. - r"(?:^|(?<=\W))\w*(?:password|passwd|client_secret|secret_key|_secret)" - r"['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+", - # Database connection string credentials (scheme://user:pass@host) - r"(?<=://)[^\s'\"]*:[^\s'\"@]+(?=@)", - # Databricks personal access tokens - r"dapi[0-9a-f]{32}", - # ── Key-name-based redaction ── - # Catches secrets inside dicts/config dumps by matching on the KEY name - # regardless of what the value looks like. - # e.g. 'master_key': 'any-value-here', "database_url": "postgres://..." - # private_key with PEM-aware value capture - r"""private_key['\"]?\s*[:=]\s*['\"]?(?:-----BEGIN[A-Z \-]*PRIVATE KEY-----[\s\S]*?-----END[A-Z \-]*PRIVATE KEY-----|[^\s,'\"})\]{}>]+)""", - r"(?:master_key|database_url|db_url|connection_string|" - r"signing_key|encryption_key|" - r"auth_token|access_token|refresh_token|" - r"slack_webhook_url|webhook_url|" - r"database_connection_string|" - r"huggingface_token|jwt_secret)" - r"""['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+""", - # ── Raw JWTs (without Bearer prefix) ── - r"\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*", - # ── Azure SAS tokens in URLs ── - r"[?&]sig=[A-Za-z0-9%+/=]+", - # ── Full JSON service-account blobs (single-line and multi-line) ── - r'\{[^{}]*"type"\s*:\s*"service_account"[^{}]*(?:\{[^{}]*\}[^{}]*)*\}', - ] - return re.compile("|".join(patterns), re.IGNORECASE) - - -_SECRET_RE = _build_secret_patterns() - def _redact_string(value: str) -> str: if not _ENABLE_SECRET_REDACTION: return value - return _SECRET_RE.sub(_REDACTED, value) + return redact_string(value) def redact_secrets(value: str) -> str: diff --git a/litellm/anthropic_beta_headers_config.json b/litellm/anthropic_beta_headers_config.json index 662b62cf20..d02afe3756 100644 --- a/litellm/anthropic_beta_headers_config.json +++ b/litellm/anthropic_beta_headers_config.json @@ -72,7 +72,7 @@ "computer-use-2025-11-24": "computer-use-2025-11-24", "context-1m-2025-08-07": "context-1m-2025-08-07", "context-management-2025-06-27": null, - "effort-2025-11-24": null, + "effort-2025-11-24": "effort-2025-11-24", "fast-mode-2026-02-01": null, "files-api-2025-04-14": null, "fine-grained-tool-streaming-2025-05-14": null, @@ -103,7 +103,7 @@ "computer-use-2025-11-24": "computer-use-2025-11-24", "context-1m-2025-08-07": "context-1m-2025-08-07", "context-management-2025-06-27": null, - "effort-2025-11-24": null, + "effort-2025-11-24": "effort-2025-11-24", "fast-mode-2026-02-01": null, "files-api-2025-04-14": null, "fine-grained-tool-streaming-2025-05-14": null, diff --git a/litellm/batches/batch_utils.py b/litellm/batches/batch_utils.py index 4b965d4e63..aaf083e75d 100644 --- a/litellm/batches/batch_utils.py +++ b/litellm/batches/batch_utils.py @@ -387,6 +387,27 @@ def _get_batch_job_total_usage_from_file_content( ) +def _get_models_from_batch_input_file_content( + file_content_dictionary: List[dict], +) -> List[str]: + """Extract the distinct ``body.model`` values from a batch *input* file. + + Used by the proxy's batch pre-call hook to enforce that the caller is + authorized for every model named inside the JSONL — not just the one + on the outer request — so the proxy's per-key model allowlist isn't + bypassed by smuggling expensive models into the batch file. + """ + models: List[str] = [] + seen: set = set() + for _item in file_content_dictionary: + body = _item.get("body") or {} + model = body.get("model") + if model and model not in seen: + seen.add(model) + models.append(model) + return models + + def _get_batch_job_input_file_usage( file_content_dictionary: List[dict], custom_llm_provider: Literal["openai", "azure", "vertex_ai"] = "openai", @@ -403,11 +424,25 @@ def _get_batch_job_input_file_usage( for _item in file_content_dictionary: body = _item.get("body", {}) model = body.get("model", model_name or "") - messages = body.get("messages", []) + # Chat completion payloads. + messages = body.get("messages") if messages: - item_tokens = token_counter(model=model, messages=messages) - prompt_tokens += item_tokens + prompt_tokens += token_counter(model=model, messages=messages) + continue + + # Text completion payloads (`prompt`). + prompt = body.get("prompt") + if prompt: + prompt_tokens += _count_prompt_or_input_tokens(model=model, value=prompt) + continue + + # Embedding payloads (`input`). + input_data = body.get("input") + if input_data: + prompt_tokens += _count_prompt_or_input_tokens( + model=model, value=input_data + ) return Usage( total_tokens=prompt_tokens + completion_tokens, @@ -416,6 +451,43 @@ def _get_batch_job_input_file_usage( ) +def _count_prompt_or_input_tokens(model: str, value: Any) -> int: + """Token-count a ``prompt`` / ``input`` field that the OpenAI batch + schema allows in four shapes: + + - ``str``: a single text prompt. + - ``list[str]``: multiple text prompts. + - ``list[int]``: a pre-tokenized prompt (each int counts as 1 token). + - ``list[list[int]]``: multiple pre-tokenized prompts. + + Pre-fix only the string shapes were counted, so a caller could send + a large ``list[list[int]]`` payload and slip past TPM rate limits + with a recorded cost of zero tokens. + """ + if isinstance(value, str): + return token_counter(model=model, text=value) + if isinstance(value, list): + total = 0 + for chunk in value: + if isinstance(chunk, str): + total += token_counter(model=model, text=chunk) + elif isinstance(chunk, int): + # Single pre-tokenized prompt at the top level: each + # int counts as one token. + total += 1 + elif isinstance(chunk, list): + # Nested pre-tokenized prompt: every int contributes a + # token. Mixed string/int items still count. + total += sum(1 if isinstance(t, int) else 0 for t in chunk) + total += sum( + token_counter(model=model, text=t) + for t in chunk + if isinstance(t, str) + ) + return total + return 0 + + def _get_batch_job_usage_from_response_body(response_body: dict) -> Usage: """ Get the tokens of a batch job from the response body diff --git a/litellm/caching/caching.py b/litellm/caching/caching.py index ce1bc26c5e..11733ce4ce 100644 --- a/litellm/caching/caching.py +++ b/litellm/caching/caching.py @@ -432,9 +432,10 @@ class Cache: str: The final hashed cache key with the redis namespace. """ dynamic_cache_control: DynamicCacheControl = kwargs.get("cache", {}) + metadata = kwargs.get("metadata") or {} namespace = ( dynamic_cache_control.get("namespace") - or kwargs.get("metadata", {}).get("redis_namespace") + or metadata.get("redis_namespace") or self.namespace ) if namespace: diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.py index 7d514e648f..3cf1d911d7 100644 --- a/litellm/caching/caching_handler.py +++ b/litellm/caching/caching_handler.py @@ -87,6 +87,18 @@ class CachingHandlerResponse(BaseModel): in_memory_cache_obj = InMemoryCache() +def _should_defer_streaming_cache_hit_callbacks(*, kwargs: Dict[str, Any]) -> bool: + """ + When stream=True, do not run success callbacks at cache-hit time. + + Cached chat/text completion replay uses CustomStreamWrapper; cached Responses + replay uses CachedResponsesAPIStreamingIterator. Both invoke logging success + handlers when the stream finishes; firing them here too would double-count + spend and callback records. + """ + return kwargs.get("stream", False) is True + + class LLMCachingHandler: def __init__( self, @@ -99,6 +111,7 @@ class LLMCachingHandler: self.async_streaming_chunks: List[ModelResponse] = [] self.sync_streaming_chunks: List[ModelResponse] = [] self.request_kwargs = request_kwargs + self.preset_cache_key: Optional[str] = None self.original_function = original_function self.start_time = start_time if litellm.cache is not None and isinstance(litellm.cache.cache, RedisCache): @@ -206,7 +219,7 @@ class LLMCachingHandler: custom_llm_provider=kwargs.get("custom_llm_provider", None), args=args, ) - if kwargs.get("stream", False) is False: + if not _should_defer_streaming_cache_hit_callbacks(kwargs=kwargs): # LOG SUCCESS self._async_log_cache_hit_on_callbacks( logging_obj=logging_obj, @@ -215,11 +228,12 @@ class LLMCachingHandler: end_time=end_time, cache_hit=cache_hit, ) - cache_key = litellm.cache.get_cache_key(**kwargs) - if ( - isinstance(cached_result, BaseModel) - or isinstance(cached_result, CustomStreamWrapper) - ) and hasattr(cached_result, "_hidden_params"): + cache_key = ( + self.preset_cache_key + or self.request_kwargs.get("cache_key") + or litellm.cache.get_cache_key(**self.request_kwargs) + ) + if hasattr(cached_result, "_hidden_params"): cached_result._hidden_params["cache_key"] = cache_key # type: ignore return CachingHandlerResponse(cached_result=cached_result) elif ( @@ -265,8 +279,6 @@ class LLMCachingHandler: kwargs: Dict[str, Any], args: Optional[Tuple[Any, ...]] = None, ) -> CachingHandlerResponse: - from litellm.utils import CustomStreamWrapper - cached_result: Optional[Any] = None # Check if caching should be performed BEFORE doing expensive kwargs copy @@ -282,6 +294,11 @@ class LLMCachingHandler: args, ) ) + if new_kwargs.get("metadata") is None: + new_kwargs.pop("metadata", None) + if new_kwargs.get("stream") is True and "cache_key" not in new_kwargs: + new_kwargs["cache_key"] = litellm.cache.get_cache_key(**new_kwargs) + self.request_kwargs = new_kwargs print_verbose("Checking Sync Cache") cached_result = litellm.cache.get_cache(**new_kwargs) if cached_result is not None: @@ -322,17 +339,19 @@ class LLMCachingHandler: is_async=False, ) - logging_obj.handle_sync_success_callbacks_for_async_calls( - result=cached_result, - start_time=start_time, - end_time=end_time, - cache_hit=cache_hit, + if not _should_defer_streaming_cache_hit_callbacks(kwargs=kwargs): + logging_obj.handle_sync_success_callbacks_for_async_calls( + result=cached_result, + start_time=start_time, + end_time=end_time, + cache_hit=cache_hit, + ) + cache_key = ( + self.preset_cache_key + or self.request_kwargs.get("cache_key") + or litellm.cache.get_cache_key(**self.request_kwargs) ) - cache_key = litellm.cache.get_cache_key(**kwargs) - if ( - isinstance(cached_result, BaseModel) - or isinstance(cached_result, CustomStreamWrapper) - ) and hasattr(cached_result, "_hidden_params"): + if hasattr(cached_result, "_hidden_params"): cached_result._hidden_params["cache_key"] = cache_key # type: ignore return CachingHandlerResponse(cached_result=cached_result) return CachingHandlerResponse(cached_result=cached_result) @@ -686,6 +705,11 @@ class LLMCachingHandler: args, ) ) + if new_kwargs.get("metadata") is None: + new_kwargs.pop("metadata", None) + if new_kwargs.get("stream") is True and "cache_key" not in new_kwargs: + new_kwargs["cache_key"] = litellm.cache.get_cache_key(**new_kwargs) + self.request_kwargs = new_kwargs cached_result: Optional[Any] = None if call_type == CallTypes.aembedding.value: if isinstance(new_kwargs["input"], str): @@ -710,14 +734,26 @@ class LLMCachingHandler: if all(result is None for result in cached_result): cached_result = None else: + request_kwargs = new_kwargs.copy() + request_cache_key = request_kwargs.pop("cache_key", None) if litellm.cache._supports_async() is True: ## check if dual cache is supported ## + self.preset_cache_key = ( + request_cache_key or litellm.cache.get_cache_key(**request_kwargs) + ) cached_result = await litellm.cache.async_get_cache( - dynamic_cache_object=self.dual_cache, **new_kwargs + dynamic_cache_object=self.dual_cache, + cache_key=self.preset_cache_key, + **request_kwargs, ) else: # fallback for caches that don't support async + self.preset_cache_key = ( + request_cache_key or litellm.cache.get_cache_key(**request_kwargs) + ) cached_result = litellm.cache.get_cache( - dynamic_cache_object=self.dual_cache, **new_kwargs + dynamic_cache_object=self.dual_cache, + cache_key=self.preset_cache_key, + **request_kwargs, ) return cached_result @@ -825,8 +861,27 @@ class LLMCachingHandler: elif (call_type == "aresponses" or call_type == "responses") and isinstance( cached_result, dict ): - # Convert cached dict back to ResponsesAPIResponse object - cached_result = ResponsesAPIResponse(**cached_result) + from litellm.responses.streaming_iterator import ( + CachedResponsesAPIStreamingIterator, + ) + + response_obj = ResponsesAPIResponse(**cached_result) + if ( + hasattr(response_obj, "_hidden_params") + and response_obj._hidden_params is not None + and isinstance(response_obj._hidden_params, dict) + ): + response_obj._hidden_params["cache_hit"] = True + + if kwargs.get("stream", False) is True: + cached_result = CachedResponsesAPIStreamingIterator( + response=response_obj, + logging_obj=logging_obj, + request_data=kwargs, + call_type=call_type, + ) + else: + cached_result = response_obj if ( hasattr(cached_result, "_hidden_params") diff --git a/litellm/caching/dual_cache.py b/litellm/caching/dual_cache.py index 6115a444ce..8060a65b78 100644 --- a/litellm/caching/dual_cache.py +++ b/litellm/caching/dual_cache.py @@ -92,6 +92,25 @@ class DualCache(BaseCache): if default_redis_ttl is not None: self.default_redis_ttl = default_redis_ttl + def attach_redis_cache( + self, + redis_cache: Optional[RedisCache] = None, + *, + default_redis_ttl: Optional[float] = None, + ) -> None: + """ + Attach a Redis backend if this DualCache does not already have one. + + No-op when ``redis_cache`` is None or when Redis was already set (constructor + or a prior attach). Use this for lazy wiring after a shared Redis client exists. + Does not backfill in-memory-only keys to Redis. + """ + if redis_cache is None or self.redis_cache is not None: + return + self.redis_cache = redis_cache + if default_redis_ttl is not None: + self.default_redis_ttl = default_redis_ttl + def set_cache(self, key, value, local_only: bool = False, **kwargs): # Update both Redis and in-memory cache try: diff --git a/litellm/caching/qdrant_semantic_cache.py b/litellm/caching/qdrant_semantic_cache.py index 5e3713e5a1..cb521efca0 100644 --- a/litellm/caching/qdrant_semantic_cache.py +++ b/litellm/caching/qdrant_semantic_cache.py @@ -11,17 +11,23 @@ Has 4 methods: import ast import asyncio import json -from typing import Any, cast +import os +from typing import Any, Dict, cast import litellm from litellm._logging import print_verbose from litellm.constants import QDRANT_SCALAR_QUANTILE, QDRANT_VECTOR_SIZE +from litellm.litellm_core_utils.prompt_templates.common_utils import ( + get_str_from_messages, +) from litellm.types.utils import EmbeddingResponse from .base_cache import BaseCache class QdrantSemanticCache(BaseCache): + CACHE_KEY_FIELD_NAME = "litellm_cache_key" + def __init__( # noqa: PLR0915 self, qdrant_api_base=None, @@ -33,8 +39,6 @@ class QdrantSemanticCache(BaseCache): host_type=None, vector_size=None, ): - import os - from litellm.llms.custom_httpx.http_handler import ( _get_httpx_client, get_async_httpx_client, @@ -115,7 +119,9 @@ class QdrantSemanticCache(BaseCache): print_verbose( f"Collection already exists.\nCollection details:{self.collection_info}" ) + self._ensure_cache_key_payload_index() else: + quantization_params: Dict[str, Any] if quantization_config is None or quantization_config == "binary": quantization_params = { "binary": { @@ -156,6 +162,7 @@ class QdrantSemanticCache(BaseCache): print_verbose( f"New collection created.\nCollection details:{self.collection_info}" ) + self._ensure_cache_key_payload_index() else: raise Exception("Error while creating new collection") @@ -170,15 +177,94 @@ class QdrantSemanticCache(BaseCache): cached_response = ast.literal_eval(cached_response) return cached_response + def _get_qdrant_cache_key_filter(self, key: str) -> dict: + return { + "must": [ + { + "key": self.CACHE_KEY_FIELD_NAME, + "match": {"value": str(key)}, + } + ] + } + + def _add_cache_key_filter_to_search_data(self, data: dict, key: str) -> None: + data["filter"] = self._get_qdrant_cache_key_filter(key) + + def _ensure_cache_key_payload_index(self) -> None: + try: + response = self.sync_client.put( + url=f"{self.qdrant_api_base}/collections/{self.collection_name}/index", + headers=self.headers, + json={ + "field_name": self.CACHE_KEY_FIELD_NAME, + "field_schema": "keyword", + }, + ) + if response.status_code not in (200, 201): + print_verbose( + "Qdrant semantic-cache could not create cache-key payload index: " + f"{response.text}" + ) + except Exception as exc: + print_verbose( + "Qdrant semantic-cache could not create cache-key payload index: " + f"{str(exc)}" + ) + + def _payload_matches_cache_key(self, payload: dict, key: str) -> bool: + # Pre-isolation points stored only prompt + response with no cache-key + # payload field. Reassigning them to a caller's key would risk + # cross-scope hits, so they're treated as misses and re-populated on + # the next set_cache. + cached_key = payload.get(self.CACHE_KEY_FIELD_NAME) + return cached_key is not None and str(cached_key) == str(key) + + async def _get_async_embedding(self, prompt: str, **kwargs) -> Any: + llm_model_list = None + llm_router = None + + try: + from litellm.proxy.proxy_server import ( + llm_model_list as proxy_llm_model_list, + llm_router as proxy_llm_router, + ) + + llm_model_list = proxy_llm_model_list + llm_router = proxy_llm_router + except ImportError: + pass + + router_model_names = ( + [m["model_name"] for m in llm_model_list] + if llm_model_list is not None + else [] + ) + if llm_router is not None and self.embedding_model in router_model_names: + user_api_key = kwargs.get("metadata", {}).get("user_api_key", "") + return await llm_router.aembedding( + model=self.embedding_model, + input=prompt, + cache={"no-store": True, "no-cache": True}, + metadata={ + "user_api_key": user_api_key, + "semantic-cache-embedding": True, + "trace_id": kwargs.get("metadata", {}).get("trace_id", None), + }, + ) + + return await litellm.aembedding( + model=self.embedding_model, + input=prompt, + cache={"no-store": True, "no-cache": True}, + ) + def set_cache(self, key, value, **kwargs): print_verbose(f"qdrant semantic-cache set_cache, kwargs: {kwargs}") from litellm._uuid import uuid # get the prompt messages = kwargs["messages"] - prompt = "" - for message in messages: - prompt += message["content"] + prompt = get_str_from_messages(messages) # create an embedding for prompt embedding_response = cast( @@ -202,6 +288,7 @@ class QdrantSemanticCache(BaseCache): "id": str(uuid.uuid4()), "vector": embedding, "payload": { + self.CACHE_KEY_FIELD_NAME: str(key), "text": prompt, "response": value, }, @@ -220,9 +307,7 @@ class QdrantSemanticCache(BaseCache): # get the messages messages = kwargs["messages"] - prompt = "" - for message in messages: - prompt += message["content"] + prompt = get_str_from_messages(messages) # convert to embedding embedding_response = cast( @@ -249,6 +334,7 @@ class QdrantSemanticCache(BaseCache): "limit": 1, "with_payload": True, } + self._add_cache_key_filter_to_search_data(data=data, key=key) search_response = self.sync_client.post( url=f"{self.qdrant_api_base}/collections/{self.collection_name}/points/search", @@ -258,21 +344,33 @@ class QdrantSemanticCache(BaseCache): results = search_response.json()["result"] if results is None: + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 return None if isinstance(results, list): if len(results) == 0: + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 return None similarity = results[0]["score"] - cached_prompt = results[0]["payload"]["text"] + payload = results[0]["payload"] + if not self._payload_matches_cache_key(payload=payload, key=key): + print_verbose("Qdrant semantic-cache hit did not match cache key scope") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 + return None + + cached_prompt = payload["text"] # check similarity, if more than self.similarity_threshold, return results print_verbose( f"semantic cache: similarity threshold: {self.similarity_threshold}, similarity: {similarity}, prompt: {prompt}, closest_cached_prompt: {cached_prompt}" ) + + # update kwargs["metadata"] with similarity, don't rewrite the original metadata + kwargs.setdefault("metadata", {})["semantic-similarity"] = similarity + if similarity >= self.similarity_threshold: # cache hit ! - cached_value = results[0]["payload"]["response"] + cached_value = payload["response"] print_verbose( f"got a cache hit, similarity: {similarity}, Current prompt: {prompt}, cached_prompt: {cached_prompt}" ) @@ -285,40 +383,12 @@ class QdrantSemanticCache(BaseCache): async def async_set_cache(self, key, value, **kwargs): from litellm._uuid import uuid - from litellm.proxy.proxy_server import llm_model_list, llm_router - print_verbose(f"async qdrant semantic-cache set_cache, kwargs: {kwargs}") # get the prompt messages = kwargs["messages"] - prompt = "" - for message in messages: - prompt += message["content"] - # create an embedding for prompt - router_model_names = ( - [m["model_name"] for m in llm_model_list] - if llm_model_list is not None - else [] - ) - if llm_router is not None and self.embedding_model in router_model_names: - user_api_key = kwargs.get("metadata", {}).get("user_api_key", "") - embedding_response = await llm_router.aembedding( - model=self.embedding_model, - input=prompt, - cache={"no-store": True, "no-cache": True}, - metadata={ - "user_api_key": user_api_key, - "semantic-cache-embedding": True, - "trace_id": kwargs.get("metadata", {}).get("trace_id", None), - }, - ) - else: - # convert to embedding - embedding_response = await litellm.aembedding( - model=self.embedding_model, - input=prompt, - cache={"no-store": True, "no-cache": True}, - ) + prompt = get_str_from_messages(messages) + embedding_response = await self._get_async_embedding(prompt, **kwargs) # get the embedding embedding = embedding_response["data"][0]["embedding"] @@ -332,6 +402,7 @@ class QdrantSemanticCache(BaseCache): "id": str(uuid.uuid4()), "vector": embedding, "payload": { + self.CACHE_KEY_FIELD_NAME: str(key), "text": prompt, "response": value, }, @@ -348,38 +419,12 @@ class QdrantSemanticCache(BaseCache): async def async_get_cache(self, key, **kwargs): print_verbose(f"async qdrant semantic-cache get_cache, kwargs: {kwargs}") - from litellm.proxy.proxy_server import llm_model_list, llm_router # get the messages messages = kwargs["messages"] - prompt = "" - for message in messages: - prompt += message["content"] + prompt = get_str_from_messages(messages) - router_model_names = ( - [m["model_name"] for m in llm_model_list] - if llm_model_list is not None - else [] - ) - if llm_router is not None and self.embedding_model in router_model_names: - user_api_key = kwargs.get("metadata", {}).get("user_api_key", "") - embedding_response = await llm_router.aembedding( - model=self.embedding_model, - input=prompt, - cache={"no-store": True, "no-cache": True}, - metadata={ - "user_api_key": user_api_key, - "semantic-cache-embedding": True, - "trace_id": kwargs.get("metadata", {}).get("trace_id", None), - }, - ) - else: - # convert to embedding - embedding_response = await litellm.aembedding( - model=self.embedding_model, - input=prompt, - cache={"no-store": True, "no-cache": True}, - ) + embedding_response = await self._get_async_embedding(prompt, **kwargs) # get the embedding embedding = embedding_response["data"][0]["embedding"] @@ -396,6 +441,7 @@ class QdrantSemanticCache(BaseCache): "limit": 1, "with_payload": True, } + self._add_cache_key_filter_to_search_data(data=data, key=key) search_response = await self.async_client.post( url=f"{self.qdrant_api_base}/collections/{self.collection_name}/points/search", @@ -414,7 +460,13 @@ class QdrantSemanticCache(BaseCache): return None similarity = results[0]["score"] - cached_prompt = results[0]["payload"]["text"] + payload = results[0]["payload"] + if not self._payload_matches_cache_key(payload=payload, key=key): + print_verbose("Qdrant semantic-cache hit did not match cache key scope") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 + return None + + cached_prompt = payload["text"] # check similarity, if more than self.similarity_threshold, return results print_verbose( @@ -426,7 +478,7 @@ class QdrantSemanticCache(BaseCache): if similarity >= self.similarity_threshold: # cache hit ! - cached_value = results[0]["payload"]["response"] + cached_value = payload["response"] print_verbose( f"got a cache hit, similarity: {similarity}, Current prompt: {prompt}, cached_prompt: {cached_prompt}" ) diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py index deee4f6ea4..cb9ce475d3 100644 --- a/litellm/caching/redis_cache.py +++ b/litellm/caching/redis_cache.py @@ -551,6 +551,13 @@ class RedisCache(BaseCache): async def async_set_cache(self, key, value, **kwargs): from redis.asyncio import Redis + if key is None: + verbose_logger.debug( + "LiteLLM Redis Caching: async set() skipped — key is None, value=%r", + value, + ) + return None + start_time = time.time() try: _redis_client: Redis = self.init_async_client() # type: ignore @@ -569,8 +576,9 @@ class RedisCache(BaseCache): ) ) verbose_logger.error( - "LiteLLM Redis Caching: async set() - Got exception from REDIS %s, Writing value=%s", + "LiteLLM Redis Caching: async set() - Got exception from REDIS %s, key=%r, value=%r", str(e), + key, value, ) raise e diff --git a/litellm/caching/redis_semantic_cache.py b/litellm/caching/redis_semantic_cache.py index c76f27377d..da9e7b1e58 100644 --- a/litellm/caching/redis_semantic_cache.py +++ b/litellm/caching/redis_semantic_cache.py @@ -35,6 +35,7 @@ class RedisSemanticCache(BaseCache): """ DEFAULT_REDIS_INDEX_NAME: str = "litellm_semantic_cache_index" + CACHE_KEY_FIELD_NAME: str = "litellm_cache_key" def __init__( self, @@ -66,8 +67,8 @@ class RedisSemanticCache(BaseCache): Exception: If similarity_threshold is not provided or required Redis connection information is missing """ - from redisvl.extensions.llmcache import SemanticCache - from redisvl.utils.vectorize import CustomTextVectorizer + from redisvl.extensions.llmcache import SemanticCache # type: ignore[import-not-found, import-untyped] + from redisvl.utils.vectorize import CustomTextVectorizer # type: ignore[import-not-found, import-untyped] if index_name is None: index_name = self.DEFAULT_REDIS_INDEX_NAME @@ -109,14 +110,94 @@ class RedisSemanticCache(BaseCache): # Initialize the Redis vectorizer and cache cache_vectorizer = CustomTextVectorizer(self._get_embedding) - self.llmcache = SemanticCache( - name=index_name, + self.llmcache = self._init_semantic_cache( + semantic_cache_cls=SemanticCache, + index_name=index_name, redis_url=redis_url, - vectorizer=cache_vectorizer, - distance_threshold=self.distance_threshold, - overwrite=False, + cache_vectorizer=cache_vectorizer, ) + @classmethod + def _cache_key_filterable_field(cls) -> Dict[str, str]: + return { + "name": cls.CACHE_KEY_FIELD_NAME, + "type": "tag", + } + + def _init_semantic_cache( + self, + semantic_cache_cls: Any, + index_name: str, + redis_url: str, + cache_vectorizer: Any, + ) -> Any: + def _is_schema_mismatch(exc: ValueError) -> bool: + error_message = str(exc).lower() + return any( + phrase in error_message + for phrase in ("schema does not match", "index schema") + ) + + try: + return semantic_cache_cls( + name=index_name, + redis_url=redis_url, + vectorizer=cache_vectorizer, + distance_threshold=self.distance_threshold, + filterable_fields=[self._cache_key_filterable_field()], + overwrite=False, + ) + except ValueError as exc: + if not _is_schema_mismatch(exc): + raise + + isolated_index_name = f"{index_name}_isolated" + print_verbose( + "Redis semantic-cache existing index schema is not isolated; " + f"using isolated index - {isolated_index_name}" + ) + try: + return semantic_cache_cls( + name=isolated_index_name, + redis_url=redis_url, + vectorizer=cache_vectorizer, + distance_threshold=self.distance_threshold, + filterable_fields=[self._cache_key_filterable_field()], + overwrite=False, + ) + except ValueError as isolated_exc: + if not _is_schema_mismatch(isolated_exc): + raise + + print_verbose( + "Redis semantic-cache isolated index schema is stale; " + f"recreating isolated index - {isolated_index_name}" + ) + return semantic_cache_cls( + name=isolated_index_name, + redis_url=redis_url, + vectorizer=cache_vectorizer, + distance_threshold=self.distance_threshold, + filterable_fields=[self._cache_key_filterable_field()], + overwrite=True, + ) + + def _get_cache_filters(self, key: str) -> Dict[str, str]: + return {self.CACHE_KEY_FIELD_NAME: str(key)} + + def _get_cache_key_filter_expression(self, key: str) -> Any: + from redisvl.query.filter import Tag # type: ignore[import-not-found, import-untyped] + + return Tag(self.CACHE_KEY_FIELD_NAME) == str(key) + + def _cache_hit_matches_key(self, cache_hit: Dict[str, Any], key: str) -> bool: + # Pre-isolation entries with no ``litellm_cache_key`` field cannot be + # safely reassigned to a caller's scope and are treated as misses. + cached_key = cache_hit.get(self.CACHE_KEY_FIELD_NAME) + if isinstance(cached_key, bytes): + cached_key = cached_key.decode("utf-8") + return cached_key is not None and str(cached_key) == str(key) + def _get_ttl(self, **kwargs) -> Optional[int]: """ Get the TTL (time-to-live) value for cache entries. @@ -188,7 +269,7 @@ class RedisSemanticCache(BaseCache): Store a value in the semantic cache. Args: - key: The cache key (not directly used in semantic caching) + key: The cache key used to isolate semantic cache entries value: The response value to cache **kwargs: Additional arguments including 'messages' for the prompt and optional 'ttl' for time-to-live @@ -206,12 +287,15 @@ class RedisSemanticCache(BaseCache): prompt = get_str_from_messages(messages) value_str = str(value) + store_kwargs: Dict[str, Any] = { + "filters": self._get_cache_filters(key), + } + # Get TTL and store in Redis semantic cache ttl = self._get_ttl(**kwargs) if ttl is not None: - self.llmcache.store(prompt, value_str, ttl=int(ttl)) - else: - self.llmcache.store(prompt, value_str) + store_kwargs["ttl"] = int(ttl) + self.llmcache.store(prompt, value_str, **store_kwargs) except Exception as e: print_verbose( f"Error setting {value_str or value} in the Redis semantic cache: {str(e)}" @@ -222,7 +306,7 @@ class RedisSemanticCache(BaseCache): Retrieve a semantically similar cached response. Args: - key: The cache key (not directly used in semantic caching) + key: The cache key used to isolate semantic cache entries **kwargs: Additional arguments including 'messages' for the prompt Returns: @@ -235,18 +319,29 @@ class RedisSemanticCache(BaseCache): messages = kwargs.get("messages", []) if not messages: print_verbose("No messages provided for semantic cache lookup") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 return None prompt = get_str_from_messages(messages) - # Check the cache for semantically similar prompts - results = self.llmcache.check(prompt=prompt) + # Check the cache for semantically similar prompts in this exact + # LiteLLM cache-key scope. + check_kwargs: Dict[str, Any] = { + "prompt": prompt, + "filter_expression": self._get_cache_key_filter_expression(key), + } + results = self.llmcache.check(**check_kwargs) # Return None if no similar prompts found if not results: + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 return None # Process the best matching result cache_hit = results[0] + if not self._cache_hit_matches_key(cache_hit=cache_hit, key=key): + print_verbose("Redis semantic-cache hit did not match cache key scope") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 + return None vector_distance = float(cache_hit["vector_distance"]) # Convert vector distance back to similarity score @@ -257,6 +352,9 @@ class RedisSemanticCache(BaseCache): cached_prompt = cache_hit["prompt"] cached_response = cache_hit["response"] + # update kwargs["metadata"] with similarity, don't rewrite the original metadata + kwargs.setdefault("metadata", {})["semantic-similarity"] = similarity + print_verbose( f"Cache hit: similarity threshold: {self.similarity_threshold}, " f"actual similarity: {similarity}, " @@ -267,6 +365,7 @@ class RedisSemanticCache(BaseCache): return self._get_cache_logic(cached_response=cached_response) except Exception as e: print_verbose(f"Error retrieving from Redis semantic cache: {str(e)}") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 async def _get_async_embedding(self, prompt: str, **kwargs) -> List[float]: """ @@ -321,7 +420,7 @@ class RedisSemanticCache(BaseCache): Asynchronously store a value in the semantic cache. Args: - key: The cache key (not directly used in semantic caching) + key: The cache key used to isolate semantic cache entries value: The response value to cache **kwargs: Additional arguments including 'messages' for the prompt and optional 'ttl' for time-to-live @@ -341,21 +440,20 @@ class RedisSemanticCache(BaseCache): # Generate embedding for the value (response) to cache prompt_embedding = await self._get_async_embedding(prompt, **kwargs) + store_kwargs: Dict[str, Any] = { + "vector": prompt_embedding, + "filters": self._get_cache_filters(key), + } + # Get TTL and store in Redis semantic cache ttl = self._get_ttl(**kwargs) if ttl is not None: - await self.llmcache.astore( - prompt, - value_str, - vector=prompt_embedding, # Pass through custom embedding - ttl=ttl, - ) - else: - await self.llmcache.astore( - prompt, - value_str, - vector=prompt_embedding, # Pass through custom embedding - ) + store_kwargs["ttl"] = ttl + await self.llmcache.astore( + prompt, + value_str, + **store_kwargs, + ) except Exception as e: print_verbose(f"Error in async_set_cache: {str(e)}") @@ -364,7 +462,7 @@ class RedisSemanticCache(BaseCache): Asynchronously retrieve a semantically similar cached response. Args: - key: The cache key (not directly used in semantic caching) + key: The cache key used to isolate semantic cache entries **kwargs: Additional arguments including 'messages' for the prompt Returns: @@ -385,17 +483,25 @@ class RedisSemanticCache(BaseCache): # Generate embedding for the prompt prompt_embedding = await self._get_async_embedding(prompt, **kwargs) - # Check the cache for semantically similar prompts - results = await self.llmcache.acheck(prompt=prompt, vector=prompt_embedding) + # Check the cache for semantically similar prompts in this exact + # LiteLLM cache-key scope. + check_kwargs: Dict[str, Any] = { + "prompt": prompt, + "vector": prompt_embedding, + "filter_expression": self._get_cache_key_filter_expression(key), + } + results = await self.llmcache.acheck(**check_kwargs) # handle results / cache hit if not results: - kwargs.setdefault("metadata", {})[ - "semantic-similarity" - ] = 0.0 # TODO why here but not above?? + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 return None cache_hit = results[0] + if not self._cache_hit_matches_key(cache_hit=cache_hit, key=key): + print_verbose("Redis semantic-cache hit did not match cache key scope") + kwargs.setdefault("metadata", {})["semantic-similarity"] = 0.0 + return None vector_distance = float(cache_hit["vector_distance"]) # Convert vector distance back to similarity diff --git a/litellm/constants.py b/litellm/constants.py index 6c889a317b..6918e40cad 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -202,6 +202,12 @@ DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET = int( DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET = int( os.getenv("DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET", 4096) ) +DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET = int( + os.getenv("DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET", 8192) +) +DEFAULT_REASONING_EFFORT_MAX_THINKING_BUDGET = int( + os.getenv("DEFAULT_REASONING_EFFORT_MAX_THINKING_BUDGET", 16384) +) MAX_TOKEN_TRIMMING_ATTEMPTS = int( os.getenv("MAX_TOKEN_TRIMMING_ATTEMPTS", 10) ) # Maximum number of attempts to trim the message @@ -399,6 +405,8 @@ BEDROCK_MAX_POLICY_SIZE = int(os.getenv("BEDROCK_MAX_POLICY_SIZE", 75)) BEDROCK_MIN_THINKING_BUDGET_TOKENS = int( os.getenv("BEDROCK_MIN_THINKING_BUDGET_TOKENS", 1024) ) +# Anthropic's Messages API rejects thinking.budget_tokens < 1024. +ANTHROPIC_MIN_THINKING_BUDGET_TOKENS = 1024 REPLICATE_POLLING_DELAY_SECONDS = float( os.getenv("REPLICATE_POLLING_DELAY_SECONDS", 0.5) ) @@ -419,9 +427,6 @@ CACHED_STREAMING_CHUNK_DELAY = float(os.getenv("CACHED_STREAMING_CHUNK_DELAY", 0 AUDIO_SPEECH_CHUNK_SIZE = int( os.getenv("AUDIO_SPEECH_CHUNK_SIZE", 8192) ) # chunk_size for audio speech streaming. Balance between latency and memory usage -MAX_SIZE_PER_ITEM_IN_MEMORY_CACHE_IN_KB = int( - os.getenv("MAX_SIZE_PER_ITEM_IN_MEMORY_CACHE_IN_KB", 512) -) DEFAULT_MAX_TOKENS_FOR_TRITON = int(os.getenv("DEFAULT_MAX_TOKENS_FOR_TRITON", 2000)) #### Networking settings #### # Sentinel used when `REQUEST_TIMEOUT` is unset: `litellm.request_timeout` keeps this diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 8a68d74be5..9b4dd80265 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -513,7 +513,10 @@ def cost_per_token( # noqa: PLR0915 return fireworks_ai_cost_per_token(model=model, usage=usage_block) elif custom_llm_provider == "azure": return azure_openai_cost_per_token( - model=model, usage=usage_block, response_time_ms=response_time_ms + model=model, + usage=usage_block, + response_time_ms=response_time_ms, + service_tier=service_tier, ) elif custom_llm_provider == "gemini": return gemini_cost_per_token( @@ -539,6 +542,7 @@ def cost_per_token( # noqa: PLR0915 usage=usage_block, response_time_ms=response_time_ms, request_model=request_model, + service_tier=service_tier, ) else: model_info = _cached_get_model_info_helper( diff --git a/litellm/files/main.py b/litellm/files/main.py index ceccba8d80..669d50dde4 100644 --- a/litellm/files/main.py +++ b/litellm/files/main.py @@ -10,6 +10,7 @@ import contextvars import time import uuid as uuid_module from functools import partial +from types import MappingProxyType from typing import Any, Coroutine, Dict, Literal, Optional, Union, cast import httpx @@ -85,6 +86,16 @@ bedrock_files_instance = BedrockFilesHandler() ################################################# +def _add_trusted_model_credentials_to_litellm_params( + litellm_params_dict: Dict[str, Any], kwargs: Dict[str, Any] +) -> None: + trusted_model_credentials = kwargs.get("_litellm_internal_model_credentials") + if isinstance(trusted_model_credentials, type(MappingProxyType({}))): + litellm_params_dict["_litellm_internal_model_credentials"] = ( + trusted_model_credentials + ) + + @client async def acreate_file( file: FileTypes, @@ -373,6 +384,10 @@ def file_retrieve( ) if provider_config is not None: litellm_params_dict = get_litellm_params(**kwargs) + _add_trusted_model_credentials_to_litellm_params( + litellm_params_dict=litellm_params_dict, + kwargs=kwargs, + ) litellm_params_dict["api_key"] = optional_params.api_key litellm_params_dict["api_base"] = optional_params.api_base @@ -497,6 +512,10 @@ def file_delete( pass optional_params = GenericLiteLLMParams(**kwargs) litellm_params_dict = get_litellm_params(**kwargs) + _add_trusted_model_credentials_to_litellm_params( + litellm_params_dict=litellm_params_dict, + kwargs=kwargs, + ) ### TIMEOUT LOGIC ### timeout = optional_params.timeout or kwargs.get("request_timeout", 600) or 600 # set timeout for 10 minutes by default @@ -846,6 +865,10 @@ def file_content( try: optional_params = GenericLiteLLMParams(**kwargs) litellm_params_dict = get_litellm_params(**kwargs) + _add_trusted_model_credentials_to_litellm_params( + litellm_params_dict=litellm_params_dict, + kwargs=kwargs, + ) ### TIMEOUT LOGIC ### timeout = optional_params.timeout or kwargs.get("request_timeout", 600) or 600 client = kwargs.get("client") @@ -993,6 +1016,7 @@ def file_content( vertex_location=vertex_ai_location, timeout=timeout, max_retries=optional_params.max_retries, + litellm_params=litellm_params_dict, ) elif custom_llm_provider == "bedrock": response = bedrock_files_instance.file_content( diff --git a/litellm/integrations/arize/_utils.py b/litellm/integrations/arize/_utils.py index 8dfaa8b142..a1bf65141c 100644 --- a/litellm/integrations/arize/_utils.py +++ b/litellm/integrations/arize/_utils.py @@ -220,23 +220,57 @@ def _set_structured_outputs(span: "Span", response_obj, msg_attrs, span_attrs): safe_set_attribute(span, f"{prefix}.{msg_attrs.MESSAGE_ROLE}", message_role) +def _safe_get(obj, key, default=None): + """Read ``key`` from a dict-like or Pydantic-model-like object. + + The arize/langfuse_otel logger receives ``usage`` objects from many sources: + plain dicts, litellm ``Usage`` (which exposes ``.get``), and raw OpenAI + Pydantic models (e.g. ``openai.types.completion_usage.CompletionUsage`` and + nested ``CompletionTokensDetails`` / ``OutputTokensDetails``) which do NOT + expose ``.get``. Calling ``.get`` on the latter raised ``AttributeError`` — + see https://github.com/BerriAI/litellm/issues/13672. + """ + if obj is None: + return default + getter = getattr(obj, "get", None) + if callable(getter): + try: + return getter(key, default) + except TypeError: + # Some objects expose `.get` with a different signature + pass + return getattr(obj, key, default) + + def _set_usage_outputs(span: "Span", response_obj, span_attrs): usage = response_obj and response_obj.get("usage") if not usage: return safe_set_attribute( - span, span_attrs.LLM_TOKEN_COUNT_TOTAL, usage.get("total_tokens") + span, span_attrs.LLM_TOKEN_COUNT_TOTAL, _safe_get(usage, "total_tokens") + ) + completion_tokens = _safe_get(usage, "completion_tokens") or _safe_get( + usage, "output_tokens" ) - completion_tokens = usage.get("completion_tokens") or usage.get("output_tokens") if completion_tokens: safe_set_attribute( span, span_attrs.LLM_TOKEN_COUNT_COMPLETION, completion_tokens ) - prompt_tokens = usage.get("prompt_tokens") or usage.get("input_tokens") + prompt_tokens = _safe_get(usage, "prompt_tokens") or _safe_get( + usage, "input_tokens" + ) if prompt_tokens: safe_set_attribute(span, span_attrs.LLM_TOKEN_COUNT_PROMPT, prompt_tokens) - reasoning_tokens = usage.get("output_tokens_details", {}).get("reasoning_tokens") + + # Reasoning tokens live in `completion_tokens_details` for Chat Completions + # API (Usage) and in `output_tokens_details` for Responses API + # (ResponseAPIUsage). Both nested objects may be plain Pydantic models + # without `.get`. + token_details = _safe_get(usage, "completion_tokens_details") or _safe_get( + usage, "output_tokens_details" + ) + reasoning_tokens = _safe_get(token_details, "reasoning_tokens") if reasoning_tokens: safe_set_attribute( span, diff --git a/litellm/integrations/arize/arize_phoenix_client.py b/litellm/integrations/arize/arize_phoenix_client.py index 3c83517bb5..8c3c2a5ff0 100644 --- a/litellm/integrations/arize/arize_phoenix_client.py +++ b/litellm/integrations/arize/arize_phoenix_client.py @@ -2,11 +2,23 @@ Arize Phoenix API client for fetching prompt versions from Arize Phoenix. """ +import urllib.parse from typing import Any, Dict, Optional from litellm.llms.custom_httpx.http_handler import HTTPHandler +def _sanitize_id(identifier: str) -> str: + """Reject path traversal characters and URL-encode the identifier.""" + if any(c in identifier for c in ("/", "\\", "#", "?")): + raise ValueError( + f"Invalid identifier {identifier!r}: contains disallowed characters" + ) + if ".." in identifier: + raise ValueError(f"Invalid identifier {identifier!r}: path traversal detected") + return urllib.parse.quote(identifier, safe="") + + class ArizePhoenixClient: """ Client for interacting with Arize Phoenix API to fetch prompt versions. @@ -53,7 +65,8 @@ class ArizePhoenixClient: Returns: Dictionary containing prompt version data, or None if not found """ - url = f"{self.api_base}/v1/prompt_versions/{prompt_version_id}" + safe_id = _sanitize_id(prompt_version_id) + url = f"{self.api_base}/v1/prompt_versions/{safe_id}" try: # Use the underlying httpx client directly to avoid query param extraction diff --git a/litellm/integrations/arize/arize_phoenix_prompt_manager.py b/litellm/integrations/arize/arize_phoenix_prompt_manager.py index 19af0bb955..df56d7bd39 100644 --- a/litellm/integrations/arize/arize_phoenix_prompt_manager.py +++ b/litellm/integrations/arize/arize_phoenix_prompt_manager.py @@ -5,7 +5,8 @@ Fetches prompt versions from Arize Phoenix and provides workspace-based access c from typing import Any, Dict, List, Optional, Tuple, Union -from jinja2 import DictLoader, Environment, select_autoescape +from jinja2 import DictLoader, select_autoescape +from jinja2.sandbox import ImmutableSandboxedEnvironment from litellm.integrations.custom_prompt_management import CustomPromptManagement from litellm.integrations.prompt_management_base import ( @@ -74,7 +75,13 @@ class ArizePhoenixTemplateManager: api_key=self.api_key, api_base=self.api_base ) - self.jinja_env = Environment( + # Templates fetched from Arize Phoenix come from external workspace + # users; in a plain `Environment()` a malicious template could reach + # `__class__.__init__.__globals__` and execute arbitrary code on the + # proxy host. The sandbox blocks that attribute traversal while + # leaving normal `{{ var }}` substitution intact. Matches the + # dotprompt manager's hardening. + self.jinja_env = ImmutableSandboxedEnvironment( loader=DictLoader({}), autoescape=select_autoescape(["html", "xml"]), # Use Mustache/Handlebars-style delimiters diff --git a/litellm/integrations/bitbucket/bitbucket_client.py b/litellm/integrations/bitbucket/bitbucket_client.py index 0502422cf8..e742cc14b7 100644 --- a/litellm/integrations/bitbucket/bitbucket_client.py +++ b/litellm/integrations/bitbucket/bitbucket_client.py @@ -3,11 +3,27 @@ BitBucket API client for fetching .prompt files from BitBucket repositories. """ import base64 +import urllib.parse from typing import Any, Dict, List, Optional from litellm.llms.custom_httpx.http_handler import HTTPHandler +def _sanitize_file_path(file_path: str) -> str: + """Reject path traversal and URL-encode each path segment.""" + if "#" in file_path or "?" in file_path: + raise ValueError( + f"Invalid file path {file_path!r}: contains URL special characters" + ) + parts = file_path.split("/") + for part in parts: + if part == "..": + raise ValueError( + f"Invalid file path {file_path!r}: path traversal detected" + ) + return "/".join(urllib.parse.quote(part, safe="") for part in parts) + + class BitBucketClient: """ Client for interacting with BitBucket API to fetch .prompt files. @@ -72,7 +88,8 @@ class BitBucketClient: Returns: File content as string, or None if file not found """ - url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{file_path}" + safe_path = _sanitize_file_path(file_path) + url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{safe_path}" try: response = self.http_handler.get(url, headers=self.headers) @@ -119,7 +136,8 @@ class BitBucketClient: Returns: List of file paths """ - url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{directory_path}" + safe_dir = _sanitize_file_path(directory_path) if directory_path else "" + url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{safe_dir}" try: response = self.http_handler.get(url, headers=self.headers) @@ -211,7 +229,8 @@ class BitBucketClient: Returns: Dictionary containing file metadata, or None if file not found """ - url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{file_path}" + safe_path = _sanitize_file_path(file_path) + url = f"{self.base_url}/repositories/{self.workspace}/{self.repository}/src/{self.branch}/{safe_path}" try: # Use GET with Range header to get just the headers (HEAD equivalent) diff --git a/litellm/integrations/bitbucket/bitbucket_prompt_manager.py b/litellm/integrations/bitbucket/bitbucket_prompt_manager.py index 701f227364..844fa9f38c 100644 --- a/litellm/integrations/bitbucket/bitbucket_prompt_manager.py +++ b/litellm/integrations/bitbucket/bitbucket_prompt_manager.py @@ -5,7 +5,8 @@ Fetches .prompt files from BitBucket repositories and provides team-based access from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union -from jinja2 import DictLoader, Environment, select_autoescape +from jinja2 import DictLoader, select_autoescape +from jinja2.sandbox import ImmutableSandboxedEnvironment from litellm.integrations.custom_prompt_management import CustomPromptManagement @@ -74,7 +75,13 @@ class BitBucketTemplateManager: self.prompts: Dict[str, BitBucketPromptTemplate] = {} self.bitbucket_client = BitBucketClient(bitbucket_config) - self.jinja_env = Environment( + # Templates fetched from a BitBucket repo are not trustworthy: + # anyone with repo write access can ship Jinja syntax that, in a + # plain `Environment()`, would reach `__class__.__init__.__globals__` + # and pivot into RCE on the proxy host. The sandbox blocks that + # attribute traversal while leaving normal `{{ var }}` substitution + # intact. Matches the dotprompt manager's hardening. + self.jinja_env = ImmutableSandboxedEnvironment( loader=DictLoader({}), autoescape=select_autoescape(["html", "xml"]), # Use Handlebars-style delimiters to match Dotprompt spec diff --git a/litellm/integrations/custom_sso_handler.py b/litellm/integrations/custom_sso_handler.py index 7f60decabc..202e488e0e 100644 --- a/litellm/integrations/custom_sso_handler.py +++ b/litellm/integrations/custom_sso_handler.py @@ -18,6 +18,17 @@ class CustomSSOLoginHandler(CustomLogger): self, request: Request, ) -> OpenID: + from litellm.proxy.auth.trusted_proxy_utils import ( + require_trusted_proxy_request, + ) + from litellm.proxy.proxy_server import general_settings + + require_trusted_proxy_request( + request=request, + general_settings=general_settings, + feature_name="Custom UI SSO", + ) + request_headers_dict = dict(request.headers) return OpenID( id=request_headers_dict.get("x-litellm-user-id"), diff --git a/litellm/integrations/gcs_bucket/gcs_bucket.py b/litellm/integrations/gcs_bucket/gcs_bucket.py index 65296bafcf..9005798423 100644 --- a/litellm/integrations/gcs_bucket/gcs_bucket.py +++ b/litellm/integrations/gcs_bucket/gcs_bucket.py @@ -6,12 +6,14 @@ import time from litellm._uuid import uuid from datetime import datetime, timedelta, timezone from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple -from urllib.parse import quote from litellm._logging import verbose_logger from litellm.constants import LITELLM_ASYNCIO_QUEUE_MAXSIZE from litellm.integrations.additional_logging_utils import AdditionalLoggingUtils from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase +from litellm.litellm_core_utils.cloud_storage_security import ( + sanitize_cloud_object_component, +) from litellm.proxy._types import CommonProxyErrors from litellm.types.integrations.base_health_check import IntegrationHealthCheckStatus from litellm.types.integrations.gcs_bucket import * @@ -335,7 +337,11 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): _litellm_params = kwargs.get("litellm_params", None) or {} _metadata = _litellm_params.get("metadata", None) or {} if "gcs_log_id" in _metadata: - object_name = _metadata["gcs_log_id"] + safe_log_id = sanitize_cloud_object_component( + _metadata.get("gcs_log_id"), fallback="" + ) + if safe_log_id: + object_name = f"{current_date}/custom-{uuid.uuid4().hex}-{safe_log_id}" return object_name @@ -367,8 +373,7 @@ class GCSBucketLogger(GCSBucketBase, AdditionalLoggingUtils): request_date_str=date_str, response_id=request_id, ) - encoded_object_name = quote(object_name, safe="") - response = await self.download_gcs_object(encoded_object_name) + response = await self.download_gcs_object(object_name) if response is not None: loaded_response = json.loads(response) diff --git a/litellm/integrations/gcs_bucket/gcs_bucket_base.py b/litellm/integrations/gcs_bucket/gcs_bucket_base.py index e84b37e689..1c5e30777a 100644 --- a/litellm/integrations/gcs_bucket/gcs_bucket_base.py +++ b/litellm/integrations/gcs_bucket/gcs_bucket_base.py @@ -11,6 +11,10 @@ from litellm.integrations.gcs_bucket.gcs_bucket_mock_client import ( from litellm._logging import verbose_logger from litellm.integrations.custom_batch_logger import CustomBatchLogger +from litellm.litellm_core_utils.cloud_storage_security import ( + encode_gcs_object_name_for_url, + split_configured_cloud_bucket_name, +) from litellm.llms.custom_httpx.http_handler import ( get_async_httpx_client, httpxSpecialProvider, @@ -133,8 +137,8 @@ class GCSBucketBase(CustomBatchLogger): - Returns: bucket_name="my-bucket", object_name="my-folder/dev/my-object" """ - if "/" in bucket_name: - bucket_name, prefix = bucket_name.split("/", 1) + bucket_name, prefix = split_configured_cloud_bucket_name(bucket_name) + if prefix: object_name = f"{prefix}/{object_name}" return bucket_name, object_name return bucket_name, object_name @@ -248,6 +252,7 @@ class GCSBucketBase(CustomBatchLogger): bucket_name=bucket_name, object_name=object_name, ) + object_name = encode_gcs_object_name_for_url(object_name) url = f"https://storage.googleapis.com/storage/v1/b/{bucket_name}/o/{object_name}?alt=media" @@ -288,6 +293,7 @@ class GCSBucketBase(CustomBatchLogger): bucket_name=bucket_name, object_name=object_name, ) + object_name = encode_gcs_object_name_for_url(object_name) url = f"https://storage.googleapis.com/storage/v1/b/{bucket_name}/o/{object_name}" @@ -334,10 +340,11 @@ class GCSBucketBase(CustomBatchLogger): bucket_name=bucket_name, object_name=object_name, ) + encoded_object_name = encode_gcs_object_name_for_url(object_name) response = await self.async_httpx_client.post( headers=headers, - url=f"https://storage.googleapis.com/upload/storage/v1/b/{bucket_name}/o?uploadType=media&name={object_name}", + url=f"https://storage.googleapis.com/upload/storage/v1/b/{bucket_name}/o?uploadType=media&name={encoded_object_name}", data=json_logged_payload, ) diff --git a/litellm/integrations/gitlab/gitlab_prompt_manager.py b/litellm/integrations/gitlab/gitlab_prompt_manager.py index b073948d76..a468741aea 100644 --- a/litellm/integrations/gitlab/gitlab_prompt_manager.py +++ b/litellm/integrations/gitlab/gitlab_prompt_manager.py @@ -4,7 +4,8 @@ GitLab prompt manager with configurable prompts folder. from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union -from jinja2 import DictLoader, Environment, select_autoescape +from jinja2 import DictLoader, select_autoescape +from jinja2.sandbox import ImmutableSandboxedEnvironment from litellm.integrations.custom_prompt_management import CustomPromptManagement @@ -90,7 +91,13 @@ class GitLabTemplateManager: or "" ).strip("/") - self.jinja_env = Environment( + # Templates fetched from a GitLab repo are not trustworthy: + # anyone with repo write access can ship Jinja syntax that, in a + # plain `Environment()`, would reach `__class__.__init__.__globals__` + # and pivot into RCE on the proxy host. The sandbox blocks that + # attribute traversal while leaving normal `{{ var }}` substitution + # intact. Matches the dotprompt manager's hardening. + self.jinja_env = ImmutableSandboxedEnvironment( loader=DictLoader({}), autoescape=select_autoescape(["html", "xml"]), variable_start_string="{{", diff --git a/litellm/integrations/langfuse/langfuse.py b/litellm/integrations/langfuse/langfuse.py index e691c490c8..0efc7d6687 100644 --- a/litellm/integrations/langfuse/langfuse.py +++ b/litellm/integrations/langfuse/langfuse.py @@ -90,6 +90,29 @@ def _extract_cache_read_input_tokens(usage_obj) -> int: return cache_read_input_tokens +def resolve_langfuse_credentials( + langfuse_public_key=None, + langfuse_secret=None, + langfuse_secret_key=None, + langfuse_host=None, + allow_env_credentials: bool = True, +): + if allow_env_credentials is False and langfuse_host is not None: + secret_key = langfuse_secret or langfuse_secret_key + public_key = langfuse_public_key + else: + secret_key = ( + langfuse_secret or langfuse_secret_key or os.getenv("LANGFUSE_SECRET_KEY") + ) + public_key = langfuse_public_key or os.getenv("LANGFUSE_PUBLIC_KEY") + + resolved_host = langfuse_host or os.getenv( + "LANGFUSE_HOST", "https://cloud.langfuse.com" + ) + + return public_key, secret_key, resolved_host + + class LangFuseLogger: # Class variables or attributes def __init__( @@ -98,6 +121,7 @@ class LangFuseLogger: langfuse_secret=None, langfuse_host=None, flush_interval=1, + allow_env_credentials: bool = True, ): try: import langfuse @@ -106,11 +130,13 @@ class LangFuseLogger: raise Exception( f"\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n{traceback.format_exc()}\033[0m" ) - # Instance variables - self.secret_key = langfuse_secret or os.getenv("LANGFUSE_SECRET_KEY") - self.public_key = langfuse_public_key or os.getenv("LANGFUSE_PUBLIC_KEY") - self.langfuse_host = langfuse_host or os.getenv( - "LANGFUSE_HOST", "https://cloud.langfuse.com" + self.public_key, self.secret_key, self.langfuse_host = ( + resolve_langfuse_credentials( + langfuse_public_key=langfuse_public_key, + langfuse_secret=langfuse_secret, + langfuse_host=langfuse_host, + allow_env_credentials=allow_env_credentials, + ) ) if not ( self.langfuse_host.startswith("http://") @@ -160,9 +186,10 @@ class LangFuseLogger: project_id = None if os.getenv("UPSTREAM_LANGFUSE_SECRET_KEY") is not None: + upstream_langfuse_debug_env = os.getenv("UPSTREAM_LANGFUSE_DEBUG") upstream_langfuse_debug = ( - str_to_bool(self.upstream_langfuse_debug) - if self.upstream_langfuse_debug is not None + str_to_bool(upstream_langfuse_debug_env) + if upstream_langfuse_debug_env is not None else None ) self.upstream_langfuse_secret_key = os.getenv( @@ -173,7 +200,7 @@ class LangFuseLogger: ) self.upstream_langfuse_host = os.getenv("UPSTREAM_LANGFUSE_HOST") self.upstream_langfuse_release = os.getenv("UPSTREAM_LANGFUSE_RELEASE") - self.upstream_langfuse_debug = os.getenv("UPSTREAM_LANGFUSE_DEBUG") + self.upstream_langfuse_debug = upstream_langfuse_debug_env self.upstream_langfuse = Langfuse( public_key=self.upstream_langfuse_public_key, secret_key=self.upstream_langfuse_secret_key, diff --git a/litellm/integrations/langfuse/langfuse_handler.py b/litellm/integrations/langfuse/langfuse_handler.py index fbadf1a2fc..4a80972642 100644 --- a/litellm/integrations/langfuse/langfuse_handler.py +++ b/litellm/integrations/langfuse/langfuse_handler.py @@ -115,8 +115,10 @@ class LangFuseHandler: langfuse_logger = LangFuseLogger( langfuse_public_key=credentials.get("langfuse_public_key"), - langfuse_secret=credentials.get("langfuse_secret"), + langfuse_secret=credentials.get("langfuse_secret") + or credentials.get("langfuse_secret_key"), langfuse_host=credentials.get("langfuse_host"), + allow_env_credentials=credentials.get("langfuse_host") is None, ) in_memory_dynamic_logger_cache.set_cache( credentials=credentials, diff --git a/litellm/integrations/langfuse/langfuse_prompt_management.py b/litellm/integrations/langfuse/langfuse_prompt_management.py index 5f4ced3a5c..b7a565512c 100644 --- a/litellm/integrations/langfuse/langfuse_prompt_management.py +++ b/litellm/integrations/langfuse/langfuse_prompt_management.py @@ -20,7 +20,7 @@ from ...litellm_core_utils.specialty_caches.dynamic_logging_cache import ( DynamicLoggingCache, ) from ..prompt_management_base import PromptManagementBase -from .langfuse import LangFuseLogger +from .langfuse import LangFuseLogger, resolve_langfuse_credentials from .langfuse_handler import LangFuseHandler if TYPE_CHECKING: @@ -46,6 +46,7 @@ def langfuse_client_init( langfuse_secret_key=None, langfuse_host=None, flush_interval=1, + allow_env_credentials: bool = True, ) -> LangfuseClass: """ Initialize Langfuse client with caching to prevent multiple initializations. @@ -70,14 +71,12 @@ def langfuse_client_init( f"\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n\033[0m" ) - # Instance variables - - secret_key = ( - langfuse_secret or langfuse_secret_key or os.getenv("LANGFUSE_SECRET_KEY") - ) - public_key = langfuse_public_key or os.getenv("LANGFUSE_PUBLIC_KEY") - langfuse_host = langfuse_host or os.getenv( - "LANGFUSE_HOST", "https://cloud.langfuse.com" + public_key, secret_key, langfuse_host = resolve_langfuse_credentials( + langfuse_public_key=langfuse_public_key, + langfuse_secret=langfuse_secret, + langfuse_secret_key=langfuse_secret_key, + langfuse_host=langfuse_host, + allow_env_credentials=allow_env_credentials, ) if not ( @@ -222,6 +221,7 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLogge langfuse_secret=dynamic_callback_params.get("langfuse_secret"), langfuse_secret_key=dynamic_callback_params.get("langfuse_secret_key"), langfuse_host=dynamic_callback_params.get("langfuse_host"), + allow_env_credentials=dynamic_callback_params.get("langfuse_host") is None, ) langfuse_prompt_client = self._get_prompt_from_id( langfuse_prompt_id=prompt_id, @@ -246,6 +246,7 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLogge langfuse_secret=dynamic_callback_params.get("langfuse_secret"), langfuse_secret_key=dynamic_callback_params.get("langfuse_secret_key"), langfuse_host=dynamic_callback_params.get("langfuse_host"), + allow_env_credentials=dynamic_callback_params.get("langfuse_host") is None, ) langfuse_prompt_client = self._get_prompt_from_id( langfuse_prompt_id=prompt_id, diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py index 3d4fd39ebe..81570e462c 100644 --- a/litellm/integrations/langsmith.py +++ b/litellm/integrations/langsmith.py @@ -19,6 +19,7 @@ from litellm.integrations.langsmith_mock_client import ( create_mock_langsmith_client, should_use_langsmith_mock, ) +from litellm.litellm_core_utils.redact_messages import redact_user_api_key_info from litellm.llms.custom_httpx.http_handler import ( get_async_httpx_client, httpxSpecialProvider, @@ -112,17 +113,28 @@ class LangsmithLogger(CustomBatchLogger): langsmith_project: Optional[str] = None, langsmith_base_url: Optional[str] = None, langsmith_tenant_id: Optional[str] = None, + allow_env_credentials: bool = True, ) -> LangsmithCredentialsObject: - _credentials_api_key = langsmith_api_key or os.getenv("LANGSMITH_API_KEY") - _credentials_project = ( - langsmith_project or os.getenv("LANGSMITH_PROJECT") or "litellm-completion" - ) - _credentials_base_url = ( - langsmith_base_url - or os.getenv("LANGSMITH_BASE_URL") - or "https://api.smith.langchain.com" - ) - _credentials_tenant_id = langsmith_tenant_id or os.getenv("LANGSMITH_TENANT_ID") + if allow_env_credentials is False and langsmith_base_url is not None: + _credentials_api_key = langsmith_api_key + _credentials_project = langsmith_project or "litellm-completion" + _credentials_base_url = langsmith_base_url + _credentials_tenant_id = langsmith_tenant_id + else: + _credentials_api_key = langsmith_api_key or os.getenv("LANGSMITH_API_KEY") + _credentials_project = ( + langsmith_project + or os.getenv("LANGSMITH_PROJECT") + or "litellm-completion" + ) + _credentials_base_url = ( + langsmith_base_url + or os.getenv("LANGSMITH_BASE_URL") + or "https://api.smith.langchain.com" + ) + _credentials_tenant_id = langsmith_tenant_id or os.getenv( + "LANGSMITH_TENANT_ID" + ) return LangsmithCredentialsObject( LANGSMITH_API_KEY=_credentials_api_key, @@ -153,6 +165,15 @@ class LangsmithLogger(CustomBatchLogger): for key in ("session_id", "thread_id", "conversation_id"): if key in requester_metadata and key not in extra_metadata: extra_metadata[key] = requester_metadata[key] + + # helper is shallow; also scrub nested requester_metadata since + # LangSmith forwards the whole dict into `extra` + extra_metadata = redact_user_api_key_info(metadata=extra_metadata) + nested = extra_metadata.get("requester_metadata") + if isinstance(nested, dict): + extra_metadata["requester_metadata"] = redact_user_api_key_info( + metadata=nested + ) return extra_metadata def _build_outputs_with_usage( @@ -540,6 +561,10 @@ class LangsmithLogger(CustomBatchLogger): langsmith_tenant_id=standard_callback_dynamic_params.get( "langsmith_tenant_id", None ), + allow_env_credentials=standard_callback_dynamic_params.get( + "langsmith_base_url", None + ) + is None, ) else: credentials = self.default_credentials diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index b6d91d0b76..77833e5de0 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -69,6 +69,8 @@ class OpenTelemetryConfig: deployment_environment: Optional[str] = None model_id: Optional[str] = None ignore_context_propagation: Optional[bool] = None + # When True, create a private TracerProvider instead of reusing or setting the global one. + skip_set_global: bool = False def __post_init__(self) -> None: # If endpoint is specified but exporter is still the default "console", @@ -259,16 +261,21 @@ class OpenTelemetry(CustomLogger): try: existing_provider = get_existing_provider_fn() - # If a real SDK provider exists (set by another SDK like Langfuse), use it - # This uses a positive check for SDK providers instead of a negative check for proxy providers if isinstance(existing_provider, sdk_provider_class): - verbose_logger.debug( - "OpenTelemetry: Using existing %s: %s", - provider_name, - type(existing_provider).__name__, - ) - provider = existing_provider - # Don't call set_provider to preserve existing context + if skip_set_global: + verbose_logger.debug( + "OpenTelemetry: existing %s found but skip_set_global=True; creating private %s for isolation", + provider_name, + provider_name, + ) + provider = create_new_provider_fn() + else: + verbose_logger.debug( + "OpenTelemetry: Using existing %s: %s", + provider_name, + type(existing_provider).__name__, + ) + provider = existing_provider else: # Default proxy provider or unknown type, create our own verbose_logger.debug("OpenTelemetry: Creating new %s", provider_name) @@ -293,6 +300,12 @@ class OpenTelemetry(CustomLogger): return provider + def _skip_set_global(self) -> bool: + # langfuse_otel relies on the Langfuse SDK's providers; don't overwrite them. + return self.config.skip_set_global or ( + hasattr(self, "callback_name") and self.callback_name == "langfuse_otel" + ) + def _init_tracing(self, tracer_provider): from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider @@ -303,11 +316,6 @@ class OpenTelemetry(CustomLogger): provider.add_span_processor(self._get_span_processor()) return provider - # CRITICAL FIX: For Langfuse OTEL, skip setting global provider to prevent interference - skip_global = ( - hasattr(self, "callback_name") and self.callback_name == "langfuse_otel" - ) - tracer_provider = self._get_or_create_provider( provider=tracer_provider, provider_name="TracerProvider", @@ -315,16 +323,18 @@ class OpenTelemetry(CustomLogger): sdk_provider_class=TracerProvider, create_new_provider_fn=create_tracer_provider, set_provider_fn=trace.set_tracer_provider, - skip_set_global=skip_global, + skip_set_global=self._skip_set_global(), ) # Grab our tracer from the TracerProvider (not from global context) # This ensures we use the provided TracerProvider (e.g., for testing) self.tracer = tracer_provider.get_tracer(LITELLM_TRACER_NAME) + self._tracer_provider = tracer_provider self.span_kind = SpanKind def _init_metrics(self, meter_provider): if not self.config.enable_metrics: + self._meter_provider = None self._operation_duration_histogram = None self._token_usage_histogram = None self._cost_histogram = None @@ -350,7 +360,9 @@ class OpenTelemetry(CustomLogger): sdk_provider_class=MeterProvider, create_new_provider_fn=create_meter_provider, set_provider_fn=metrics.set_meter_provider, + skip_set_global=self._skip_set_global(), ) + self._meter_provider = meter_provider meter = meter_provider.get_meter(__name__) @@ -388,6 +400,7 @@ class OpenTelemetry(CustomLogger): def _init_logs(self, logger_provider): # nothing to do if events disabled if not self.config.enable_events: + self._logger_provider = None return from opentelemetry._logs import get_logger_provider, set_logger_provider @@ -404,13 +417,14 @@ class OpenTelemetry(CustomLogger): ) return provider - self._get_or_create_provider( + self._logger_provider = self._get_or_create_provider( provider=logger_provider, provider_name="LoggerProvider", get_existing_provider_fn=get_logger_provider, sdk_provider_class=OTLoggerProvider, create_new_provider_fn=create_logger_provider, set_provider_fn=set_logger_provider, + skip_set_global=self._skip_set_global(), ) def log_success_event(self, kwargs, response_obj, start_time, end_time): @@ -1073,7 +1087,7 @@ class OpenTelemetry(CustomLogger): # See: https://github.com/open-telemetry/opentelemetry-python/pull/4676 # TODO: Refactor to use the proper OTEL Logs API instead of directly creating SDK LogRecords - from opentelemetry._logs import SeverityNumber, get_logger + from opentelemetry._logs import SeverityNumber try: from opentelemetry.sdk._logs import ( # type: ignore[attr-defined] # OTEL < 1.39.0 @@ -1084,7 +1098,10 @@ class OpenTelemetry(CustomLogger): LogRecord as SdkLogRecord, # type: ignore[attr-defined] # OTEL >= 1.39.0 ) - otel_logger = get_logger(LITELLM_LOGGER_NAME) + # Resolve through the handler's own LoggerProvider (which may be a + # private one when skip_set_global=True) rather than the module-level + # get_logger() which always goes through the global provider. + otel_logger = self._logger_provider.get_logger(LITELLM_LOGGER_NAME) parent_ctx = span.get_span_context() provider = (kwargs.get("litellm_params") or {}).get( diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index 723b142dfa..7d3856ea63 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -265,6 +265,7 @@ class PrometheusLogger(CustomLogger): ######################################## # LiteLLM Virtual API KEY metrics ######################################## + # Remaining MODEL RPM limit for API Key self.litellm_remaining_api_key_requests_for_model = self._gauge_factory( "litellm_remaining_api_key_requests_for_model", @@ -1928,7 +1929,7 @@ class PrometheusLogger(CustomLogger): or _litellm_params_metadata.get("user_agent"), } - def set_llm_deployment_failure_metrics(self, request_kwargs: dict): + def set_llm_deployment_failure_metrics(self, request_kwargs: dict): # noqa: PLR0915 """ Sets Failure metrics when an LLM API call fails @@ -2006,17 +2007,32 @@ class PrometheusLogger(CustomLogger): if code is not None: exception_status = str(code) - # Create enum_values for the label factory (always create for use in different metrics) + # On LiteLLM-side rejects (no deployment picked), route request_kwargs["model"] + # into requested_model and leave deployment-scoped labels empty. + deployment_selected = bool(model_id) + if deployment_selected: + label_litellm_model_name = litellm_model_name + label_model_id = model_id + label_api_base = api_base + label_api_provider = llm_provider + label_requested_model = model_group or litellm_model_name + else: + label_litellm_model_name = "" + label_model_id = "" + label_api_base = "" + label_api_provider = "" + label_requested_model = litellm_model_name or model_group or "" + enum_values = UserAPIKeyLabelValues( - litellm_model_name=litellm_model_name, - model_id=model_id, - api_base=api_base, - api_provider=llm_provider, + litellm_model_name=label_litellm_model_name, + model_id=label_model_id, + api_base=label_api_base, + api_provider=label_api_provider, exception_status=exception_status, exception_class=( self._get_exception_class_name(exception) if exception else None ), - requested_model=model_group or litellm_model_name, + requested_model=label_requested_model, hashed_api_key=hashed_api_key, api_key_alias=api_key_alias, team=team, @@ -2030,12 +2046,14 @@ class PrometheusLogger(CustomLogger): log these labels ["litellm_model_name", "model_id", "api_base", "api_provider"] """ - self.set_deployment_partial_outage( - litellm_model_name=litellm_model_name or "", - model_id=model_id, - api_base=api_base, - api_provider=llm_provider or "", - ) + # Only mark a deployment outage when one was actually picked. + if deployment_selected: + self.set_deployment_partial_outage( + litellm_model_name=litellm_model_name or "", + model_id=model_id, + api_base=api_base, + api_provider=llm_provider or "", + ) _deployment_label_ctx = PrometheusLabelFactoryContext(enum_values) if exception is not None: PrometheusLogger._inc_labeled_counter( diff --git a/litellm/integrations/prometheus_helpers/prometheus_api.py b/litellm/integrations/prometheus_helpers/prometheus_api.py index b25da57723..0901d7b680 100644 --- a/litellm/integrations/prometheus_helpers/prometheus_api.py +++ b/litellm/integrations/prometheus_helpers/prometheus_api.py @@ -2,6 +2,7 @@ Helper functions to query prometheus API """ +import json import time from datetime import datetime, timedelta from typing import Optional @@ -81,6 +82,24 @@ def is_prometheus_connected() -> bool: return False +def _quote_promql_string_literal(value: str) -> str: + """Render ``value`` as a PromQL double-quoted string literal. + + PromQL string literals follow Go's escape rules + (https://prometheus.io/docs/prometheus/latest/querying/basics/): a + backslash begins an escape sequence and a bare ``"`` ends the literal. + Without escaping, callers that accept arbitrary user-supplied values + (like the ``api_key`` filter on ``/global/spend/logs``) can inject extra + label matchers or selectors and read cross-tenant metrics. + + JSON's quoting rules are a strict subset of Go's, so ``json.dumps`` of + a Python string produces a literal Prometheus accepts: ``\\``, ``\\"``, + and the standard ``\\n`` / ``\\t`` / ``\\uNNNN`` control-character + escapes. The returned value already includes the surrounding quotes. + """ + return json.dumps(value, ensure_ascii=False) + + async def get_daily_spend_from_prometheus(api_key: Optional[str]): """ Expected Response Format: @@ -109,8 +128,11 @@ async def get_daily_spend_from_prometheus(api_key: Optional[str]): if api_key is None: query = "sum(delta(litellm_spend_metric_total[1d]))" else: + quoted_api_key = _quote_promql_string_literal(api_key) query = ( - f'sum(delta(litellm_spend_metric_total{{hashed_api_key="{api_key}"}}[1d]))' + "sum(delta(litellm_spend_metric_total{" + f"hashed_api_key={quoted_api_key}" + "}[1d]))" ) params = { diff --git a/litellm/litellm_core_utils/cli_token_utils.py b/litellm/litellm_core_utils/cli_token_utils.py index e2e304931a..3776d27691 100644 --- a/litellm/litellm_core_utils/cli_token_utils.py +++ b/litellm/litellm_core_utils/cli_token_utils.py @@ -31,15 +31,23 @@ def load_cli_token() -> Optional[dict]: return None -def get_litellm_gateway_api_key() -> Optional[str]: +def get_litellm_gateway_api_key( + expected_base_url: Optional[str] = None, +) -> Optional[str]: """ Get the stored CLI API key for use with LiteLLM SDK. This function reads the token file created by `litellm-proxy login` and returns the API key for use in Python scripts. + Args: + expected_base_url: When provided, the key is only returned if it was + originally issued for this URL. Pass the target server URL to + prevent credential leakage when the client is pointed at a + different (possibly malicious) server. + Returns: - str: The API key if found, None otherwise + str: The API key if found (and origin matches), None otherwise Example: >>> import litellm @@ -53,6 +61,10 @@ def get_litellm_gateway_api_key() -> Optional[str]: >>> ) """ token_data = load_cli_token() - if token_data and "key" in token_data: - return token_data["key"] - return None + if not token_data or "key" not in token_data: + return None + if expected_base_url is not None: + stored_url = token_data.get("base_url") + if stored_url != expected_base_url.rstrip("/"): + return None + return token_data["key"] diff --git a/litellm/litellm_core_utils/cloud_storage_security.py b/litellm/litellm_core_utils/cloud_storage_security.py new file mode 100644 index 0000000000..daa3dc6032 --- /dev/null +++ b/litellm/litellm_core_utils/cloud_storage_security.py @@ -0,0 +1,175 @@ +import posixpath +import re +from types import MappingProxyType +from typing import Any, Mapping, Optional, Sequence, Tuple, cast +from urllib.parse import quote, unquote + +from litellm._uuid import uuid + +VERTEX_AI_MANAGED_GCS_PREFIX = "litellm-vertex-files/" +BEDROCK_MANAGED_S3_BATCH_PREFIX = "litellm-bedrock-files-" +BEDROCK_MANAGED_S3_UPLOAD_PREFIX = "litellm-bedrock-files/" +BEDROCK_MANAGED_S3_OUTPUT_PREFIX = "litellm-batch-outputs/" +BEDROCK_MANAGED_S3_PREFIXES = ( + BEDROCK_MANAGED_S3_BATCH_PREFIX, + BEDROCK_MANAGED_S3_UPLOAD_PREFIX, + BEDROCK_MANAGED_S3_OUTPUT_PREFIX, +) +_MAPPING_PROXY_TYPE: type = type(MappingProxyType({})) + +_SAFE_OBJECT_COMPONENT_PATTERN = re.compile(r"[^A-Za-z0-9._-]+") + + +def sanitize_cloud_object_component( + value: Optional[str], fallback: str = "file" +) -> str: + if not isinstance(value, str): + return fallback + + component = posixpath.basename(value.replace("\\", "/")).strip() + if component in {"", ".", ".."}: + return fallback + + component = "".join( + "_" if ord(char) < 32 or ord(char) == 127 else char for char in component + ) + component = _SAFE_OBJECT_COMPONENT_PATTERN.sub("_", component) + component = component.strip("._") + if not component: + return fallback + return component[:255] + + +def sanitize_cloud_object_path(value: Optional[str], fallback: str = "file") -> str: + if not isinstance(value, str): + return fallback + + segments = [] + for segment in value.replace("\\", "/").split("/"): + sanitized_segment = sanitize_cloud_object_component(segment, fallback="") + if sanitized_segment: + segments.append(sanitized_segment) + + if not segments: + return fallback + return "/".join(segments) + + +def build_managed_cloud_object_name( + prefix: str, filename: Optional[str], fallback_filename: str = "file" +) -> str: + safe_filename = sanitize_cloud_object_component( + filename, fallback=fallback_filename + ) + return f"{prefix}{uuid.uuid4().hex}-{safe_filename}" + + +def _validate_cloud_object_path(object_name: str) -> None: + if not object_name: + raise ValueError("Cloud storage object name is required") + if object_name.startswith("/"): + raise ValueError("Cloud storage object name must be relative") + if any(ord(char) < 32 or ord(char) == 127 for char in object_name): + raise ValueError("Cloud storage object name contains control characters") + segments = object_name.split("/") + if any(segment in {".", ".."} for segment in segments): + raise ValueError("Cloud storage object name contains an invalid path segment") + if "" in segments[:-1]: + raise ValueError("Cloud storage object name contains an invalid path segment") + + +def split_configured_cloud_bucket_name(bucket_name: str) -> Tuple[str, str]: + if not isinstance(bucket_name, str) or not bucket_name.strip(): + raise ValueError("Cloud storage bucket name is required") + + bucket_name = bucket_name.strip() + if "://" in bucket_name or "?" in bucket_name or "#" in bucket_name: + raise ValueError( + "Cloud storage bucket name must not include a URI scheme or query" + ) + if any(ord(char) < 32 or ord(char) == 127 for char in bucket_name): + raise ValueError("Cloud storage bucket name contains control characters") + + bucket, _, prefix = bucket_name.partition("/") + if not bucket: + raise ValueError("Cloud storage bucket name is required") + if "\\" in bucket: + raise ValueError("Cloud storage bucket name contains an invalid separator") + + prefix = prefix.strip("/") + if prefix: + _validate_cloud_object_path(prefix) + + return bucket, prefix + + +def encode_gcs_object_name_for_url(object_name: str) -> str: + return quote(unquote(object_name), safe="") + + +def encode_s3_object_key_for_url(object_key: str) -> str: + return quote(unquote(object_key), safe="/") + + +def should_allow_legacy_cloud_file_ids( + litellm_params: Optional[Mapping[str, Any]] = None, +) -> bool: + value = None + if isinstance(litellm_params, Mapping): + trusted_model_credentials = litellm_params.get( + "_litellm_internal_model_credentials" + ) + if isinstance(trusted_model_credentials, _MAPPING_PROXY_TYPE): + value = cast(Mapping[str, Any], trusted_model_credentials).get( + "allow_legacy_cloud_file_ids" + ) + + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.strip().lower() in {"1", "true", "yes", "on"} + return False + + +def validate_managed_cloud_file_id( + file_id: str, + scheme: str, + configured_bucket_name: str, + allowed_object_prefixes: Sequence[str], + allow_legacy_cloud_file_ids: bool = False, +) -> Tuple[str, str]: + decoded_file_id = unquote(file_id) + if not decoded_file_id.startswith(scheme): + raise ValueError(f"file_id must be a {scheme} URI") + + full_path = decoded_file_id[len(scheme) :] + if "/" not in full_path: + raise ValueError("file_id must include a cloud storage object name") + + bucket_name, object_name = full_path.split("/", 1) + configured_bucket, configured_prefix = split_configured_cloud_bucket_name( + configured_bucket_name + ) + if bucket_name != configured_bucket: + raise ValueError("file_id bucket does not match the configured storage bucket") + + _validate_cloud_object_path(object_name) + allowed_prefixes = tuple(allowed_object_prefixes) + if configured_prefix: + allowed_prefixes = tuple( + f"{configured_prefix.rstrip('/')}/{prefix}" for prefix in allowed_prefixes + ) + + if object_name.startswith(allowed_prefixes): + return bucket_name, object_name + + if allow_legacy_cloud_file_ids: + if configured_prefix and not object_name.startswith( + f"{configured_prefix.rstrip('/')}/" + ): + raise ValueError( + "file_id object does not match the configured storage prefix" + ) + return bucket_name, object_name + + raise ValueError("file_id must reference a LiteLLM-managed storage object") diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py index 5a7d4e33b6..2c1d92920a 100644 --- a/litellm/litellm_core_utils/exception_mapping_utils.py +++ b/litellm/litellm_core_utils/exception_mapping_utils.py @@ -6,7 +6,8 @@ from typing import Any, Optional import httpx import litellm -from litellm._logging import _redact_string, verbose_logger +from litellm._logging import _ENABLE_SECRET_REDACTION, _redact_string, verbose_logger +from litellm.litellm_core_utils.secret_redaction import redact_string from litellm.types.utils import LlmProviders from ..exceptions import ( @@ -261,10 +262,18 @@ def exception_type( # type: ignore # noqa: PLR0915 original_exception=original_exception ) try: - error_str = str(original_exception) + error_str = ( + redact_string(str(original_exception)) + if _ENABLE_SECRET_REDACTION + else str(original_exception) + ) if model: if hasattr(original_exception, "message"): - error_str = str(original_exception.message) + error_str = ( + redact_string(str(original_exception.message)) + if _ENABLE_SECRET_REDACTION + else str(original_exception.message) + ) if isinstance(original_exception, BaseException): exception_type = type(original_exception).__name__ else: @@ -2431,7 +2440,8 @@ def exception_type( # type: ignore # noqa: PLR0915 else: raise APIConnectionError( message="{}\n{}".format( - str(original_exception), _redact_string(traceback.format_exc()) + str(original_exception), + _redact_string(traceback.format_exc()), ), llm_provider=custom_llm_provider, model=model, @@ -2461,7 +2471,8 @@ def exception_type( # type: ignore # noqa: PLR0915 raise e # it's already mapped raised_exc = APIConnectionError( message="{}\n{}".format( - original_exception, _redact_string(traceback.format_exc()) + original_exception, + _redact_string(traceback.format_exc()), ), llm_provider="", model="", diff --git a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py index ffb6436f38..a89dae5231 100644 --- a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py +++ b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py @@ -37,8 +37,6 @@ _supported_callback_params = [ "langfuse_secret_key", "langfuse_host", "langfuse_prompt_version", - "gcs_bucket_name", - "gcs_path_service_account", "langsmith_api_key", "langsmith_project", "langsmith_base_url", @@ -57,6 +55,11 @@ _supported_callback_params = [ "lunary_public_key", ] +_request_blocked_callback_params = { + "gcs_bucket_name", + "gcs_path_service_account", +} + def initialize_standard_callback_dynamic_params( kwargs: Optional[Dict] = None, @@ -64,13 +67,15 @@ def initialize_standard_callback_dynamic_params( """ Initialize the standard callback dynamic params from the kwargs - checks if langfuse_secret_key, gcs_bucket_name in kwargs and sets the corresponding attributes in StandardCallbackDynamicParams + checks supported request callback params in kwargs and sets the corresponding attributes in StandardCallbackDynamicParams """ standard_callback_dynamic_params = StandardCallbackDynamicParams() if kwargs: # 1. Check top-level kwargs for param in _supported_callback_params: + if param in _request_blocked_callback_params: + continue if param in kwargs: _param_value = kwargs.get(param) validate_no_callback_env_reference( @@ -86,6 +91,8 @@ def initialize_standard_callback_dynamic_params( if isinstance(metadata, dict): for param in _supported_callback_params: + if param in _request_blocked_callback_params: + continue if param not in standard_callback_dynamic_params and param in metadata: _param_value = metadata.get(param) validate_no_callback_env_reference( diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 829c1c9ca0..a815442c2f 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -3242,10 +3242,15 @@ class Logging(LiteLLMLoggingBaseClass): ), langfuse_secret=self.standard_callback_dynamic_params.get( "langfuse_secret" - ), + ) + or self.standard_callback_dynamic_params.get("langfuse_secret_key"), langfuse_host=self.standard_callback_dynamic_params.get( "langfuse_host" ), + allow_env_credentials=self.standard_callback_dynamic_params.get( + "langfuse_host" + ) + is None, ) return langFuseLogger @@ -4720,7 +4725,7 @@ class StandardLoggingPayloadSetup: ): for key, value in litellm_params["metadata"].items(): # Skip non-serializable objects like UserAPIKeyAuth - if key == "user_api_key_auth": + if key in {"user_api_key_auth", "user_api_key_budget_reservation"}: continue merged_metadata[key] = value diff --git a/litellm/litellm_core_utils/llm_request_utils.py b/litellm/litellm_core_utils/llm_request_utils.py index f5f28822ca..7be7085297 100644 --- a/litellm/litellm_core_utils/llm_request_utils.py +++ b/litellm/litellm_core_utils/llm_request_utils.py @@ -77,8 +77,8 @@ def get_proxy_server_request_headers(litellm_params: Optional[dict]) -> dict: if litellm_params is None: return {} - proxy_request_headers = ( - litellm_params.get("proxy_server_request", {}).get("headers", {}) or {} - ) + proxy_request_headers = (litellm_params.get("proxy_server_request") or {}).get( + "headers" + ) or {} return proxy_request_headers diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index 3a83162fb2..ba840bc3d8 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -4582,6 +4582,11 @@ class BedrockConverseMessagesProcessor: message=cast(ChatCompletionFileObject, element) ) _parts.append(_part) + elif element["type"] == "document": + _part = BedrockConverseMessagesProcessor._process_document_message( + element + ) + _parts.append(_part) _cache_point_block = ( litellm.AmazonConverseConfig()._get_cache_point_block( message_block=cast( @@ -4864,6 +4869,44 @@ class BedrockConverseMessagesProcessor: image_url=cast(str, file_id or file_data), format=format ) + @staticmethod + def _process_document_message(element: dict) -> BedrockContentBlock: + """Convert a document content block to a Bedrock DocumentBlock. + + Handles the Anthropic-style document format: + {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "..."}} + """ + source = element["source"] + source_type = source.get("type") + if source_type != "base64": + raise ValueError( + f"Bedrock Converse only supports base64-encoded document sources, got '{source_type}'. " + "Please convert the document to base64 before sending to Bedrock." + ) + media_type: str = source["media_type"] + data: str = source["data"] + doc_format = BedrockImageProcessor._validate_format( + mime_type=media_type, image_format=media_type.split("/")[1] + ) + + # Deterministic name using the same hashing pattern as _create_bedrock_block + HASH_SAMPLE_BYTES = 64 * 1024 + normalized = "".join(data.split()).encode("utf-8") + sample = normalized[:HASH_SAMPLE_BYTES] + hasher = hashlib.sha256() + hasher.update(sample) + hasher.update(str(len(normalized)).encode("utf-8")) + content_hash = hasher.hexdigest()[:16] + document_name = f"Document_{content_hash}_{doc_format}" + + return BedrockContentBlock( + document=BedrockDocumentBlock( + source=BedrockSourceBlock(bytes=data), + format=doc_format, + name=document_name, + ) + ) + @staticmethod def add_thinking_blocks_to_assistant_content( thinking_blocks: List[BedrockContentBlock], @@ -4961,6 +5004,11 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915 ) ) _parts.append(_part) + elif element["type"] == "document": + _part = BedrockConverseMessagesProcessor._process_document_message( + element + ) + _parts.append(_part) _cache_point_block = ( litellm.AmazonConverseConfig()._get_cache_point_block( message_block=cast( diff --git a/litellm/litellm_core_utils/secret_redaction.py b/litellm/litellm_core_utils/secret_redaction.py new file mode 100644 index 0000000000..5c4e3e3dac --- /dev/null +++ b/litellm/litellm_core_utils/secret_redaction.py @@ -0,0 +1,81 @@ +""" +Credential/secret redaction utilities. + +This module owns the compiled regex and the public `redact_string` helper so +that any part of the codebase (logging, exception mapping, etc.) can scrub +secrets from strings without depending on the logging-configuration module. +""" + +import re +from typing import List + +_REDACTED = "REDACTED" + + +def _build_secret_patterns() -> "re.Pattern[str]": + patterns: List[str] = [ + # PEM private key / certificate blocks + r"-----BEGIN[A-Z \-]*PRIVATE KEY-----[\s\S]*?-----END[A-Z \-]*PRIVATE KEY-----", + # GCP OAuth2 access tokens (ya29.*) + r"\bya29\.[A-Za-z0-9_.~+/-]+", + # Credential %s formatting (space separator, no key= prefix) + r"(?:client_secret|azure_password|azure_username)\s+[^\s,'\"})\]{}>]+", + # AWS access key IDs + r"(?:AKIA|ASIA)[0-9A-Z]{16}", + # AWS secrets / session tokens / access key IDs (key=value) + r"(?:aws_secret_access_key|aws_session_token|aws_access_key_id)" + r"\s*[:=]\s*[A-Za-z0-9/+=]{20,}", + # Bearer tokens (OAuth, JWT, etc.) + r"Bearer\s+[A-Za-z0-9\-._~+/]{10,}=*", + # Basic auth headers + r"Basic\s+[A-Za-z0-9+/]{10,}={0,2}", + # OpenAI / Anthropic sk- prefixed keys + r"sk-[A-Za-z0-9\-_]{20,}", + # Generic api_key / api-key / apikey (handles 'key': 'value' dict repr) + r"(?:api[_-]?key)['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]{8,}", + # x-api-key / api-key header values (handles 'key': 'value' dict repr) + r"(?:x-api-key|api-key)['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+", + # Anthropic internal header keys + r"x-ak-[A-Za-z0-9\-_]{20,}", + # Google API keys (bare key value) + r"AIza[0-9A-Za-z\-_]{35}", + # URL query-param key=VALUE (e.g. ?key=AIza... or &key=...) — catches the + # full "key=" fragment so the value is redacted regardless of format. + r"(?<=[?&])key=[^\s&'\"]{8,}", + # Password / secret params (handles key=value and 'key': 'value') + # Word boundary prevents O(n^2) backtracking on long word-char runs. + r"(?:^|(?<=\W))\w*(?:password|passwd|client_secret|secret_key|_secret)" + r"['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+", + # Database connection string credentials (scheme://user:pass@host) + r"(?<=://)[^\s'\"]*:[^\s'\"@]+(?=@)", + # Databricks personal access tokens + r"dapi[0-9a-f]{32}", + # ── Key-name-based redaction ── + # Catches secrets inside dicts/config dumps by matching on the KEY name + # regardless of what the value looks like. + # e.g. 'master_key': 'any-value-here', "database_url": "postgres://..." + # private_key with PEM-aware value capture + r"""private_key['\"]?\s*[:=]\s*['\"]?(?:-----BEGIN[A-Z \-]*PRIVATE KEY-----[\s\S]*?-----END[A-Z \-]*PRIVATE KEY-----|[^\s,'\"})\]{}>]+)""", + r"(?:master_key|database_url|db_url|connection_string|" + r"signing_key|encryption_key|" + r"auth_token|access_token|refresh_token|" + r"slack_webhook_url|webhook_url|" + r"database_connection_string|" + r"huggingface_token|jwt_secret)" + r"""['\"]?\s*[:=]\s*['\"]?[^\s,'\"})\]{}>]+""", + # Raw JWTs (without Bearer prefix) + r"\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*", + # Azure SAS tokens in URLs + r"[?&]sig=[A-Za-z0-9%+/=]+", + # Full JSON service-account blobs (single-line and multi-line) + r'\{[^{}]*"type"\s*:\s*"service_account"[^{}]*(?:\{[^{}]*\}[^{}]*)*\}', + ] + return re.compile("|".join(patterns), re.IGNORECASE) + + +_SECRET_RE = _build_secret_patterns() + + +def redact_string(value: str) -> str: + """Scrub known secret/credential patterns from *value* and return the result.""" + return _SECRET_RE.sub(_REDACTED, value) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index e281b17268..fa7faf3035 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -2244,7 +2244,7 @@ class CustomStreamWrapper: asyncio.create_task( self.logging_obj.async_failure_handler(e, traceback_exception) ) - raise e + self._handle_stream_fallback_error(e) except Exception as e: traceback_exception = traceback.format_exc() if self.logging_obj is not None: diff --git a/litellm/litellm_core_utils/url_utils.py b/litellm/litellm_core_utils/url_utils.py index a65d0892aa..38a78ee058 100644 --- a/litellm/litellm_core_utils/url_utils.py +++ b/litellm/litellm_core_utils/url_utils.py @@ -21,8 +21,8 @@ Admins can opt out via two ``litellm`` globals (wired from proxy config): import socket from ipaddress import ip_address, ip_network -from typing import Any, List, Set, Tuple -from urllib.parse import urlparse, urlunparse +from typing import Any, List, Optional, Set, Tuple +from urllib.parse import quote, urlparse, urlunparse import httpx @@ -46,6 +46,46 @@ class SSRFError(ValueError): pass +def encode_url_path_segment(value: Any, *, field_name: str = "path parameter") -> str: + """Percent-encode one user-controlled URL path segment. + + ``urllib.parse.quote(..., safe="")`` intentionally leaves RFC 3986 + unreserved characters such as ``.`` unescaped, so reject standalone dot + segments before they can be appended to an upstream URL and normalized by + the HTTP client. + """ + if value is None: + raise ValueError(f"{field_name} is required") + + value_str = str(value) + if value_str == "": + raise ValueError(f"{field_name} is required") + if value_str in {".", ".."}: + raise ValueError(f"{field_name} cannot be a dot path segment") + + return quote(value_str, safe="") + + +def encode_url_path_segments(value: Any, *, field_name: str = "path") -> str: + """Percent-encode a user-controlled URL path made of multiple segments. + + Empty segments are rejected, so leading, trailing, or consecutive slashes + fail closed instead of being normalized by the HTTP client. + """ + if value is None: + raise ValueError(f"{field_name} is required") + + value_str = str(value) + if value_str == "": + raise ValueError(f"{field_name} is required") + + encoded_segments = [] + for segment in value_str.split("/"): + encoded_segments.append(encode_url_path_segment(segment, field_name=field_name)) + + return "/".join(encoded_segments) + + def _is_blocked_ip(addr: str) -> bool: """Return True for any IP not safe to reach from a user-supplied URL. @@ -70,6 +110,85 @@ def _normalize_host(host: str) -> str: return host.lower().rstrip(".") +def _default_port_for_scheme(scheme: str) -> int: + return 443 if scheme == "https" else 80 + + +def _parse_url_destination_allowlist_entry( + entry: str, +) -> Optional[Tuple[str, Optional[str], Optional[int]]]: + """Parse an admin allowlist entry into host, optional scheme, optional port. + + Entries may be bare hosts (``api.example.com``), host+port + (``api.example.com:8443``), or origins (``https://api.example.com``). + URL paths are intentionally ignored so admins can paste an api_base value. + """ + entry = entry.strip() + if not entry: + return None + + has_scheme = "://" in entry + parsed = urlparse(entry if has_scheme else f"//{entry}") + if has_scheme and parsed.scheme not in _ALLOWED_SCHEMES: + return None + if parsed.username is not None or parsed.password is not None: + return None + if not parsed.hostname: + return None + + try: + port = parsed.port + except ValueError: + return None + + scheme: Optional[str] = parsed.scheme if has_scheme else None + if scheme is not None and port is None: + port = _default_port_for_scheme(scheme) + + return _normalize_host(parsed.hostname), scheme, port + + +def is_url_destination_allowed_by_host(url: str, allowed_hosts: List[str]) -> bool: + """Return True when a credential-bearing provider URL is admin-allowlisted. + + This does not fetch, resolve, or rewrite URLs. It only answers whether the + destination origin is explicitly trusted by configuration. Use ``safe_get`` + for user-controlled content fetches that require SSRF protection. + """ + parsed = urlparse(url) + if parsed.scheme not in _ALLOWED_SCHEMES: + return False + if parsed.username is not None or parsed.password is not None: + return False + if not parsed.hostname: + return False + + try: + effective_port = parsed.port or _default_port_for_scheme(parsed.scheme) + except ValueError: + return False + + normalized_host = _normalize_host(parsed.hostname) + configured_entries = ( + [allowed_hosts] if isinstance(allowed_hosts, str) else allowed_hosts + ) + for entry in configured_entries or []: + if not isinstance(entry, str): + continue + parsed_entry = _parse_url_destination_allowlist_entry(entry) + if parsed_entry is None: + continue + allowed_host, allowed_scheme, allowed_port = parsed_entry + if allowed_host != normalized_host: + continue + if allowed_scheme is not None and allowed_scheme != parsed.scheme: + continue + if allowed_port is not None and allowed_port != effective_port: + continue + return True + return False + + def _format_host_header(hostname: str, port: int, default_port: int) -> str: """Build an RFC 7230 Host header value, bracketing IPv6 literals.""" bracketed = f"[{hostname}]" if ":" in hostname else hostname @@ -145,7 +264,7 @@ def validate_url(url: str) -> Tuple[str, str]: raise SSRFError("URL has no hostname") port = parsed.port - default_port = 443 if parsed.scheme == "https" else 80 + default_port = _default_port_for_scheme(parsed.scheme) effective_port = port if port is not None else default_port host_header = _format_host_header(hostname, effective_port, default_port) @@ -199,13 +318,54 @@ def validate_url(url: str) -> Tuple[str, str]: return rewritten, host_header +def assert_same_origin(candidate_url: str, expected_url: str) -> None: + """Verify ``candidate_url`` shares scheme, host, and port with ``expected_url``. + + Use when an upstream API returns a URL meant for follow-up requests + (e.g. an async-job polling URL that will be hit with the operator's + API key in the headers). The upstream is trusted because the operator + configured ``api_base``, but the URL it hands back must actually point + back at the same origin or we'd be blindly forwarding credentials + wherever the upstream told us to. + + Hostnames are compared case-insensitively. Default ports are made + explicit (HTTP→80, HTTPS→443) so ``https://api.example.com:443/...`` + and ``https://api.example.com/...`` are treated as the same origin. + + Error messages identify *which* component mismatched but never echo + the operator's ``expected`` host or the candidate's hostname back to + the caller — in the SSRF threat model the caller is the attacker, + and reflecting host info would be a secondary leak of operator + infrastructure details. + """ + candidate = urlparse(candidate_url) + expected = urlparse(expected_url) + + if candidate.scheme not in _ALLOWED_SCHEMES: + raise SSRFError("URL scheme is not allowed") + + if candidate.scheme != expected.scheme: + raise SSRFError("Origin mismatch on scheme") + + candidate_host = _normalize_host(candidate.hostname or "") + expected_host = _normalize_host(expected.hostname or "") + if not candidate_host or candidate_host != expected_host: + raise SSRFError("Origin mismatch on host") + + default_port = 443 if candidate.scheme == "https" else 80 + candidate_port = candidate.port if candidate.port is not None else default_port + expected_port = expected.port if expected.port is not None else default_port + if candidate_port != expected_port: + raise SSRFError("Origin mismatch on port") + + _MAX_REDIRECTS = 10 def _extract_redirect_url(response: Any, request_url: str) -> str: """Extract and resolve the redirect target from a response's Location header.""" location = response.headers.get("location") - if not location: + if not isinstance(location, str) or not location: raise SSRFError("Redirect response has no Location header") # Resolve relative URLs against the request URL return str(httpx.URL(request_url).join(location)) diff --git a/litellm/llms/anthropic/batches/transformation.py b/litellm/llms/anthropic/batches/transformation.py index 3f03c744ef..fd67a7fbaf 100644 --- a/litellm/llms/anthropic/batches/transformation.py +++ b/litellm/llms/anthropic/batches/transformation.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, cas import httpx from httpx import Headers, Response +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.batches.transformation import BaseBatchesConfig from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.types.llms.openai import AllMessageValues, CreateBatchRequest @@ -122,7 +123,8 @@ class AnthropicBatchesConfig(BaseBatchesConfig): Complete URL for Anthropic batch retrieval: {api_base}/v1/messages/batches/{batch_id} """ api_base = api_base or self.anthropic_model_info.get_api_base(api_base) - return f"{api_base.rstrip('/')}/v1/messages/batches/{batch_id}" + encoded_batch_id = encode_url_path_segment(batch_id, field_name="batch_id") + return f"{api_base.rstrip('/')}/v1/messages/batches/{encoded_batch_id}" def transform_retrieve_batch_request( self, diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 61ddf801a2..345558a69f 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1,18 +1,31 @@ import json import re import time -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast +from typing import ( + TYPE_CHECKING, + Any, + Dict, + List, + NoReturn, + Optional, + Tuple, + Union, + cast, +) import httpx import litellm from litellm.constants import ( + ANTHROPIC_MIN_THINKING_BUDGET_TOKENS, ANTHROPIC_WEB_SEARCH_TOOL_MAX_USES, DEFAULT_ANTHROPIC_CHAT_MAX_TOKENS, DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET, + DEFAULT_REASONING_EFFORT_MAX_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, + DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET, RESPONSE_FORMAT_TOOL_NAME, ) from litellm.litellm_core_utils.core_helpers import map_finish_reason @@ -92,6 +105,22 @@ else: LoggingClass = Any +REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT: Dict[str, str] = { + "low": "low", + "minimal": "low", + "medium": "medium", + "high": "high", + "xhigh": "xhigh", + "max": "max", +} + +DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING = ( + "Dropping unsupported `output_config` for model=%s " + "(drop_params=True). Effort is only supported on Opus 4.5+, " + "Sonnet 4.6+, and Mythos Preview." +) + + class AnthropicConfig(AnthropicModelInfo, BaseConfig): """ Reference: https://docs.anthropic.com/claude/reference/messages_post @@ -202,17 +231,96 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): def _supports_effort_level(model: str, level: str) -> bool: """Check ``supports_{level}_reasoning_effort`` in the model map. - Mirrors the pattern used in ``openai/chat/gpt_5_transformation.py`` so - that adding support for a new effort level is a pure model-map change. + Strips bedrock/vertex prefixes so a provider-routed Claude still + resolves to the Anthropic model-map entry. """ + key = f"supports_{level}_reasoning_effort" try: - return _supports_factory( + if _supports_factory( model=model, custom_llm_provider="anthropic", - key=f"supports_{level}_reasoning_effort", - ) + key=key, + ): + return True except Exception: - return False + pass + candidates = [model] + for prefix in ( + "bedrock/converse/", + "bedrock/invoke/", + "bedrock/", + "vertex_ai/", + ): + if model.startswith(prefix): + candidates.append(model[len(prefix) :]) + try: + from litellm.llms.bedrock.common_utils import BedrockModelInfo + + base = BedrockModelInfo.get_base_model(model) + if base: + candidates.append(base) + candidates.append(f"bedrock/{base}") + except Exception: + pass + try: + import litellm + + for cand in candidates: + if cand in litellm.model_cost and ( + litellm.model_cost[cand].get(key) is True + ): + return True + except Exception: + pass + return False + + @staticmethod + def _validate_effort_for_model(model: str, effort: Optional[str]) -> Optional[str]: + """Return ``None`` if ``effort`` is allowed on ``model``, else an error message.""" + if effort == "max" and not ( + AnthropicConfig._is_claude_4_6_model(model) + or AnthropicConfig._is_claude_4_7_model(model) + or AnthropicConfig._supports_effort_level(model, "max") + ): + return f"effort='max' is not supported by this model. Got model: {model}" + if effort == "xhigh" and not AnthropicConfig._supports_effort_level( + model, "xhigh" + ): + return f"effort='xhigh' is not supported by this model. Got model: {model}" + return None + + @staticmethod + def _model_supports_effort_param(model: str) -> bool: + """Whether the model accepts ``output_config.effort`` at all.""" + return any( + AnthropicConfig._supports_effort_level(model, level) + for level in ("low", "minimal", "medium", "high", "xhigh", "max") + ) + + @staticmethod + def _raise_invalid_reasoning_effort( + model: str, value: Any, llm_provider: str + ) -> NoReturn: + """Raise a ``BadRequestError`` for an unrecognised ``reasoning_effort``. + + Args: + model: The model id the request was routed to (surfaced in the error). + value: The offending ``reasoning_effort`` value supplied by the caller. + llm_provider: Provider tag for the raised exception (``"anthropic"``, + ``"bedrock_converse"``, ``"databricks"``, ...). + + Raises: + litellm.exceptions.BadRequestError: Always. + """ + raise litellm.exceptions.BadRequestError( + message=( + f"Invalid reasoning_effort: {value!r}. " + f"Must be one of: 'minimal', 'low', 'medium', " + f"'high', 'xhigh', 'max', 'none'" + ), + model=model, + llm_provider=llm_provider, + ) def get_supported_openai_params(self, model: str): params = [ @@ -794,12 +902,11 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): def _map_reasoning_effort( reasoning_effort: Optional[Union[REASONING_EFFORT, str]], model: str, + llm_provider: str = "anthropic", ) -> Optional[AnthropicThinkingParam]: if reasoning_effort is None or reasoning_effort == "none": return None - if AnthropicConfig._is_claude_4_6_model( - model - ) or AnthropicConfig._is_claude_4_7_model(model): + if AnthropicConfig._is_adaptive_thinking_model(model): return AnthropicThinkingParam( type="adaptive", ) @@ -818,13 +925,34 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): type="enabled", budget_tokens=DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, ) + elif reasoning_effort == "xhigh": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET, + ) + elif reasoning_effort == "max": + return AnthropicThinkingParam( + type="enabled", + budget_tokens=DEFAULT_REASONING_EFFORT_MAX_THINKING_BUDGET, + ) elif reasoning_effort == "minimal": return AnthropicThinkingParam( type="enabled", - budget_tokens=DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, + budget_tokens=max( + DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, + ANTHROPIC_MIN_THINKING_BUDGET_TOKENS, + ), ) else: - raise ValueError(f"Unmapped reasoning effort: {reasoning_effort}") + raise litellm.exceptions.BadRequestError( + message=( + f"Unmapped reasoning effort: {reasoning_effort!r}. " + f"Must be one of: 'minimal', 'low', 'medium', 'high', " + f"'xhigh', 'max', 'none'." + ), + model=model, + llm_provider=llm_provider, + ) def _extract_json_schema_from_response_format( self, value: Optional[dict] @@ -1088,24 +1216,27 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): elif param == "thinking": optional_params["thinking"] = value elif param == "reasoning_effort" and isinstance(value, str): - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - reasoning_effort=value, model=model + mapped_thinking = AnthropicConfig._map_reasoning_effort( + reasoning_effort=value, + model=model, + llm_provider=self.custom_llm_provider or "anthropic", ) - # For Claude 4.6+ models, effort is controlled via output_config, - # not thinking budget_tokens. Map reasoning_effort to output_config. - if AnthropicConfig._is_claude_4_6_model( - model - ) or AnthropicConfig._is_claude_4_7_model(model): - effort_map = { - "low": "low", - "minimal": "low", - "medium": "medium", - "high": "high", - "xhigh": "xhigh", - "max": "max", - } - mapped_effort = effort_map.get(value, value) - optional_params["output_config"] = {"effort": mapped_effort} + if mapped_thinking is None: + optional_params.pop("thinking", None) + optional_params.pop("output_config", None) + else: + optional_params["thinking"] = mapped_thinking + if AnthropicConfig._is_adaptive_thinking_model(model): + mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( + value + ) + if mapped_effort is None: + AnthropicConfig._raise_invalid_reasoning_effort( + model=model, + value=value, + llm_provider=self.custom_llm_provider or "anthropic", + ) + optional_params["output_config"] = {"effort": mapped_effort} elif param == "web_search_options" and isinstance(value, dict): hosted_web_search_tool = self.map_web_search_tool( cast(OpenAIWebSearchOptions, value) @@ -1527,29 +1658,31 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): output_config = optional_params.get("output_config") if not output_config or not isinstance(output_config, dict): return + if litellm.drop_params is True and not self._model_supports_effort_param(model): + litellm.verbose_logger.warning( + DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING, + model, + ) + optional_params.pop("output_config", None) + data.pop("output_config", None) + return effort = output_config.get("effort") valid_efforts = ["high", "medium", "low", "xhigh", "max"] - if effort and effort not in valid_efforts: - raise ValueError( - f"Invalid effort value: {effort}. Must be one of: " - f"'high', 'medium', 'low', 'xhigh', 'max'" + if effort is not None and effort not in valid_efforts: + raise litellm.exceptions.BadRequestError( + message=( + f"Invalid effort value: {effort!r}. Must be one of: " + f"'high', 'medium', 'low', 'xhigh', 'max'" + ), + model=model, + llm_provider=self.custom_llm_provider or "anthropic", ) - # ``max`` is for Opus 4.6+ output effort (not Sonnet 4.6, not Opus 4.5). - # Accept known Opus 4.6/4.7 id patterns and/or ``supports_max_reasoning_effort`` - # in the model map (same pattern as ``xhigh`` below). - if effort == "max" and not ( - self._is_opus_4_6_model(model) - or self._is_opus_4_7_model(model) - or self._supports_effort_level(model, "max") - ): - raise ValueError( - f"effort='max' is not supported by this model. Got model: {model}" - ) - # ``xhigh`` is data-driven via ``supports_xhigh_reasoning_effort`` so - # enabling it for a new model is a pure model-map change. - if effort == "xhigh" and not self._supports_effort_level(model, "xhigh"): - raise ValueError( - f"effort='xhigh' is not supported by this model. Got model: {model}" + gate_error = self._validate_effort_for_model(model, effort) + if gate_error is not None: + raise litellm.exceptions.BadRequestError( + message=gate_error, + model=model, + llm_provider=self.custom_llm_provider or "anthropic", ) data["output_config"] = output_config diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py index b095d40156..869a7c5fbc 100644 --- a/litellm/llms/anthropic/common_utils.py +++ b/litellm/llms/anthropic/common_utils.py @@ -273,7 +273,18 @@ class AnthropicModelInfo(BaseLLMModelInfo): @staticmethod def _is_adaptive_thinking_model(model: str) -> bool: - """Claude 4.6+ models use adaptive thinking with output_config effort.""" + """Claude 4.6+ models use adaptive thinking with ``output_config.effort``.""" + from litellm.utils import _supports_factory + + try: + if _supports_factory( + model=model, + custom_llm_provider=None, + key="supports_adaptive_thinking", + ): + return True + except Exception: + pass return AnthropicModelInfo._is_claude_4_6_model( model ) or AnthropicModelInfo._is_claude_4_7_model(model) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index 829ce14d69..8ed6126d2e 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -27,6 +27,16 @@ from litellm.utils import get_model_info if TYPE_CHECKING: pass + +# Anthropic-only fields that the translator above already maps into the +# OpenAI-format completion_kwargs (output_config → reasoning_effort / +# response_format, etc.). They must be filtered out of the raw +# extra_kwargs re-merge below or non-Anthropic backends reject the call +# with 400 "Extra inputs are not permitted". Add new entries here when +# extending AnthropicMessagesRequestOptionalParams with another Anthropic- +# specific key. +ANTHROPIC_ONLY_REQUEST_KEYS: frozenset[str] = frozenset({"output_config"}) + ######################################################## # init adapter ANTHROPIC_ADAPTER = AnthropicAdapter() @@ -202,8 +212,12 @@ class LiteLLMMessagesToCompletionTransformationHandler: request_data["output_format"] = output_format # Extract output_config from extra_kwargs so the translator can use it - # (e.g. output_config.effort for adaptive thinking → reasoning_effort) - extra_kwargs = extra_kwargs or {} + # (e.g. output_config.effort for adaptive thinking → reasoning_effort, + # output_config.format → response_format for structured outputs). + # Use explicit None check rather than `or {}` so an explicit empty dict + # caller-passed argument is preserved (matters for tests that drive + # the fallback inference path). + extra_kwargs = extra_kwargs if extra_kwargs is not None else {} if "output_config" in extra_kwargs: request_data["output_config"] = extra_kwargs["output_config"] @@ -225,8 +239,23 @@ class LiteLLMMessagesToCompletionTransformationHandler: "include_usage": True, } - excluded_keys = {"anthropic_messages"} - extra_kwargs = extra_kwargs or {} + # Keys that must NOT be forwarded as raw extras into the OpenAI-format + # ``completion_kwargs`` after translation. The translator above has + # already consumed the meaningful parts of these inputs (e.g. + # ``output_config.format`` → ``response_format``, ``output_config.effort`` + # → ``reasoning_effort`` for non-Claude targets). Re-adding the raw + # Anthropic-shaped key here causes 400 "Extra inputs are not permitted" + # on non-Anthropic backends (Azure OpenAI, Fireworks, Bedrock Nova, + # etc.) and is silently lossy on Anthropic-family targets, which would + # see the translated key ``response_format`` AND a duplicate, conflicting + # ``output_config``. + # + # Maintainability: when adding a new Anthropic-only request param to + # ``AnthropicMessagesRequestOptionalParams``, also extend + # ``ANTHROPIC_ONLY_REQUEST_KEYS`` here so it doesn't silently leak. + excluded_keys = ANTHROPIC_ONLY_REQUEST_KEYS | {"anthropic_messages"} + # NOTE: extra_kwargs was already coerced from None to {} at the top of + # this method (line ~220). It is guaranteed to be a dict here. for key, value in extra_kwargs.items(): if ( key == "litellm_logging_obj" diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 0879788919..fe8e694efe 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -667,7 +667,7 @@ class LiteLLMAnthropicMessagesAdapter: @staticmethod def translate_anthropic_thinking_to_reasoning_effort( - thinking: Dict[str, Any] + thinking: Dict[str, Any], ) -> Optional[str]: """ Translate Anthropic's thinking parameter to OpenAI's reasoning_effort. @@ -1084,10 +1084,23 @@ class LiteLLMAnthropicMessagesAdapter: anthropic_message_request: AnthropicMessagesRequest, new_kwargs: ChatCompletionRequest, ) -> None: - """Translate output_format to response_format when applicable.""" - if "output_format" not in anthropic_message_request: - return - output_format = anthropic_message_request["output_format"] + """Translate Anthropic structured-output config to OpenAI ``response_format``. + + Accepts either the legacy top-level ``output_format`` field OR the + newer ``output_config.format`` (sub-key on ``output_config``) so that + both shapes flow through to non-Anthropic backends as + ``response_format``. Without the ``output_config.format`` branch, + callers using the new Anthropic Structured Outputs API would have + their schema silently dropped on the adapter path — only the legacy + top-level ``output_format`` was being mapped. + + ``output_format`` takes precedence when both are provided. + """ + output_format: Any = anthropic_message_request.get("output_format") + if not output_format: + output_config = anthropic_message_request.get("output_config") + if isinstance(output_config, dict): + output_format = output_config.get("format") if not output_format: return response_format = self.translate_anthropic_output_format_to_openai( diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py index 7617ad52ab..35495d5961 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py @@ -47,6 +47,7 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): "inference_geo", "speed", "output_config", + "reasoning_effort", # TODO: Add Anthropic `metadata` support # "metadata", ] @@ -166,6 +167,62 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): return headers, api_base + @staticmethod + def _translate_reasoning_effort_to_anthropic( + model: str, optional_params: Dict + ) -> None: + """Map OpenAI-style ``reasoning_effort`` to native Anthropic params. + + Caller-supplied ``thinking`` / ``output_config`` win over the alias. + ``effort='none'`` clears both. Invalid efforts raise a 400. + """ + from litellm.exceptions import BadRequestError as _BadRequestError + from litellm.llms.anthropic.chat.transformation import ( + REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT, + AnthropicConfig, + ) + + reasoning_effort = optional_params.pop("reasoning_effort", None) + if not isinstance(reasoning_effort, str): + return + + try: + mapped_thinking = AnthropicConfig._map_reasoning_effort( + reasoning_effort=reasoning_effort, model=model + ) + except _BadRequestError as e: + raise AnthropicError(message=str(e.message), status_code=400) + + if mapped_thinking is None: + optional_params.pop("thinking", None) + optional_params.pop("output_config", None) + return + + optional_params.setdefault("thinking", mapped_thinking) + if AnthropicModelInfo._is_adaptive_thinking_model(model): + mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( + reasoning_effort + ) + if mapped_effort is None: + raise AnthropicError( + message=( + f"Invalid reasoning_effort: {reasoning_effort!r}. " + f"Must be one of: 'minimal', 'low', 'medium', 'high', " + f"'xhigh', 'max', 'none'" + ), + status_code=400, + ) + gate_error = AnthropicConfig._validate_effort_for_model( + model, mapped_effort + ) + if gate_error is not None: + raise AnthropicError(message=gate_error, status_code=400) + existing_output_config = optional_params.get("output_config") + if not isinstance(existing_output_config, dict): + existing_output_config = {} + existing_output_config.setdefault("effort", mapped_effort) + optional_params["output_config"] = existing_output_config + @staticmethod def _translate_legacy_thinking_for_adaptive_model( model: str, optional_params: Dict @@ -217,6 +274,11 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): status_code=400, ) + self._translate_reasoning_effort_to_anthropic( + model=model, + optional_params=anthropic_messages_optional_request_params, + ) + self._translate_legacy_thinking_for_adaptive_model( model=model, optional_params=anthropic_messages_optional_request_params, diff --git a/litellm/llms/anthropic/files/handler.py b/litellm/llms/anthropic/files/handler.py index c56799f30c..56296df94a 100644 --- a/litellm/llms/anthropic/files/handler.py +++ b/litellm/llms/anthropic/files/handler.py @@ -9,6 +9,7 @@ import litellm from litellm._logging import verbose_logger from litellm._uuid import uuid from litellm.litellm_core_utils.litellm_logging import Logging +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.types.llms.openai import ( FileContentRequest, @@ -89,7 +90,10 @@ class AnthropicFilesHandler: raise ValueError("Missing Anthropic API Key") # Construct the Anthropic batch results URL - results_url = f"{api_base.rstrip('/')}/v1/messages/batches/{batch_id}/results" + encoded_batch_id = encode_url_path_segment(batch_id, field_name="batch_id") + results_url = ( + f"{api_base.rstrip('/')}/v1/messages/batches/{encoded_batch_id}/results" + ) # Prepare headers headers = { diff --git a/litellm/llms/anthropic/files/transformation.py b/litellm/llms/anthropic/files/transformation.py index aeaab4e57b..ea9bf00f50 100644 --- a/litellm/llms/anthropic/files/transformation.py +++ b/litellm/llms/anthropic/files/transformation.py @@ -19,6 +19,7 @@ from typing import Any, Dict, List, Optional, Union, cast import httpx from openai.types.file_deleted import FileDeleted +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.files.transformation import ( @@ -185,7 +186,8 @@ class AnthropicFilesConfig(BaseFilesConfig): AnthropicModelInfo.get_api_base(litellm_params.get("api_base")) or ANTHROPIC_FILES_API_BASE ) - return f"{api_base.rstrip('/')}/v1/files/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base.rstrip('/')}/v1/files/{encoded_file_id}", {} def transform_retrieve_file_response( self, @@ -206,7 +208,8 @@ class AnthropicFilesConfig(BaseFilesConfig): AnthropicModelInfo.get_api_base(litellm_params.get("api_base")) or ANTHROPIC_FILES_API_BASE ) - return f"{api_base.rstrip('/')}/v1/files/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base.rstrip('/')}/v1/files/{encoded_file_id}", {} def transform_delete_file_response( self, @@ -268,7 +271,8 @@ class AnthropicFilesConfig(BaseFilesConfig): AnthropicModelInfo.get_api_base(litellm_params.get("api_base")) or ANTHROPIC_FILES_API_BASE ) - return f"{api_base.rstrip('/')}/v1/files/{file_id}/content", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base.rstrip('/')}/v1/files/{encoded_file_id}/content", {} def transform_file_content_response( self, diff --git a/litellm/llms/anthropic/skills/transformation.py b/litellm/llms/anthropic/skills/transformation.py index a992d84d45..4ea768b02a 100644 --- a/litellm/llms/anthropic/skills/transformation.py +++ b/litellm/llms/anthropic/skills/transformation.py @@ -7,6 +7,7 @@ from typing import Any, Dict, Optional, Tuple import httpx from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.skills.transformation import ( BaseSkillsAPIConfig, LiteLLMLoggingObj, @@ -81,7 +82,8 @@ class AnthropicSkillsConfig(BaseSkillsAPIConfig): api_base = AnthropicModelInfo.get_api_base() if skill_id: - return f"{api_base}/v1/skills/{skill_id}" + encoded_skill_id = encode_url_path_segment(skill_id, field_name="skill_id") + return f"{api_base}/v1/skills/{encoded_skill_id}" return f"{api_base}/v1/{endpoint}" def transform_create_skill_request( diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.py index 61cfd54b56..9291269d15 100644 --- a/litellm/llms/azure/azure.py +++ b/litellm/llms/azure/azure.py @@ -16,6 +16,7 @@ import litellm from litellm.constants import AZURE_OPERATION_POLLING_TIMEOUT, DEFAULT_MAX_RETRIES from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj from litellm.litellm_core_utils.logging_utils import track_llm_api_timing +from litellm.litellm_core_utils.url_utils import SSRFError, assert_same_origin from litellm.llms.custom_httpx.http_handler import ( AsyncHTTPHandler, HTTPHandler, @@ -43,6 +44,7 @@ from .common_utils import ( select_azure_base_url_or_endpoint, ) from .image_generation import get_azure_image_generation_config +from .image_generation.http_utils import azure_deployment_image_generation_json_body class AzureOpenAIAssistantsAPIConfig: @@ -792,6 +794,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): client=client, litellm_params=litellm_params, api_base=api_base, + api_version=api_version, ) azure_client = self.get_azure_openai_client( api_version=api_version, @@ -898,6 +901,17 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): operation_location_url = response.headers["operation-location"] else: raise AzureOpenAIError(status_code=500, message=response.text) + # Reject polling URLs that don't share an origin with ``api_base``. + # Without this an upstream-controlled or attacker-controlled + # value would receive the operator's Azure API key in the + # request headers below. VERIA-51. + try: + assert_same_origin(operation_location_url, api_base) + except SSRFError as ssrf_err: + raise AzureOpenAIError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) response = await async_handler.get( url=operation_location_url, headers=headers, @@ -908,8 +922,13 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): timeout_secs: int = AZURE_OPERATION_POLLING_TIMEOUT start_time = time.time() if "status" not in response.json(): - raise Exception( - "Expected 'status' in response. Got={}".format(response.json()) + # Don't reflect the raw response body — when the polling + # URL points at an internal JSON API (cloud metadata + # service etc.) reflecting it here turns Blind SSRF into + # Full-Read SSRF. VERIA-51. + raise AzureOpenAIError( + status_code=502, + message="Polling response missing 'status' field", ) while response.json()["status"] not in ["succeeded", "failed"]: if time.time() - start_time > timeout_secs: @@ -948,9 +967,10 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): content=json.dumps(result).encode("utf-8"), request=httpx.Request(method="POST", url="https://api.openai.com/v1"), ) + request_json = azure_deployment_image_generation_json_body(api_base, data) return await async_handler.post( url=api_base, - json=data, + json=request_json, headers=headers, ) @@ -1009,6 +1029,13 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): operation_location_url = response.headers["operation-location"] else: raise AzureOpenAIError(status_code=500, message=response.text) + try: + assert_same_origin(operation_location_url, api_base) + except SSRFError as ssrf_err: + raise AzureOpenAIError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) response = sync_handler.get( url=operation_location_url, headers=headers, @@ -1019,8 +1046,9 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): timeout_secs: int = AZURE_OPERATION_POLLING_TIMEOUT start_time = time.time() if "status" not in response.json(): - raise Exception( - "Expected 'status' in response. Got={}".format(response.json()) + raise AzureOpenAIError( + status_code=502, + message="Polling response missing 'status' field", ) while response.json()["status"] not in ["succeeded", "failed"]: if time.time() - start_time > timeout_secs: @@ -1059,9 +1087,10 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): content=json.dumps(result).encode("utf-8"), request=httpx.Request(method="POST", url="https://api.openai.com/v1"), ) + request_json = azure_deployment_image_generation_json_body(api_base, data) return sync_handler.post( url=api_base, - json=data, + json=request_json, headers=headers, ) diff --git a/litellm/llms/azure/cost_calculation.py b/litellm/llms/azure/cost_calculation.py index 5b411095ea..2a20c55a6c 100644 --- a/litellm/llms/azure/cost_calculation.py +++ b/litellm/llms/azure/cost_calculation.py @@ -12,7 +12,10 @@ from litellm.utils import get_model_info def cost_per_token( - model: str, usage: Usage, response_time_ms: Optional[float] = 0.0 + model: str, + usage: Usage, + response_time_ms: Optional[float] = 0.0, + service_tier: Optional[str] = None, ) -> Tuple[float, float]: """ Calculates the cost per token for a given model, prompt tokens, and completion tokens. @@ -47,4 +50,5 @@ def cost_per_token( model=model, usage=usage, custom_llm_provider="azure", + service_tier=service_tier, ) diff --git a/litellm/llms/azure/image_edit/transformation.py b/litellm/llms/azure/image_edit/transformation.py index dffa1c9eea..0b6ecfb076 100644 --- a/litellm/llms/azure/image_edit/transformation.py +++ b/litellm/llms/azure/image_edit/transformation.py @@ -9,6 +9,19 @@ from litellm.utils import _add_path_to_api_base class AzureImageEditConfig(OpenAIImageEditConfig): + @staticmethod + def azure_deployment_image_edit_form_data(data: dict, request_url: str) -> dict: + """ + Azure OpenAI ``.../openai/deployments/{deployment}/images/edits`` routes by + deployment in the URL; including ``model`` in multipart fields can break + the same way as image generations (LiteLLM #26316). + + Non-deployment edit URLs keep ``model`` when present. + """ + if "images/edits" in request_url and "/openai/deployments/" in request_url: + return {k: v for k, v in data.items() if k != "model"} + return data + def validate_environment( self, headers: dict, @@ -83,3 +96,8 @@ class AzureImageEditConfig(OpenAIImageEditConfig): final_url = httpx.URL(new_url).copy_with(params=query_params) return str(final_url) + + def finalize_image_edit_request_data( + self, data: dict, resolved_request_url: str + ) -> dict: + return self.azure_deployment_image_edit_form_data(data, resolved_request_url) diff --git a/litellm/llms/azure/image_generation/__init__.py b/litellm/llms/azure/image_generation/__init__.py index a9cf151464..f60e446f0c 100644 --- a/litellm/llms/azure/image_generation/__init__.py +++ b/litellm/llms/azure/image_generation/__init__.py @@ -6,11 +6,13 @@ from litellm.llms.base_llm.image_generation.transformation import ( from .dall_e_2_transformation import AzureDallE2ImageGenerationConfig from .dall_e_3_transformation import AzureDallE3ImageGenerationConfig from .gpt_transformation import AzureGPTImageGenerationConfig +from .http_utils import azure_deployment_image_generation_json_body __all__ = [ "AzureDallE2ImageGenerationConfig", "AzureDallE3ImageGenerationConfig", "AzureGPTImageGenerationConfig", + "azure_deployment_image_generation_json_body", ] diff --git a/litellm/llms/azure/image_generation/http_utils.py b/litellm/llms/azure/image_generation/http_utils.py new file mode 100644 index 0000000000..03c425eeff --- /dev/null +++ b/litellm/llms/azure/image_generation/http_utils.py @@ -0,0 +1,17 @@ +"""HTTP helpers for Azure OpenAI image generation (REST, not SDK).""" + + +def azure_deployment_image_generation_json_body(api_base: str, data: dict) -> dict: + """ + Build the JSON body for Azure OpenAI image generation POSTs. + + For ``.../openai/deployments/{deployment}/images/generations``, routing uses the + deployment in the URL only; sending ``model`` in the body (especially the deployment + name) breaks some models (e.g. gpt-image-2). See LiteLLM #26316. + + Provider-style URLs (e.g. ``/providers/...`` for FLUX on Azure AI) keep all keys + so non–OpenAI-deployment payloads still work. + """ + if "images/generations" in api_base and "/openai/deployments/" in api_base: + return {k: v for k, v in data.items() if k != "model"} + return data diff --git a/litellm/llms/azure/responses/transformation.py b/litellm/llms/azure/responses/transformation.py index 76a6d485bc..ca9293325f 100644 --- a/litellm/llms/azure/responses/transformation.py +++ b/litellm/llms/azure/responses/transformation.py @@ -5,6 +5,7 @@ import httpx from openai.types.responses import ResponseReasoningItem from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.azure.common_utils import BaseAzureLLM from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig from litellm.types.llms.openai import * @@ -201,7 +202,10 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): # Insert the response_id at the end of the path component # Remove trailing slash if present to avoid double slashes path = parsed_url.path.rstrip("/") - new_path = f"{path}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + new_path = f"{path}/{encoded_response_id}" # Reconstruct the URL with all original components but with the modified path constructed_url = urlunparse( @@ -322,7 +326,10 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig): # Insert the response_id and /cancel at the end of the path component # Remove trailing slash if present to avoid double slashes path = parsed_url.path.rstrip("/") - new_path = f"{path}/{response_id}/cancel" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + new_path = f"{path}/{encoded_response_id}/cancel" # Reconstruct the URL with all original components but with the modified path cancel_url = urlunparse( diff --git a/litellm/llms/azure_ai/agents/handler.py b/litellm/llms/azure_ai/agents/handler.py index c3cd06ab4d..9bae8abce8 100644 --- a/litellm/llms/azure_ai/agents/handler.py +++ b/litellm/llms/azure_ai/agents/handler.py @@ -36,6 +36,7 @@ from typing import ( import httpx from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.azure_ai.agents.transformation import ( AzureAIAgentsConfig, AzureAIAgentsError, @@ -75,20 +76,29 @@ class AzureAIAgentsHandler: def _build_messages_url( self, api_base: str, thread_id: str, api_version: str ) -> str: - return f"{api_base}/threads/{thread_id}/messages?api-version={api_version}" + encoded_thread_id = encode_url_path_segment(thread_id, field_name="thread_id") + return ( + f"{api_base}/threads/{encoded_thread_id}/messages?api-version={api_version}" + ) def _build_runs_url(self, api_base: str, thread_id: str, api_version: str) -> str: - return f"{api_base}/threads/{thread_id}/runs?api-version={api_version}" + encoded_thread_id = encode_url_path_segment(thread_id, field_name="thread_id") + return f"{api_base}/threads/{encoded_thread_id}/runs?api-version={api_version}" def _build_run_status_url( self, api_base: str, thread_id: str, run_id: str, api_version: str ) -> str: - return f"{api_base}/threads/{thread_id}/runs/{run_id}?api-version={api_version}" + encoded_thread_id = encode_url_path_segment(thread_id, field_name="thread_id") + encoded_run_id = encode_url_path_segment(run_id, field_name="run_id") + return f"{api_base}/threads/{encoded_thread_id}/runs/{encoded_run_id}?api-version={api_version}" def _build_list_messages_url( self, api_base: str, thread_id: str, api_version: str ) -> str: - return f"{api_base}/threads/{thread_id}/messages?api-version={api_version}" + encoded_thread_id = encode_url_path_segment(thread_id, field_name="thread_id") + return ( + f"{api_base}/threads/{encoded_thread_id}/messages?api-version={api_version}" + ) def _build_create_thread_and_run_url(self, api_base: str, api_version: str) -> str: """URL for the create-thread-and-run endpoint (supports streaming).""" diff --git a/litellm/llms/azure_ai/anthropic/transformation.py b/litellm/llms/azure_ai/anthropic/transformation.py index e935aa1c05..e176a4d860 100644 --- a/litellm/llms/azure_ai/anthropic/transformation.py +++ b/litellm/llms/azure_ai/anthropic/transformation.py @@ -12,6 +12,23 @@ if TYPE_CHECKING: pass +def _promote_extra_body_to_optional_params(optional_params: dict) -> None: + """Promote anthropic-native passthrough keys out of ``extra_body``. + + ``azure_ai`` is an OpenAI-compatible provider, so non-OpenAI kwargs like + ``output_config`` get auto-routed into ``extra_body`` by + ``add_provider_specific_params_to_optional_params``. For the Azure→Anthropic + route those keys must reach the request body and be validated, so promote + them. ``setdefault`` keeps explicit top-level values authoritative. + """ + extra_body = optional_params.get("extra_body") + if not isinstance(extra_body, dict) or not extra_body: + return + for k, v in extra_body.items(): + optional_params.setdefault(k, v) + optional_params.pop("extra_body", None) + + class AzureAnthropicConfig(AnthropicConfig): """ Azure Anthropic configuration that extends AnthropicConfig. @@ -39,6 +56,8 @@ class AzureAnthropicConfig(AnthropicConfig): 1. API key via 'api-key' header 2. Azure AD token via 'Authorization: Bearer ' header """ + _promote_extra_body_to_optional_params(optional_params) + # Convert dict to GenericLiteLLMParams if needed if isinstance(litellm_params, dict): # Ensure api_key is included if provided @@ -101,7 +120,8 @@ class AzureAnthropicConfig(AnthropicConfig): Transform request using parent AnthropicConfig, then remove unsupported params. Azure Anthropic doesn't support extra_body, max_retries, or stream_options parameters. """ - # Call parent transform_request + _promote_extra_body_to_optional_params(optional_params) + data = super().transform_request( model=model, messages=messages, diff --git a/litellm/llms/azure_ai/cost_calculator.py b/litellm/llms/azure_ai/cost_calculator.py index 067181b946..755d44fdef 100644 --- a/litellm/llms/azure_ai/cost_calculator.py +++ b/litellm/llms/azure_ai/cost_calculator.py @@ -65,6 +65,7 @@ def cost_per_token( usage: Usage, response_time_ms: Optional[float] = 0.0, request_model: Optional[str] = None, + service_tier: Optional[str] = None, ) -> Tuple[float, float]: """ Calculate the cost per token for Azure AI models. @@ -102,6 +103,7 @@ def cost_per_token( model=model, usage=usage, custom_llm_provider="azure_ai", + service_tier=service_tier, ) except Exception as e: # For Model Router, the model name (e.g., "azure-model-router") may not be in the cost map diff --git a/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py b/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py index 76c247aea8..d4144a7571 100644 --- a/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py +++ b/litellm/llms/azure_ai/ocr/document_intelligence/transformation.py @@ -17,11 +17,13 @@ from urllib.parse import quote import httpx from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import SSRFError, assert_same_origin from litellm.constants import ( AZURE_DOCUMENT_INTELLIGENCE_API_VERSION, AZURE_DOCUMENT_INTELLIGENCE_DEFAULT_DPI, AZURE_OPERATION_POLLING_TIMEOUT, ) +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.ocr.transformation import ( BaseOCRConfig, DocumentType, @@ -217,11 +219,12 @@ class AzureDocumentIntelligenceOCRConfig(BaseOCRConfig): if "/" in model: # Extract the last part after the last slash model_id = model.split("/")[-1] + encoded_model_id = encode_url_path_segment(model_id, field_name="model_id") # Azure Document Intelligence analyze endpoint # Note: API version 2024-11-30+ uses /documentintelligence/ (not /formrecognizer/) url = ( - f"{api_base}/documentintelligence/documentModels/{model_id}:analyze" + f"{api_base}/documentintelligence/documentModels/{encoded_model_id}:analyze" f"?api-version={AZURE_DOCUMENT_INTELLIGENCE_API_VERSION}" ) @@ -599,6 +602,16 @@ class AzureDocumentIntelligenceOCRConfig(BaseOCRConfig): "Azure Document Intelligence returned 202 but no Operation-Location header found" ) + # Reject cross-origin polling URLs — the auth headers + # below would otherwise leak to whatever URL the upstream + # (or an attacker-controlled upstream) returns. VERIA-51. + try: + assert_same_origin(operation_url, str(raw_response.request.url)) + except SSRFError as ssrf_err: + raise ValueError( + f"Azure Document Intelligence: rejected polling URL ({ssrf_err})" + ) + # Get headers for polling (need auth) poll_headers = { "Ocp-Apim-Subscription-Key": raw_response.request.headers.get( @@ -711,6 +724,14 @@ class AzureDocumentIntelligenceOCRConfig(BaseOCRConfig): "Azure Document Intelligence returned 202 but no Operation-Location header found" ) + # Reject cross-origin polling URLs (see sync path). VERIA-51. + try: + assert_same_origin(operation_url, str(raw_response.request.url)) + except SSRFError as ssrf_err: + raise ValueError( + f"Azure Document Intelligence: rejected polling URL ({ssrf_err})" + ) + # Get headers for polling (need auth) poll_headers = { "Ocp-Apim-Subscription-Key": raw_response.request.headers.get( diff --git a/litellm/llms/base_llm/chat/transformation.py b/litellm/llms/base_llm/chat/transformation.py index b71ae0fdde..bec25916c4 100644 --- a/litellm/llms/base_llm/chat/transformation.py +++ b/litellm/llms/base_llm/chat/transformation.py @@ -87,9 +87,7 @@ class BaseConfig(ABC): return { k: v for k, v in cls.__dict__.items() - if not k.startswith("__") - and not k.startswith("_abc") - and not k.startswith("_is_base_class") + if not k.startswith("_") and not isinstance( v, ( diff --git a/litellm/llms/base_llm/image_edit/transformation.py b/litellm/llms/base_llm/image_edit/transformation.py index cea96bde74..92429573ff 100644 --- a/litellm/llms/base_llm/image_edit/transformation.py +++ b/litellm/llms/base_llm/image_edit/transformation.py @@ -102,6 +102,18 @@ class BaseImageEditConfig(ABC): ) -> Tuple[Dict, RequestFiles]: pass + def finalize_image_edit_request_data( + self, data: dict, resolved_request_url: str + ) -> dict: + """ + Last pass on the request dict after ``transform_image_edit_request``, using the + exact URL string used for the HTTP POST (same as ``get_complete_url`` output). + + The handler sends this dict as ``data=`` for multipart providers or ``json=`` + for JSON-only providers; default implementation returns ``data`` unchanged. + """ + return data + @abstractmethod def transform_image_edit_response( self, diff --git a/litellm/llms/base_llm/managed_resources/base_managed_resource.py b/litellm/llms/base_llm/managed_resources/base_managed_resource.py index 5422af7678..c0c18aefde 100644 --- a/litellm/llms/base_llm/managed_resources/base_managed_resource.py +++ b/litellm/llms/base_llm/managed_resources/base_managed_resource.py @@ -18,6 +18,11 @@ from typing import ( ) from litellm import verbose_logger +from litellm.llms.base_llm.managed_resources.isolation import ( + build_list_page, + build_owner_filter, + can_access_resource, +) from litellm.proxy._types import UserAPIKeyAuth from litellm.types.utils import SpecialEnums @@ -169,6 +174,7 @@ class BaseManagedResource(ABC, Generic[ResourceObjectType]): "model_mappings": model_mappings, "flat_model_resource_ids": list(model_mappings.values()), "created_by": user_api_key_dict.user_id, + "team_id": user_api_key_dict.team_id, "updated_by": user_api_key_dict.user_id, } @@ -190,6 +196,7 @@ class BaseManagedResource(ABC, Generic[ResourceObjectType]): "model_mappings": json.dumps(model_mappings), "flat_model_resource_ids": list(model_mappings.values()), "created_by": user_api_key_dict.user_id, + "team_id": user_api_key_dict.team_id, "updated_by": user_api_key_dict.user_id, } @@ -316,15 +323,17 @@ class BaseManagedResource(ABC, Generic[ResourceObjectType]): Returns: True if user has access, False otherwise """ - user_id = user_api_key_dict.user_id - # Use cached method instead of direct DB query resource = await self.get_unified_resource_id( unified_resource_id, litellm_parent_otel_span ) if resource: - return resource.get("created_by") == user_id + return can_access_resource( + user_api_key_dict=user_api_key_dict, + created_by=resource.get("created_by"), + resource_team_id=resource.get("team_id"), + ) return False @@ -549,11 +558,11 @@ class BaseManagedResource(ABC, Generic[ResourceObjectType]): Returns: Dictionary with list of resources and pagination info """ - where_clause: Dict[str, Any] = {} + owner_filter = build_owner_filter(user_api_key_dict) + if owner_filter is None: + return build_list_page([]) - # Filter by user who created the resource - if user_api_key_dict.user_id: - where_clause["created_by"] = user_api_key_dict.user_id + where_clause: Dict[str, Any] = {**owner_filter} if after: where_clause["id"] = {"gt": after} @@ -598,10 +607,6 @@ class BaseManagedResource(ABC, Generic[ResourceObjectType]): ) continue - return { - "object": "list", - "data": resource_objects, - "first_id": resource_objects[0].id if resource_objects else None, - "last_id": resource_objects[-1].id if resource_objects else None, - "has_more": len(resource_objects) == (limit or 20), - } + return build_list_page( + resource_objects, has_more=len(resource_objects) == (limit or 20) + ) diff --git a/litellm/llms/base_llm/managed_resources/isolation.py b/litellm/llms/base_llm/managed_resources/isolation.py new file mode 100644 index 0000000000..62027f4272 --- /dev/null +++ b/litellm/llms/base_llm/managed_resources/isolation.py @@ -0,0 +1,99 @@ +""" +Tenant-isolation helpers for managed file/batch/vector-store resources. + +Returns a Prisma filter and an ownership check that scope managed resources +to the caller's identity: proxy admins see everything, user-keyed callers +see records they created, and service-account keys (no user_id) fall back +to the resource's owning team. Callers with no admin role and no +identifying ids are denied so an empty user_id can never select an +unscoped query. +""" + +from typing import Any, Dict, List, Optional + +from litellm.proxy._types import ( + UserAPIKeyAuth, + user_api_key_has_admin_view as _user_has_admin_view, +) + + +def build_list_page(items: List[Any], has_more: bool = False) -> Dict[str, Any]: + """Build the OpenAI-style paginated list response shape used by managed + file/batch/vector-store listings. ``first_id`` and ``last_id`` are + sourced from each item's ``.id`` attribute.""" + return { + "object": "list", + "data": items, + "first_id": items[0].id if items else None, + "last_id": items[-1].id if items else None, + "has_more": has_more, + } + + +def build_owner_filter( + user_api_key_dict: UserAPIKeyAuth, +) -> Optional[Dict[str, Any]]: + """Return a Prisma `where` fragment that scopes a managed-resource listing + to records the caller is allowed to see. + + - ``{}`` means no scoping (proxy admins). + - ``{"created_by": }`` for user-keyed callers. + - ``{"team_id": }`` for service-account callers + that have a team but no user_id. + - ``{"OR": [...]}`` when the caller has both — listing must include + both their own resources and team-shared ones so it stays consistent + with ``can_access_resource``. + - ``None`` means deny: callers MUST skip the query rather than fall + back to an unscoped fetch. + """ + if _user_has_admin_view(user_api_key_dict): + return {} + + user_id = user_api_key_dict.user_id + team_id = user_api_key_dict.team_id + + if user_id is not None and team_id is not None: + return { + "OR": [ + {"created_by": user_id}, + {"team_id": team_id}, + ] + } + + if user_id is not None: + return {"created_by": user_id} + + if team_id is not None: + return {"team_id": team_id} + + return None + + +def can_access_resource( + user_api_key_dict: UserAPIKeyAuth, + created_by: Optional[str], + resource_team_id: Optional[str], +) -> bool: + """Return True iff the caller may read/modify a managed resource. + + The resource's ``created_by`` and ``team_id`` fields must be non-None + to match the caller's identity — guarding against the ``None == None`` + bypass that previously let service-account keys read every keyless + resource. + """ + if _user_has_admin_view(user_api_key_dict): + return True + + user_id = user_api_key_dict.user_id + if user_id is not None and created_by is not None and created_by == user_id: + return True + + team_id = user_api_key_dict.team_id + if ( + team_id is not None + and resource_team_id is not None + and resource_team_id == team_id + ): + return True + + return False diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 61a7d4c08d..efc890d9ee 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -31,7 +31,11 @@ from litellm.litellm_core_utils.prompt_templates.factory import ( _bedrock_converse_messages_pt, _bedrock_tools_pt, ) -from litellm.llms.anthropic.chat.transformation import AnthropicConfig +from litellm.llms.anthropic.chat.transformation import ( + DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING, + REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT, + AnthropicConfig, +) from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException from litellm.types.llms.bedrock import * from litellm.types.llms.openai import ( @@ -189,7 +193,7 @@ class AmazonConverseConfig(BaseConfig): return { k: v for k, v in cls.__dict__.items() - if not k.startswith("__") + if not k.startswith("_") and not isinstance( v, ( @@ -410,47 +414,64 @@ class AmazonConverseConfig(BaseConfig): """ Handle the reasoning_effort parameter based on the model type. - Different model families handle reasoning effort differently: - - GPT-OSS models: Keep reasoning_effort as-is (passed to additionalModelRequestFields) - - Nova 2 models: Transform to reasoningConfig structure - - Other models (Anthropic, etc.): Convert to thinking parameter - - Args: - model: The model identifier - reasoning_effort: The reasoning effort value - optional_params: Dictionary of optional parameters to update in-place - - Examples: - >>> config = AmazonConverseConfig() - >>> params = {} - >>> config._handle_reasoning_effort_parameter("gpt-oss-model", "high", params) - >>> params - {'reasoning_effort': 'high'} - - >>> params = {} - >>> config._handle_reasoning_effort_parameter("amazon.nova-2-lite-v1:0", "high", params) - >>> params - {'reasoningConfig': {'type': 'enabled', 'maxReasoningEffort': 'high'}} - - >>> params = {} - >>> config._handle_reasoning_effort_parameter("anthropic.claude-3", "high", params) - >>> params - {'thinking': {'type': 'enabled', 'budget_tokens': 10000}} + - GPT-OSS models: passed through unchanged via additionalModelRequestFields. + - Nova 2 models: transformed to reasoningConfig. + - Anthropic models: mapped to ``thinking`` (and ``output_config.effort`` on + adaptive Claude 4.6 / 4.7). """ if "gpt-oss" in model: - # GPT-OSS models: keep reasoning_effort as-is - # It will be passed through to additionalModelRequestFields optional_params["reasoning_effort"] = reasoning_effort elif self._is_nova_2_model(model): - # Nova 2 models: transform to reasoningConfig reasoning_config = self._transform_reasoning_effort_to_reasoning_config( reasoning_effort ) optional_params.update(reasoning_config) else: - # Anthropic and other models: convert to thinking parameter - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - reasoning_effort=reasoning_effort, model=model + mapped_thinking = AnthropicConfig._map_reasoning_effort( + reasoning_effort=reasoning_effort, + model=model, + llm_provider="bedrock_converse", + ) + if mapped_thinking is None: + optional_params.pop("thinking", None) + optional_params.pop("output_config", None) + else: + optional_params["thinking"] = mapped_thinking + if AnthropicConfig._is_adaptive_thinking_model(model): + mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( + reasoning_effort + ) + if mapped_effort is None: + AnthropicConfig._raise_invalid_reasoning_effort( + model=model, + value=reasoning_effort, + llm_provider="bedrock_converse", + ) + self._validate_anthropic_adaptive_effort( + model=model, effort=mapped_effort + ) + optional_params["output_config"] = {"effort": mapped_effort} + + @staticmethod + def _validate_anthropic_adaptive_effort(model: str, effort: str) -> None: + """Validate ``output_config.effort`` for adaptive-thinking Claude 4.6/4.7.""" + valid_efforts = {"high", "medium", "low", "xhigh", "max"} + if effort not in valid_efforts: + raise litellm.exceptions.BadRequestError( + message=( + f"Invalid reasoning_effort/output_config.effort value: " + f"{effort!r}. Must be one of: 'low', 'medium', 'high', " + f"'xhigh', or 'max'." + ), + model=model, + llm_provider="bedrock_converse", + ) + error = AnthropicConfig._validate_effort_for_model(model=model, effort=effort) + if error is not None: + raise litellm.exceptions.BadRequestError( + message=error, + model=model, + llm_provider="bedrock_converse", ) @staticmethod @@ -1192,9 +1213,11 @@ class AmazonConverseConfig(BaseConfig): + supported_config_params ) inference_params.pop("json_mode", None) # used for handling json_schema - # Anthropic-only key. Bedrock expects `outputConfig` (camelCase) and - # will reject `output_config` if it leaks through pass-through routes. - inference_params.pop("output_config", None) + + # Anthropic-only ``output_config`` (snake_case) — re-attached to + # ``additionalModelRequestFields`` for Anthropic models below. The + # Bedrock-native ``outputConfig`` (camelCase) is handled separately. + anthropic_output_config = inference_params.pop("output_config", None) # Extract requestMetadata before processing other parameters request_metadata = inference_params.pop("requestMetadata", None) @@ -1204,9 +1227,6 @@ class AmazonConverseConfig(BaseConfig): output_config: Optional[OutputConfigBlock] = inference_params.pop( "outputConfig", None ) - inference_params.pop( - "output_config", None - ) # Bedrock Converse doesn't support it # keep supported params in 'inference_params', and set all model-specific params in 'additional_request_params' additional_request_params = { @@ -1249,6 +1269,27 @@ class AmazonConverseConfig(BaseConfig): additional_request_params ) + if anthropic_output_config is not None and isinstance( + anthropic_output_config, dict + ): + base_model = BedrockModelInfo.get_base_model(model) + if base_model.startswith("anthropic"): + if ( + litellm.drop_params is True + and not AnthropicConfig._model_supports_effort_param(model) + ): + litellm.verbose_logger.warning( + DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING, + model, + ) + else: + effort = anthropic_output_config.get("effort") + if effort is not None: + self._validate_anthropic_adaptive_effort( + model=model, effort=effort + ) + additional_request_params["output_config"] = anthropic_output_config + return ( inference_params, additional_request_params, @@ -1372,9 +1413,25 @@ class AmazonConverseConfig(BaseConfig): # Append pre-formatted tools (systemTool etc.) after transformation bedrock_tools.extend(pre_formatted_tools) + # Opus 4.5 gates ``output_config.effort`` behind a beta header; + # Claude 4.6/4.7 accept it without one. + base_model = BedrockModelInfo.get_base_model(model) + if base_model.startswith("anthropic"): + output_config = additional_request_params.get("output_config") + if ( + isinstance(output_config, dict) + and output_config.get("effort") is not None + and not AnthropicConfig._is_adaptive_thinking_model(model) + ): + from litellm.types.llms.anthropic import ( + ANTHROPIC_EFFORT_BETA_HEADER, + ) + + if ANTHROPIC_EFFORT_BETA_HEADER not in anthropic_beta_list: + anthropic_beta_list.append(ANTHROPIC_EFFORT_BETA_HEADER) + # Set anthropic_beta in additional_request_params if we have any beta features # ONLY apply to Anthropic/Claude models - other models (e.g., Qwen, Llama) don't support this field - base_model = BedrockModelInfo.get_base_model(model) if anthropic_beta_list and base_model.startswith("anthropic"): additional_request_params["anthropic_beta"] = anthropic_beta_list diff --git a/litellm/llms/bedrock/chat/invoke_agent/transformation.py b/litellm/llms/bedrock/chat/invoke_agent/transformation.py index 2c7135f4d8..4c667b0ce3 100644 --- a/litellm/llms/bedrock/chat/invoke_agent/transformation.py +++ b/litellm/llms/bedrock/chat/invoke_agent/transformation.py @@ -12,6 +12,7 @@ import httpx from litellm._logging import verbose_logger from litellm._uuid import uuid +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.prompt_templates.common_utils import ( convert_content_list_to_str, ) @@ -97,8 +98,15 @@ class AmazonInvokeAgentConfig(BaseConfig, BaseAWSLLM): agent_id, agent_alias_id = self._get_agent_id_and_alias_id(model) session_id = self._get_session_id(optional_params) + encoded_agent_id = encode_url_path_segment(agent_id, field_name="agent_id") + encoded_agent_alias_id = encode_url_path_segment( + agent_alias_id, field_name="agent_alias_id" + ) + encoded_session_id = encode_url_path_segment( + session_id, field_name="session_id" + ) - endpoint_url = f"{endpoint_url}/agents/{agent_id}/agentAliases/{agent_alias_id}/sessions/{session_id}/text" + endpoint_url = f"{endpoint_url}/agents/{encoded_agent_id}/agentAliases/{encoded_agent_alias_id}/sessions/{encoded_session_id}/text" return endpoint_url diff --git a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py index cff415d49e..c883ab68df 100644 --- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py @@ -169,7 +169,6 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig): anthropic_request.pop("model", None) anthropic_request.pop("stream", None) anthropic_request.pop("output_format", None) - anthropic_request.pop("output_config", None) if "anthropic_version" not in anthropic_request: anthropic_request["anthropic_version"] = self.anthropic_version diff --git a/litellm/llms/bedrock/count_tokens/transformation.py b/litellm/llms/bedrock/count_tokens/transformation.py index a37af13162..c967fd334b 100644 --- a/litellm/llms/bedrock/count_tokens/transformation.py +++ b/litellm/llms/bedrock/count_tokens/transformation.py @@ -201,13 +201,14 @@ class BedrockCountTokensConfig(BaseAWSLLM): # Remove bedrock/ prefix if present if model_id.startswith("bedrock/"): model_id = model_id[8:] # Remove "bedrock/" prefix + encoded_model_id = self.encode_model_id(model_id=model_id) base_url, _ = self.get_runtime_endpoint( api_base=api_base, aws_bedrock_runtime_endpoint=aws_bedrock_runtime_endpoint, aws_region_name=aws_region_name, ) - endpoint = f"{base_url}/model/{model_id}/count-tokens" + endpoint = f"{base_url}/model/{encoded_model_id}/count-tokens" return endpoint diff --git a/litellm/llms/bedrock/files/handler.py b/litellm/llms/bedrock/files/handler.py index 13bd87a1f0..ecf157e12e 100644 --- a/litellm/llms/bedrock/files/handler.py +++ b/litellm/llms/bedrock/files/handler.py @@ -1,10 +1,17 @@ import asyncio import base64 -from typing import Any, Coroutine, Optional, Tuple, Union +import os +from types import MappingProxyType +from typing import Any, Coroutine, Mapping, Optional, Tuple, Union, cast import httpx from litellm import LlmProviders +from litellm.litellm_core_utils.cloud_storage_security import ( + BEDROCK_MANAGED_S3_PREFIXES, + should_allow_legacy_cloud_file_ids, + validate_managed_cloud_file_id, +) from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.types.llms.openai import ( FileContentRequest, @@ -35,7 +42,7 @@ class BedrockFilesHandler(BaseAWSLLM): The file ID can be in two formats: 1. Base64-encoded unified file ID containing: llm_output_file_id,s3://bucket/path - 2. Direct S3 URI: s3://bucket/path + 2. Direct S3 URI: s3://bucket/litellm-managed-prefix/path Args: file_id: Encoded file ID or direct S3 URI @@ -58,14 +65,19 @@ class BedrockFilesHandler(BaseAWSLLM): except Exception: pass - # If not base64 encoded or doesn't contain llm_output_file_id, assume it's already an S3 URI + # If not base64 encoded or doesn't contain llm_output_file_id, accept only + # explicit S3 URIs. Bucket and key validation happens before any S3 call. if file_id.startswith("s3://"): return file_id - # If it doesn't start with s3://, assume it's a direct S3 URI and add the prefix - return f"s3://{file_id}" + raise ValueError("file_id must be a managed LiteLLM S3 file id") - def _parse_s3_uri(self, s3_uri: str) -> Tuple[str, str]: + def _parse_s3_uri( + self, + s3_uri: str, + configured_bucket_name: str, + allow_legacy_cloud_file_ids: bool = False, + ) -> Tuple[str, str]: """ Parse S3 URI to extract bucket name and object key. @@ -75,21 +87,34 @@ class BedrockFilesHandler(BaseAWSLLM): Returns: Tuple of (bucket_name, object_key) """ - if not s3_uri.startswith("s3://"): - raise ValueError( - f"Invalid S3 URI format: {s3_uri}. Expected format: s3://bucket-name/path/to/file" + return validate_managed_cloud_file_id( + file_id=s3_uri, + scheme="s3://", + configured_bucket_name=configured_bucket_name, + allowed_object_prefixes=BEDROCK_MANAGED_S3_PREFIXES, + allow_legacy_cloud_file_ids=allow_legacy_cloud_file_ids, + ) + + def _get_configured_s3_bucket_name(self, litellm_params: dict) -> str: + trusted_model_credentials = litellm_params.get( + "_litellm_internal_model_credentials" + ) + bucket_name = None + if isinstance(trusted_model_credentials, type(MappingProxyType({}))): + trusted_model_credentials_mapping = cast( + Mapping[str, Any], trusted_model_credentials ) - - # Remove 's3://' prefix - path = s3_uri[5:] - - if "/" in path: - bucket_name, object_key = path.split("/", 1) - else: - bucket_name = path - object_key = "" - - return bucket_name, object_key + candidate_bucket_name = trusted_model_credentials_mapping.get( + "s3_bucket_name" + ) + if isinstance(candidate_bucket_name, str): + bucket_name = candidate_bucket_name + bucket_name = bucket_name or os.getenv("AWS_S3_BUCKET_NAME") + if not bucket_name: + raise ValueError( + "S3 bucket_name is required. Set 's3_bucket_name' in proxy config or AWS_S3_BUCKET_NAME for Bedrock file content retrieval." + ) + return bucket_name async def afile_content( self, @@ -119,7 +144,14 @@ class BedrockFilesHandler(BaseAWSLLM): # Extract S3 URI from file ID s3_uri = self._extract_s3_uri_from_file_id(file_id) - bucket_name, object_key = self._parse_s3_uri(s3_uri) + configured_bucket_name = self._get_configured_s3_bucket_name(optional_params) + bucket_name, object_key = self._parse_s3_uri( + s3_uri=s3_uri, + configured_bucket_name=configured_bucket_name, + allow_legacy_cloud_file_ids=should_allow_legacy_cloud_file_ids( + optional_params + ), + ) # Get AWS credentials aws_region_name = self._get_aws_region_name( diff --git a/litellm/llms/bedrock/files/transformation.py b/litellm/llms/bedrock/files/transformation.py index 3007b54808..6669363093 100644 --- a/litellm/llms/bedrock/files/transformation.py +++ b/litellm/llms/bedrock/files/transformation.py @@ -2,6 +2,7 @@ import json import os import time from typing import Any, Dict, List, Optional, Tuple, Union +from urllib.parse import unquote import httpx from httpx import Headers, Response @@ -10,6 +11,14 @@ from openai.types.file_deleted import FileDeleted from litellm._logging import verbose_logger from litellm._uuid import uuid from litellm.files.utils import FilesAPIUtils +from litellm.litellm_core_utils.cloud_storage_security import ( + BEDROCK_MANAGED_S3_BATCH_PREFIX, + BEDROCK_MANAGED_S3_UPLOAD_PREFIX, + build_managed_cloud_object_name, + encode_s3_object_key_for_url, + sanitize_cloud_object_component, + split_configured_cloud_bucket_name, +) from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.files.transformation import ( @@ -116,10 +125,13 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): if _model.startswith("bedrock/"): _model = _model[8:] - # Replace colons with hyphens for Bedrock S3 URI compliance - _model = _model.replace(":", "-") + safe_model = sanitize_cloud_object_component( + _model.replace(":", "-"), fallback="model" + ) - object_name = f"litellm-bedrock-files-{_model}-{uuid.uuid4()}.jsonl" + object_name = ( + f"{BEDROCK_MANAGED_S3_BATCH_PREFIX}{safe_model}-{uuid.uuid4()}.jsonl" + ) return object_name def get_object_name( @@ -146,12 +158,13 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): if len(openai_jsonl_content) > 0: return self._get_s3_object_name_from_batch_jsonl(openai_jsonl_content) - ## 2. If not jsonl, return the filename + ## 2. If not jsonl, store under a server-generated managed object name filename = extracted_file_data.get("filename") - if filename: - return filename - ## 3. If no file name, return timestamp - return str(int(time.time())) + return build_managed_cloud_object_name( + prefix=BEDROCK_MANAGED_S3_UPLOAD_PREFIX, + filename=filename, + fallback_filename="file", + ) def get_complete_file_url( self, @@ -172,6 +185,7 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): raise ValueError( "S3 bucket_name is required. Set 's3_bucket_name' in litellm_params or AWS_S3_BUCKET_NAME env var" ) + bucket_name, object_prefix = split_configured_cloud_bucket_name(bucket_name) s3_region_name = litellm_params.get("s3_region_name") or optional_params.get( "s3_region_name" @@ -188,14 +202,17 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): raise ValueError("purpose is required") extracted_file_data = extract_file_data(file_data) object_name = self.get_object_name(extracted_file_data, purpose) + if object_prefix: + object_name = f"{object_prefix}/{object_name}" + encoded_object_name = encode_s3_object_key_for_url(object_name) # S3 endpoint URL format s3_endpoint_url = ( optional_params.get("s3_endpoint_url") or f"https://s3.{aws_region_name}.amazonaws.com" - ) + ).rstrip("/") - return f"{s3_endpoint_url}/{bucket_name}/{object_name}" + return f"{s3_endpoint_url}/{bucket_name}/{encoded_object_name}" def get_supported_openai_params( self, model: str @@ -532,10 +549,12 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): if match1: # Pattern: https://s3.region.amazonaws.com/bucket/key region, bucket, key = match1.groups() + key = unquote(key) s3_uri = f"s3://{bucket}/{key}" elif match2: # Pattern: https://bucket.s3.region.amazonaws.com/key bucket, region, key = match2.groups() + key = unquote(key) s3_uri = f"s3://{bucket}/{key}" else: # Fallback: try to extract bucket and key from URL path @@ -545,6 +564,7 @@ class BedrockFilesConfig(BaseAWSLLM, BaseFilesConfig): path_parts = parsed.path.lstrip("/").split("/", 1) if len(path_parts) >= 2: bucket, key = path_parts[0], path_parts[1] + key = unquote(key) s3_uri = f"s3://{bucket}/{key}" else: raise ValueError(f"Unable to parse S3 URL: {https_url}") @@ -722,7 +742,12 @@ class BedrockJsonlFilesTransformation: # Remove bedrock/ prefix if present if _model.startswith("bedrock/"): _model = _model[8:] - object_name = f"litellm-bedrock-files-{_model}-{uuid.uuid4()}.jsonl" + safe_model = sanitize_cloud_object_component( + _model.replace(":", "-"), fallback="model" + ) + object_name = ( + f"{BEDROCK_MANAGED_S3_BATCH_PREFIX}{safe_model}-{uuid.uuid4()}.jsonl" + ) return object_name def _get_content_from_openai_file(self, openai_file_content: FileTypes) -> str: diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py index 1b15ebaa76..aae2bc5e28 100644 --- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py @@ -12,9 +12,14 @@ from typing import ( import httpx +import litellm from litellm.anthropic_beta_headers_manager import filter_and_transform_beta_headers from litellm.constants import BEDROCK_MIN_THINKING_BUDGET_TOKENS from litellm.litellm_core_utils.litellm_logging import verbose_logger +from litellm.llms.anthropic.chat.transformation import ( + DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING, + AnthropicConfig, +) from litellm.llms.anthropic.common_utils import AnthropicModelInfo from litellm.llms.anthropic.experimental_pass_through.messages.transformation import ( AnthropicMessagesConfig, @@ -580,6 +585,17 @@ class AmazonAnthropicClaudeMessagesConfig( if filtered_betas: anthropic_messages_request["anthropic_beta"] = filtered_betas + if ( + litellm.drop_params is True + and "output_config" in anthropic_messages_request + and not AnthropicConfig._model_supports_effort_param(model) + ): + verbose_logger.warning( + DROP_UNSUPPORTED_OUTPUT_CONFIG_WARNING, + model, + ) + anthropic_messages_request.pop("output_config", None) + # 7. Final safety net: filter top-level fields to the Bedrock Invoke allowlist. # Catches Anthropic-only extensions (context_management, output_config, speed, # mcp_servers, ...) and any future additions Claude Code may start sending. diff --git a/litellm/llms/bedrock/vector_stores/transformation.py b/litellm/llms/bedrock/vector_stores/transformation.py index f028503c6a..ec20d76102 100644 --- a/litellm/llms/bedrock/vector_stores/transformation.py +++ b/litellm/llms/bedrock/vector_stores/transformation.py @@ -5,6 +5,7 @@ from urllib.parse import urlparse import httpx from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfig from litellm.llms.bedrock.base_aws_llm import BaseAWSLLM from litellm.types.integrations.rag.bedrock_knowledgebase import ( @@ -209,7 +210,10 @@ class BedrockVectorStoreConfig(BaseVectorStoreConfig, BaseAWSLLM): if isinstance(query, list): query = " ".join(query) - url = f"{api_base}/{vector_store_id}/retrieve" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}/retrieve" request_body: Dict[str, Any] = { "retrievalQuery": BedrockKBRetrievalQuery(text=query), diff --git a/litellm/llms/black_forest_labs/image_edit/handler.py b/litellm/llms/black_forest_labs/image_edit/handler.py index dea2683a04..f5784e0836 100644 --- a/litellm/llms/black_forest_labs/image_edit/handler.py +++ b/litellm/llms/black_forest_labs/image_edit/handler.py @@ -15,6 +15,7 @@ import httpx import litellm from litellm._logging import verbose_logger from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj +from litellm.litellm_core_utils.url_utils import SSRFError, assert_same_origin from litellm.llms.custom_httpx.http_handler import ( AsyncHTTPHandler, HTTPHandler, @@ -331,6 +332,17 @@ class BlackForestLabsImageEdit: message="No polling_url in BFL response", ) + # Reject cross-origin polling URLs — the ``x-key`` auth header + # would otherwise leak to whatever URL the upstream returns. + # VERIA-51. + try: + assert_same_origin(polling_url, str(initial_response.request.url)) + except SSRFError as ssrf_err: + raise BlackForestLabsError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) + # Get just the auth header for polling polling_headers = {"x-key": headers.get("x-key", "")} @@ -416,6 +428,17 @@ class BlackForestLabsImageEdit: message="No polling_url in BFL response", ) + # Reject cross-origin polling URLs — the ``x-key`` auth header + # would otherwise leak to whatever URL the upstream returns. + # VERIA-51. + try: + assert_same_origin(polling_url, str(initial_response.request.url)) + except SSRFError as ssrf_err: + raise BlackForestLabsError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) + # Get just the auth header for polling polling_headers = {"x-key": headers.get("x-key", "")} diff --git a/litellm/llms/black_forest_labs/image_generation/handler.py b/litellm/llms/black_forest_labs/image_generation/handler.py index 5a1d885e52..8af4a236fd 100644 --- a/litellm/llms/black_forest_labs/image_generation/handler.py +++ b/litellm/llms/black_forest_labs/image_generation/handler.py @@ -15,6 +15,7 @@ import httpx import litellm from litellm._logging import verbose_logger from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj +from litellm.litellm_core_utils.url_utils import SSRFError, assert_same_origin from litellm.llms.custom_httpx.http_handler import ( AsyncHTTPHandler, HTTPHandler, @@ -317,6 +318,17 @@ class BlackForestLabsImageGeneration: message="No polling_url in BFL response", ) + # Reject cross-origin polling URLs — the ``x-key`` auth header + # would otherwise leak to whatever URL the upstream returns. + # VERIA-51. + try: + assert_same_origin(polling_url, str(initial_response.request.url)) + except SSRFError as ssrf_err: + raise BlackForestLabsError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) + # Get just the auth header for polling polling_headers = {"x-key": headers.get("x-key", "")} @@ -402,6 +414,17 @@ class BlackForestLabsImageGeneration: message="No polling_url in BFL response", ) + # Reject cross-origin polling URLs — the ``x-key`` auth header + # would otherwise leak to whatever URL the upstream returns. + # VERIA-51. + try: + assert_same_origin(polling_url, str(initial_response.request.url)) + except SSRFError as ssrf_err: + raise BlackForestLabsError( + status_code=502, + message=f"Rejected polling URL: {ssrf_err}", + ) + # Get just the auth header for polling polling_headers = {"x-key": headers.get("x-key", "")} diff --git a/litellm/llms/bytez/chat/transformation.py b/litellm/llms/bytez/chat/transformation.py index a72f732a30..5b08670f9f 100644 --- a/litellm/llms/bytez/chat/transformation.py +++ b/litellm/llms/bytez/chat/transformation.py @@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union import httpx +from litellm.litellm_core_utils.url_utils import encode_url_path_segments from litellm.litellm_core_utils.exception_mapping_utils import exception_type from litellm.litellm_core_utils.logging_utils import track_llm_api_timing from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException @@ -149,7 +150,8 @@ class BytezChatConfig(BaseConfig): litellm_params: dict, stream: Optional[bool] = None, ) -> str: - return f"{API_BASE}/{model}" + encoded_model = encode_url_path_segments(model, field_name="model") + return f"{API_BASE}/{encoded_model}" def transform_request( self, diff --git a/litellm/llms/cloudflare/chat/transformation.py b/litellm/llms/cloudflare/chat/transformation.py index 9e59782bf7..66e253f304 100644 --- a/litellm/llms/cloudflare/chat/transformation.py +++ b/litellm/llms/cloudflare/chat/transformation.py @@ -5,6 +5,7 @@ from typing import AsyncIterator, Iterator, List, Optional, Union import httpx import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segments from litellm.llms.base_llm.base_model_iterator import BaseModelResponseIterator from litellm.llms.base_llm.chat.transformation import ( BaseConfig, @@ -89,7 +90,8 @@ class CloudflareChatConfig(BaseConfig): api_base = ( f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/" ) - return api_base + model + encoded_model = encode_url_path_segments(model, field_name="model") + return api_base + encoded_model def get_supported_openai_params(self, model: str) -> List[str]: return [ @@ -147,9 +149,9 @@ class CloudflareChatConfig(BaseConfig): ) -> ModelResponse: completion_response = raw_response.json() - model_response.choices[0].message.content = completion_response["result"][ # type: ignore - "response" - ] + # Support both "response" and "response_text" keys (newer models like Nemotron use "response_text") + result = completion_response["result"] + model_response.choices[0].message.content = result.get("response") if result.get("response") is not None else result.get("response_text", "") # type: ignore prompt_tokens = litellm.utils.get_token_count(messages=messages, model=model) completion_tokens = len( @@ -199,8 +201,10 @@ class CloudflareChatResponseIterator(BaseModelResponseIterator): index = int(chunk.get("index", 0)) - if "response" in chunk: + if "response" in chunk and chunk["response"] is not None: text = chunk["response"] + elif "response_text" in chunk and chunk["response_text"] is not None: + text = chunk["response_text"] returned_chunk = GenericStreamingChunk( text=text, diff --git a/litellm/llms/custom_httpx/container_handler.py b/litellm/llms/custom_httpx/container_handler.py index afdd7bc6a8..599cd705eb 100644 --- a/litellm/llms/custom_httpx/container_handler.py +++ b/litellm/llms/custom_httpx/container_handler.py @@ -12,6 +12,7 @@ from typing import TYPE_CHECKING, Any, Coroutine, Dict, Optional, Type, Union import httpx import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.custom_httpx.http_handler import ( AsyncHTTPHandler, HTTPHandler, @@ -72,7 +73,8 @@ def _build_url( # Substitute path parameters for param, value in path_params.items(): - path_template = path_template.replace(f"{{{param}}}", value) + encoded_value = encode_url_path_segment(value, field_name=param) + path_template = path_template.replace(f"{{{param}}}", encoded_value) # Parse the api_base to extract existing query params parsed_base = httpx.URL(api_base) diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index dc625918b9..2ffc7acbfb 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -26,6 +26,7 @@ from litellm._logging import _redact_string, verbose_logger from litellm.anthropic_beta_headers_manager import update_headers_with_filtered_beta from litellm.constants import REALTIME_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES from litellm.litellm_core_utils.realtime_streaming import RealTimeStreaming +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.anthropic_messages.transformation import ( BaseAnthropicMessagesConfig, ) @@ -5578,6 +5579,9 @@ class BaseLLMHTTPHandler: litellm_params=litellm_params, headers=headers, ) + data = image_edit_provider_config.finalize_image_edit_request_data( + data, api_base + ) ## LOGGING logging_obj.pre_call( @@ -5676,6 +5680,9 @@ class BaseLLMHTTPHandler: litellm_params=litellm_params, headers=headers, ) + data = image_edit_provider_config.finalize_image_edit_request_data( + data, api_base + ) ## LOGGING logging_obj.pre_call( @@ -8948,7 +8955,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" logging_obj.pre_call( input="", @@ -9015,7 +9025,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" logging_obj.pre_call( input="", @@ -9214,7 +9227,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" request_body: Dict[str, Any] = dict(vector_store_update_optional_params) @@ -9297,7 +9313,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" request_body: Dict[str, Any] = dict(vector_store_update_optional_params) @@ -9363,7 +9382,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" logging_obj.pre_call( input="", @@ -9428,7 +9450,10 @@ class BaseLLMHTTPHandler: litellm_params=dict(litellm_params), ) - url = f"{api_base}/{vector_store_id}" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}" logging_obj.pre_call( input="", diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py index c086d4ad75..09c782a475 100644 --- a/litellm/llms/databricks/chat/transformation.py +++ b/litellm/llms/databricks/chat/transformation.py @@ -56,7 +56,10 @@ from litellm.types.utils import ( Usage, ) -from ...anthropic.chat.transformation import AnthropicConfig +from ...anthropic.chat.transformation import ( + REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT, + AnthropicConfig, +) from ...openai_like.chat.transformation import OpenAILikeChatConfig from ..common_utils import DatabricksBase, DatabricksException @@ -330,9 +333,30 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): ) # unsupported for claude models - if json_schema -> convert to tool call if "reasoning_effort" in non_default_params and "claude" in model: - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( - reasoning_effort=non_default_params.get("reasoning_effort"), model=model + reasoning_effort_value = non_default_params.get("reasoning_effort") + mapped_thinking = AnthropicConfig._map_reasoning_effort( + reasoning_effort=reasoning_effort_value, + model=model, + llm_provider="databricks", ) + if mapped_thinking is None: + optional_params.pop("thinking", None) + optional_params.pop("output_config", None) + else: + optional_params["thinking"] = mapped_thinking + if AnthropicConfig._is_adaptive_thinking_model(model): + mapped_effort: Optional[str] = None + if isinstance(reasoning_effort_value, str): + mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get( + reasoning_effort_value + ) + if mapped_effort is None: + AnthropicConfig._raise_invalid_reasoning_effort( + model=model, + value=reasoning_effort_value, + llm_provider="databricks", + ) + optional_params["output_config"] = {"effort": mapped_effort} optional_params.pop("reasoning_effort", None) ## handle thinking tokens self.update_optional_params_with_thinking_tokens( diff --git a/litellm/llms/elevenlabs/text_to_speech/transformation.py b/litellm/llms/elevenlabs/text_to_speech/transformation.py index 4dac2b8ba9..6a59911701 100644 --- a/litellm/llms/elevenlabs/text_to_speech/transformation.py +++ b/litellm/llms/elevenlabs/text_to_speech/transformation.py @@ -11,13 +11,14 @@ import httpx from httpx import Headers import litellm -from litellm.types.utils import all_litellm_params +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.text_to_speech.transformation import ( BaseTextToSpeechConfig, TextToSpeechRequestData, ) from litellm.secret_managers.main import get_secret_str +from litellm.types.utils import all_litellm_params from ..common_utils import ElevenLabsException @@ -321,7 +322,8 @@ class ElevenLabsTextToSpeechConfig(BaseTextToSpeechConfig): "ElevenLabs voice_id is required. Pass `voice` when calling `litellm.speech()`." ) - url = f"{base_url}{self.TTS_ENDPOINT_PATH}/{voice_id}" + encoded_voice_id = encode_url_path_segment(voice_id, field_name="voice_id") + url = f"{base_url}{self.TTS_ENDPOINT_PATH}/{encoded_voice_id}" query_params = litellm_params.get(self.ELEVENLABS_QUERY_PARAMS_KEY, {}) if query_params: diff --git a/litellm/llms/gemini/files/transformation.py b/litellm/llms/gemini/files/transformation.py index 401d7bb9f4..63a383ebd3 100644 --- a/litellm/llms/gemini/files/transformation.py +++ b/litellm/llms/gemini/files/transformation.py @@ -12,6 +12,7 @@ import httpx from openai.types.file_deleted import FileDeleted from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.files.transformation import ( BaseFilesConfig, @@ -258,10 +259,14 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig): normalized_file_id = file_id normalized_file_id = normalized_file_id.strip("/") - if not normalized_file_id.startswith("files/"): - normalized_file_id = f"files/{normalized_file_id}" + if normalized_file_id.startswith("files/"): + normalized_file_id = normalized_file_id.removeprefix("files/") - return normalized_file_id + encoded_file_id = encode_url_path_segment( + normalized_file_id, field_name="file_id" + ) + + return f"files/{encoded_file_id}" def transform_retrieve_file_response( self, @@ -337,13 +342,8 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig): if not api_key: raise ValueError("api_key is required") - # Extract file name from URI if full URI is provided - # file_id could be "files/abc123" or "https://generativelanguage.googleapis.com/v1beta/files/abc123" - if file_id.startswith("http"): - # Extract the file path from full URI - file_name = file_id.split("/v1beta/")[-1] - else: - file_name = file_id if file_id.startswith("files/") else f"files/{file_id}" + # Normalize and encode the file name before interpolating it into the URL. + file_name = self._normalize_gemini_file_id(file_id) # Construct the delete URL url = f"{api_base}/v1beta/{file_name}" diff --git a/litellm/llms/gemini/interactions/transformation.py b/litellm/llms/gemini/interactions/transformation.py index c34da83cb8..593cbf7c2c 100644 --- a/litellm/llms/gemini/interactions/transformation.py +++ b/litellm/llms/gemini/interactions/transformation.py @@ -15,6 +15,7 @@ import httpx from litellm._logging import verbose_logger from litellm.litellm_core_utils.core_helpers import process_response_headers +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.interactions.transformation import BaseInteractionsAPIConfig from litellm.llms.gemini.common_utils import GeminiError, GeminiModelInfo from litellm.types.interactions import ( @@ -205,8 +206,11 @@ class GoogleAIStudioInteractionsConfig(BaseInteractionsAPIConfig): resolved_api_base = GeminiModelInfo.get_api_base(api_base) if not GeminiModelInfo.get_api_key(litellm_params.api_key): raise ValueError("Google API key is required") + encoded_interaction_id = encode_url_path_segment( + interaction_id, field_name="interaction_id" + ) return ( - f"{resolved_api_base}/{self.api_version}/interactions/{interaction_id}", + f"{resolved_api_base}/{self.api_version}/interactions/{encoded_interaction_id}", {}, ) @@ -238,8 +242,11 @@ class GoogleAIStudioInteractionsConfig(BaseInteractionsAPIConfig): resolved_api_base = GeminiModelInfo.get_api_base(api_base) if not GeminiModelInfo.get_api_key(litellm_params.api_key): raise ValueError("Google API key is required") + encoded_interaction_id = encode_url_path_segment( + interaction_id, field_name="interaction_id" + ) return ( - f"{resolved_api_base}/{self.api_version}/interactions/{interaction_id}", + f"{resolved_api_base}/{self.api_version}/interactions/{encoded_interaction_id}", {}, ) @@ -268,8 +275,11 @@ class GoogleAIStudioInteractionsConfig(BaseInteractionsAPIConfig): resolved_api_base = GeminiModelInfo.get_api_base(api_base) if not GeminiModelInfo.get_api_key(litellm_params.api_key): raise ValueError("Google API key is required") + encoded_interaction_id = encode_url_path_segment( + interaction_id, field_name="interaction_id" + ) return ( - f"{resolved_api_base}/{self.api_version}/interactions/{interaction_id}:cancel", + f"{resolved_api_base}/{self.api_version}/interactions/{encoded_interaction_id}:cancel", {}, ) diff --git a/litellm/llms/hosted_vllm/embedding/README.md b/litellm/llms/hosted_vllm/embedding/README.md index f82b3c77a6..2c58e16fc2 100644 --- a/litellm/llms/hosted_vllm/embedding/README.md +++ b/litellm/llms/hosted_vllm/embedding/README.md @@ -2,4 +2,15 @@ No transformation is required for hosted_vllm embedding. VLLM is a superset of OpenAI's `embedding` endpoint. -To pass provider-specific parameters, see [this](https://docs.litellm.ai/docs/completion/provider_specific_params) \ No newline at end of file +## `encoding_format` + +For OpenAI-compatible embedding calls (including `openai/...` with a custom `api_base` pointing at vLLM), LiteLLM resolves `encoding_format` when it is not set on the request: + +1. Explicit value on the embedding call (`encoding_format=...`). +2. Model config (`litellm_params.encoding_format` on the proxy `model_list` entry). +3. Environment variable `LITELLM_DEFAULT_EMBEDDING_ENCODING_FORMAT` (e.g. in `.env` or container env). +4. Default **`float`**. + +That avoids forwarding `encoding_format=None` to the provider/SDK where some servers behave poorly. + +To pass provider-specific parameters, see [provider-specific params](https://docs.litellm.ai/docs/completion/provider_specific_params). \ No newline at end of file diff --git a/litellm/llms/litellm_proxy/skills/handler.py b/litellm/llms/litellm_proxy/skills/handler.py index 8e5070c272..37aabd8b47 100644 --- a/litellm/llms/litellm_proxy/skills/handler.py +++ b/litellm/llms/litellm_proxy/skills/handler.py @@ -9,42 +9,47 @@ import uuid from typing import Any, Dict, List, Optional from litellm._logging import verbose_logger -from litellm.proxy._types import LiteLLM_SkillsTable, NewSkillRequest +from litellm.caching.in_memory_cache import InMemoryCache +from litellm.proxy._types import LiteLLM_SkillsTable, NewSkillRequest, UserAPIKeyAuth +from litellm.proxy.common_utils.resource_ownership import ( + get_primary_resource_owner_scope, + get_resource_owner_scopes, + is_proxy_admin, + user_can_access_resource_owner, +) + +# Skills are looked up on every chat completion that has skills enabled +# (`SkillsInjectionHook` calls ``fetch_skill_from_db``). 60s LRU/TTL cache +# absorbs the hot read before it reaches Prisma. ``_NEGATIVE_SKILL_SENTINEL`` +# lets us cache a true "skill does not exist" so repeated misses also +# avoid the DB — ``InMemoryCache`` returns ``None`` indistinguishably for +# "miss" and "cached as None". +_NEGATIVE_SKILL_SENTINEL = "__litellm_skill_not_found__" +_SKILL_CACHE = InMemoryCache(max_size_in_memory=10000, default_ttl=60) def _prisma_skill_to_litellm(prisma_skill) -> LiteLLM_SkillsTable: - """ - Convert a Prisma skill record to LiteLLM_SkillsTable. + """Convert a Prisma skill record to LiteLLM_SkillsTable. - Handles Base64 decoding of file_content field. + Handles Base64 decoding of file_content field — model_dump() converts + Base64 fields to base64-encoded strings. """ import base64 data = prisma_skill.model_dump() - # Decode Base64 file_content back to bytes - # model_dump() converts Base64 field to base64-encoded string if data.get("file_content") is not None: if isinstance(data["file_content"], str): data["file_content"] = base64.b64decode(data["file_content"]) - elif isinstance(data["file_content"], bytes): - # Already bytes, no conversion needed - pass return LiteLLM_SkillsTable(**data) class LiteLLMSkillsHandler: - """ - Handler for LiteLLM database-backed skills operations. - - This class provides static methods for CRUD operations on skills - stored in the LiteLLM proxy database (LiteLLM_SkillsTable). - """ + """CRUD for skills stored in ``litellm_skillstable``.""" @staticmethod async def _get_prisma_client(): - """Get the prisma client from proxy server.""" from litellm.proxy.proxy_server import prisma_client if prisma_client is None: @@ -58,20 +63,21 @@ class LiteLLMSkillsHandler: async def create_skill( data: NewSkillRequest, user_id: Optional[str] = None, + user_api_key_dict: Optional[UserAPIKeyAuth] = None, ) -> LiteLLM_SkillsTable: - """ - Create a new skill in the LiteLLM database. - - Args: - data: NewSkillRequest with skill details - user_id: Optional user ID for tracking - - Returns: - LiteLLM_SkillsTable record - """ prisma_client = await LiteLLMSkillsHandler._get_prisma_client() skill_id = f"litellm_skill_{uuid.uuid4()}" + owner = get_primary_resource_owner_scope(user_api_key_dict) or user_id + if owner is None: + # Identity-less callers (no user_id / team_id / org_id / + # api_key / token) can't be uniquely stamped on the row. + # Stamping a placeholder would let any two such callers see + # each other's skills via the shared owner. ValueError keeps + # this module FastAPI-free per the project layering rule. + raise ValueError( + "Unable to record skill ownership: caller has no identity scope." + ) skill_data: Dict[str, Any] = { "skill_id": skill_id, @@ -79,17 +85,15 @@ class LiteLLMSkillsHandler: "description": data.description, "instructions": data.instructions, "source": "custom", - "created_by": user_id, - "updated_by": user_id, + "created_by": owner, + "updated_by": owner, } - # Handle metadata if data.metadata is not None: from litellm.litellm_core_utils.safe_json_dumps import safe_dumps skill_data["metadata"] = safe_dumps(data.metadata) - # Handle file content - wrap bytes in Base64 for Prisma if data.file_content is not None: from prisma.fields import Base64 @@ -104,112 +108,103 @@ class LiteLLMSkillsHandler: ) new_skill = await prisma_client.db.litellm_skillstable.create(data=skill_data) - return _prisma_skill_to_litellm(new_skill) @staticmethod async def list_skills( limit: int = 20, offset: int = 0, + user_api_key_dict: Optional[UserAPIKeyAuth] = None, ) -> List[LiteLLM_SkillsTable]: - """ - List skills from the LiteLLM database. - - Args: - limit: Maximum number of skills to return - offset: Number of skills to skip - - Returns: - List of LiteLLM_SkillsTable records - """ prisma_client = await LiteLLMSkillsHandler._get_prisma_client() verbose_logger.debug( f"LiteLLMSkillsHandler: Listing skills with limit={limit}, offset={offset}" ) - skills = await prisma_client.db.litellm_skillstable.find_many( - take=limit, - skip=offset, - order={"created_at": "desc"}, - ) + find_many_kwargs: Dict[str, Any] = { + "take": limit, + "skip": offset, + "order": {"created_at": "desc"}, + } + if user_api_key_dict is not None and not is_proxy_admin(user_api_key_dict): + owner_scopes = get_resource_owner_scopes(user_api_key_dict) + if not owner_scopes: + return [] + find_many_kwargs["where"] = {"created_by": {"in": owner_scopes}} + skills = await prisma_client.db.litellm_skillstable.find_many( + **find_many_kwargs + ) return [_prisma_skill_to_litellm(s) for s in skills] @staticmethod - async def get_skill(skill_id: str) -> LiteLLM_SkillsTable: + async def _load_skill(skill_id: str) -> Optional[Any]: + """Cache-first read of the Prisma skill row. Owner-scope filtering + happens on the cached row, so the cache is per-skill not per-caller. """ - Get a skill by ID from the LiteLLM database. + cached = _SKILL_CACHE.get_cache(skill_id) + if cached == _NEGATIVE_SKILL_SENTINEL: + return None + if cached is not None: + return cached - Args: - skill_id: The skill ID to retrieve - - Returns: - LiteLLM_SkillsTable record - - Raises: - ValueError: If skill not found - """ prisma_client = await LiteLLMSkillsHandler._get_prisma_client() - - verbose_logger.debug(f"LiteLLMSkillsHandler: Getting skill {skill_id}") - skill = await prisma_client.db.litellm_skillstable.find_unique( where={"skill_id": skill_id} ) + _SKILL_CACHE.set_cache( + skill_id, skill if skill is not None else _NEGATIVE_SKILL_SENTINEL + ) + return skill - if skill is None: + @staticmethod + async def get_skill( + skill_id: str, + user_api_key_dict: Optional[UserAPIKeyAuth] = None, + ) -> LiteLLM_SkillsTable: + verbose_logger.debug(f"LiteLLMSkillsHandler: Getting skill {skill_id}") + + skill = await LiteLLMSkillsHandler._load_skill(skill_id) + # Same "not found" message for both "missing" and "cross-tenant" + # so callers can't enumerate skill IDs they don't own. + if skill is None or not user_can_access_resource_owner( + getattr(skill, "created_by", None), user_api_key_dict + ): raise ValueError(f"Skill not found: {skill_id}") return _prisma_skill_to_litellm(skill) @staticmethod - async def delete_skill(skill_id: str) -> Dict[str, str]: - """ - Delete a skill by ID from the LiteLLM database. - - Args: - skill_id: The skill ID to delete - - Returns: - Dict with id and type of deleted skill - - Raises: - ValueError: If skill not found - """ + async def delete_skill( + skill_id: str, + user_api_key_dict: Optional[UserAPIKeyAuth] = None, + ) -> Dict[str, str]: prisma_client = await LiteLLMSkillsHandler._get_prisma_client() - verbose_logger.debug(f"LiteLLMSkillsHandler: Deleting skill {skill_id}") - # Check if skill exists - skill = await prisma_client.db.litellm_skillstable.find_unique( - where={"skill_id": skill_id} - ) - - if skill is None: + skill = await LiteLLMSkillsHandler._load_skill(skill_id) + if skill is None or not user_can_access_resource_owner( + getattr(skill, "created_by", None), user_api_key_dict + ): raise ValueError(f"Skill not found: {skill_id}") - # Delete the skill await prisma_client.db.litellm_skillstable.delete(where={"skill_id": skill_id}) + _SKILL_CACHE.set_cache(skill_id, _NEGATIVE_SKILL_SENTINEL) return {"id": skill_id, "type": "skill_deleted"} @staticmethod - async def fetch_skill_from_db(skill_id: str) -> Optional[LiteLLM_SkillsTable]: - """ - Fetch a skill from the database (used by skills injection hook). - - This is a convenience method that returns None instead of raising - an exception if the skill is not found. - - Args: - skill_id: The skill ID to fetch - - Returns: - LiteLLM_SkillsTable or None if not found - """ + async def fetch_skill_from_db( + skill_id: str, + user_api_key_dict: Optional[UserAPIKeyAuth] = None, + ) -> Optional[LiteLLM_SkillsTable]: + """Skills-injection-hook helper: returns None instead of raising on + not-found / not-authorized so the hook can silently skip.""" try: - return await LiteLLMSkillsHandler.get_skill(skill_id) + return await LiteLLMSkillsHandler.get_skill( + skill_id, user_api_key_dict=user_api_key_dict + ) except ValueError: return None except Exception as e: diff --git a/litellm/llms/litellm_proxy/skills/transformation.py b/litellm/llms/litellm_proxy/skills/transformation.py index 4622bda4e8..199f13191f 100644 --- a/litellm/llms/litellm_proxy/skills/transformation.py +++ b/litellm/llms/litellm_proxy/skills/transformation.py @@ -18,6 +18,7 @@ from litellm.types.utils import LlmProviders if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj + from litellm.proxy._types import UserAPIKeyAuth class LiteLLMSkillsTransformationHandler: @@ -44,6 +45,7 @@ class LiteLLMSkillsTransformationHandler: file_type: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, user_id: Optional[str] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, _is_async: bool = False, logging_obj: Optional["LiteLLMLoggingObj"] = None, litellm_call_id: Optional[str] = None, @@ -99,6 +101,7 @@ class LiteLLMSkillsTransformationHandler: file_type=file_type, metadata=metadata, user_id=user_id, + user_api_key_dict=user_api_key_dict, ) import asyncio @@ -113,6 +116,7 @@ class LiteLLMSkillsTransformationHandler: file_type=file_type, metadata=metadata, user_id=user_id, + user_api_key_dict=user_api_key_dict, ) ) @@ -126,6 +130,7 @@ class LiteLLMSkillsTransformationHandler: file_type: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, user_id: Optional[str] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, ) -> Skill: """Async implementation of create_skill.""" # Lazy import to avoid SDK dependency on proxy @@ -145,6 +150,7 @@ class LiteLLMSkillsTransformationHandler: db_skill = await LiteLLMSkillsHandler.create_skill( data=skill_request, user_id=user_id, + user_api_key_dict=user_api_key_dict, ) return self._db_skill_to_response(db_skill) @@ -156,6 +162,7 @@ class LiteLLMSkillsTransformationHandler: _is_async: bool = False, logging_obj: Optional["LiteLLMLoggingObj"] = None, litellm_call_id: Optional[str] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, **kwargs, ) -> Union[ListSkillsResponse, Coroutine[Any, Any, ListSkillsResponse]]: """ @@ -182,18 +189,27 @@ class LiteLLMSkillsTransformationHandler: ) if _is_async: - return self._async_list_skills(limit=limit, offset=offset) + return self._async_list_skills( + limit=limit, + offset=offset, + user_api_key_dict=user_api_key_dict, + ) import asyncio return asyncio.get_event_loop().run_until_complete( - self._async_list_skills(limit=limit, offset=offset) + self._async_list_skills( + limit=limit, + offset=offset, + user_api_key_dict=user_api_key_dict, + ) ) async def _async_list_skills( self, limit: int = 20, offset: int = 0, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, ) -> ListSkillsResponse: """Async implementation of list_skills.""" # Lazy import to avoid SDK dependency on proxy @@ -202,6 +218,7 @@ class LiteLLMSkillsTransformationHandler: db_skills = await LiteLLMSkillsHandler.list_skills( limit=limit, offset=offset, + user_api_key_dict=user_api_key_dict, ) skills = [self._db_skill_to_response(s) for s in db_skills] @@ -217,6 +234,7 @@ class LiteLLMSkillsTransformationHandler: _is_async: bool = False, logging_obj: Optional["LiteLLMLoggingObj"] = None, litellm_call_id: Optional[str] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, **kwargs, ) -> Union[Skill, Coroutine[Any, Any, Skill]]: """ @@ -242,20 +260,33 @@ class LiteLLMSkillsTransformationHandler: ) if _is_async: - return self._async_get_skill(skill_id=skill_id) + return self._async_get_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) import asyncio return asyncio.get_event_loop().run_until_complete( - self._async_get_skill(skill_id=skill_id) + self._async_get_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) ) - async def _async_get_skill(self, skill_id: str) -> Skill: + async def _async_get_skill( + self, + skill_id: str, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, + ) -> Skill: """Async implementation of get_skill.""" # Lazy import to avoid SDK dependency on proxy from litellm.llms.litellm_proxy.skills.handler import LiteLLMSkillsHandler - db_skill = await LiteLLMSkillsHandler.get_skill(skill_id=skill_id) + db_skill = await LiteLLMSkillsHandler.get_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) return self._db_skill_to_response(db_skill) def delete_skill_handler( @@ -264,6 +295,7 @@ class LiteLLMSkillsTransformationHandler: _is_async: bool = False, logging_obj: Optional["LiteLLMLoggingObj"] = None, litellm_call_id: Optional[str] = None, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, **kwargs, ) -> Union[DeleteSkillResponse, Coroutine[Any, Any, DeleteSkillResponse]]: """ @@ -289,20 +321,33 @@ class LiteLLMSkillsTransformationHandler: ) if _is_async: - return self._async_delete_skill(skill_id=skill_id) + return self._async_delete_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) import asyncio return asyncio.get_event_loop().run_until_complete( - self._async_delete_skill(skill_id=skill_id) + self._async_delete_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) ) - async def _async_delete_skill(self, skill_id: str) -> DeleteSkillResponse: + async def _async_delete_skill( + self, + skill_id: str, + user_api_key_dict: Optional["UserAPIKeyAuth"] = None, + ) -> DeleteSkillResponse: """Async implementation of delete_skill.""" # Lazy import to avoid SDK dependency on proxy from litellm.llms.litellm_proxy.skills.handler import LiteLLMSkillsHandler - result = await LiteLLMSkillsHandler.delete_skill(skill_id=skill_id) + result = await LiteLLMSkillsHandler.delete_skill( + skill_id=skill_id, + user_api_key_dict=user_api_key_dict, + ) return DeleteSkillResponse( id=result["id"], type=result.get("type", "skill_deleted"), diff --git a/litellm/llms/manus/files/transformation.py b/litellm/llms/manus/files/transformation.py index 3381a5327e..3416616139 100644 --- a/litellm/llms/manus/files/transformation.py +++ b/litellm/llms/manus/files/transformation.py @@ -18,6 +18,7 @@ from openai.types.file_deleted import FileDeleted import litellm from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.files.transformation import ( @@ -306,7 +307,8 @@ class ManusFilesConfig(BaseFilesConfig): optional_params=optional_params, litellm_params=litellm_params, ) - return f"{api_base}/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}", {} def transform_retrieve_file_response( self, @@ -336,7 +338,8 @@ class ManusFilesConfig(BaseFilesConfig): optional_params=optional_params, litellm_params=litellm_params, ) - return f"{api_base}/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}", {} def transform_delete_file_response( self, @@ -422,7 +425,8 @@ class ManusFilesConfig(BaseFilesConfig): optional_params=optional_params, litellm_params=litellm_params, ) - return f"{api_base}/{file_id}/content", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}/content", {} def transform_file_content_response( self, diff --git a/litellm/llms/manus/responses/transformation.py b/litellm/llms/manus/responses/transformation.py index 510c41304a..b3a0073a5c 100644 --- a/litellm/llms/manus/responses/transformation.py +++ b/litellm/llms/manus/responses/transformation.py @@ -6,6 +6,7 @@ import httpx import litellm from litellm._logging import verbose_logger from litellm.litellm_core_utils.core_helpers import process_response_headers +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import ( _safe_convert_created_field, ) @@ -270,7 +271,10 @@ class ManusResponsesAPIConfig(OpenAIResponsesAPIConfig): Reference: https://open.manus.im/docs/openai-compatibility """ - url = f"{api_base}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}" data: Dict = {} return url, data diff --git a/litellm/llms/openai/chat/gpt_5_transformation.py b/litellm/llms/openai/chat/gpt_5_transformation.py index 34941a545e..4e34d10b18 100644 --- a/litellm/llms/openai/chat/gpt_5_transformation.py +++ b/litellm/llms/openai/chat/gpt_5_transformation.py @@ -244,9 +244,11 @@ class OpenAIGPT5Config(OpenAIGPTConfig): ), status_code=400, ) - elif effective_effort == "minimal": - # minimal is opt-out: unknown models pass through; only block when - # the model map explicitly sets supports_minimal_reasoning_effort=false. + elif effective_effort in ("minimal", "low"): + # minimal/low are opt-out: unknown models pass through; only block when + # the model map explicitly sets supports_{level}_reasoning_effort=false. + # Example: gpt-5.5-pro only accepts {medium, high, xhigh}, so it sets + # supports_low_reasoning_effort=false (and supports_minimal=false). if self._is_reasoning_effort_level_explicitly_disabled( model, effective_effort ): diff --git a/litellm/llms/openai/containers/transformation.py b/litellm/llms/openai/containers/transformation.py index 955b9f760d..7f874ffd3b 100644 --- a/litellm/llms/openai/containers/transformation.py +++ b/litellm/llms/openai/containers/transformation.py @@ -6,6 +6,7 @@ import litellm from litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking import ( StandardBuiltInToolCostTracking, ) +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.secret_managers.main import get_secret_str from litellm.types.containers.main import ( ContainerCreateOptionalRequestParams, @@ -198,7 +199,10 @@ class OpenAIContainerConfig(BaseContainerConfig): ) -> Tuple[str, Dict]: """Transform the OpenAI container retrieve request.""" # For container retrieve, we just need to construct the URL - url = join_container_api_base_path(api_base, f"/{container_id}") + encoded_container_id = encode_url_path_segment( + container_id, field_name="container_id" + ) + url = join_container_api_base_path(api_base, f"/{encoded_container_id}") # No additional data needed for GET request data: Dict[str, Any] = {} @@ -230,7 +234,10 @@ class OpenAIContainerConfig(BaseContainerConfig): - DELETE /v1/containers/{container_id} """ # Construct the URL for container delete - url = join_container_api_base_path(api_base, f"/{container_id}") + encoded_container_id = encode_url_path_segment( + container_id, field_name="container_id" + ) + url = join_container_api_base_path(api_base, f"/{encoded_container_id}") # No data needed for DELETE request data: Dict[str, Any] = {} @@ -267,7 +274,10 @@ class OpenAIContainerConfig(BaseContainerConfig): - GET /v1/containers/{container_id}/files """ # Construct the URL for container files - url = join_container_api_base_path(api_base, f"/{container_id}/files") + encoded_container_id = encode_url_path_segment( + container_id, field_name="container_id" + ) + url = join_container_api_base_path(api_base, f"/{encoded_container_id}/files") # Prepare query parameters params: Dict[str, Any] = {} @@ -311,8 +321,12 @@ class OpenAIContainerConfig(BaseContainerConfig): - GET /v1/containers/{container_id}/files/{file_id}/content """ # Construct the URL for container file content + encoded_container_id = encode_url_path_segment( + container_id, field_name="container_id" + ) + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") url = join_container_api_base_path( - api_base, f"/{container_id}/files/{file_id}/content" + api_base, f"/{encoded_container_id}/files/{encoded_file_id}/content" ) # No query parameters needed diff --git a/litellm/llms/openai/evals/transformation.py b/litellm/llms/openai/evals/transformation.py index c24dbf8637..66537e56a6 100644 --- a/litellm/llms/openai/evals/transformation.py +++ b/litellm/llms/openai/evals/transformation.py @@ -7,6 +7,7 @@ from typing import Any, Dict, Optional, Tuple import httpx from litellm._logging import verbose_logger +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.evals.transformation import ( BaseEvalsAPIConfig, LiteLLMLoggingObj, @@ -76,7 +77,8 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): api_base = "https://api.openai.com" if eval_id: - return f"{api_base}/v1/evals/{eval_id}" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + return f"{api_base}/v1/evals/{encoded_eval_id}" return f"{api_base}/v1/{endpoint}" def transform_create_eval_request( @@ -276,7 +278,8 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): if litellm_params and litellm_params.api_base: api_base = litellm_params.api_base - url = f"{api_base}/v1/evals/{eval_id}/runs" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + url = f"{api_base}/v1/evals/{encoded_eval_id}/runs" # Build request body request_body = {k: v for k, v in create_request.items() if v is not None} @@ -310,7 +313,8 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): if litellm_params and litellm_params.api_base: api_base = litellm_params.api_base - url = f"{api_base}/v1/evals/{eval_id}/runs" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + url = f"{api_base}/v1/evals/{encoded_eval_id}/runs" # Build query parameters query_params: Dict[str, Any] = {} @@ -350,7 +354,9 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): headers: dict, ) -> Tuple[str, Dict]: """Transform get run request for OpenAI""" - url = f"{api_base}/v1/evals/{eval_id}/runs/{run_id}" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + encoded_run_id = encode_url_path_segment(run_id, field_name="run_id") + url = f"{api_base}/v1/evals/{encoded_eval_id}/runs/{encoded_run_id}" verbose_logger.debug("Get run request - URL: %s", url) @@ -376,7 +382,9 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): headers: dict, ) -> Tuple[str, Dict, Dict]: """Transform cancel run request for OpenAI""" - url = f"{api_base}/v1/evals/{eval_id}/runs/{run_id}/cancel" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + encoded_run_id = encode_url_path_segment(run_id, field_name="run_id") + url = f"{api_base}/v1/evals/{encoded_eval_id}/runs/{encoded_run_id}/cancel" # Empty body for cancel request request_body: Dict[str, Any] = {} @@ -405,7 +413,9 @@ class OpenAIEvalsConfig(BaseEvalsAPIConfig): headers: dict, ) -> Tuple[str, Dict, Dict]: """Transform delete run request for OpenAI""" - url = f"{api_base}/v1/evals/{eval_id}/runs/{run_id}" + encoded_eval_id = encode_url_path_segment(eval_id, field_name="eval_id") + encoded_run_id = encode_url_path_segment(run_id, field_name="run_id") + url = f"{api_base}/v1/evals/{encoded_eval_id}/runs/{encoded_run_id}" # Empty body for delete request request_body: Dict[str, Any] = {} diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index 87c502032c..b7d5340d8d 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -7,6 +7,7 @@ from pydantic import BaseModel, ValidationError import litellm from litellm._logging import verbose_logger from litellm.litellm_core_utils.core_helpers import process_response_headers +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import ( _safe_convert_created_field, ) @@ -421,7 +422,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): OpenAI API expects the following request - DELETE /v1/responses/{response_id} """ - url = f"{api_base}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}" data: Dict = {} return url, data @@ -457,7 +461,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): OpenAI API expects the following request - GET /v1/responses/{response_id} """ - url = f"{api_base}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}" data: Dict = {} return url, data @@ -498,7 +505,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): limit: int = 20, order: Literal["asc", "desc"] = "desc", ) -> Tuple[str, Dict]: - url = f"{api_base}/{response_id}/input_items" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}/input_items" params: Dict[str, Any] = {} if after is not None: params["after"] = after @@ -540,7 +550,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): OpenAI API expects the following request - POST /v1/responses/{response_id}/cancel """ - url = f"{api_base}/{response_id}/cancel" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}/cancel" data: Dict = {} return url, data diff --git a/litellm/llms/openai/vector_store_files/transformation.py b/litellm/llms/openai/vector_store_files/transformation.py index cd5f10251b..52202f57fd 100644 --- a/litellm/llms/openai/vector_store_files/transformation.py +++ b/litellm/llms/openai/vector_store_files/transformation.py @@ -3,6 +3,7 @@ from typing import Any, Dict, Optional, Tuple, cast import httpx import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.vector_store_files.transformation import ( BaseVectorStoreFilesConfig, ) @@ -98,7 +99,10 @@ class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig): or "https://api.openai.com/v1" ) base_url = base_url.rstrip("/") - return f"{base_url}/vector_stores/{vector_store_id}/files" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + return f"{base_url}/vector_stores/{encoded_vector_store_id}/files" def transform_create_vector_store_file_request( self, @@ -163,7 +167,8 @@ class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig): file_id: str, api_base: str, ) -> Tuple[str, Dict[str, Any]]: - return f"{api_base}/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}", {} def transform_retrieve_vector_store_file_response( self, @@ -186,7 +191,8 @@ class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig): file_id: str, api_base: str, ) -> Tuple[str, Dict[str, Any]]: - return f"{api_base}/{file_id}/content", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}/content", {} def transform_retrieve_vector_store_file_content_response( self, @@ -218,7 +224,8 @@ class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig): payload["attributes"] = filtered_attributes else: payload.pop("attributes", None) - return f"{api_base}/{file_id}", payload + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}", payload def transform_update_vector_store_file_response( self, @@ -241,7 +248,8 @@ class OpenAIVectorStoreFilesConfig(BaseVectorStoreFilesConfig): file_id: str, api_base: str, ) -> Tuple[str, Dict[str, Any]]: - return f"{api_base}/{file_id}", {} + encoded_file_id = encode_url_path_segment(file_id, field_name="file_id") + return f"{api_base}/{encoded_file_id}", {} def transform_delete_vector_store_file_response( self, diff --git a/litellm/llms/openai/vector_stores/transformation.py b/litellm/llms/openai/vector_stores/transformation.py index 2c11d13748..bd095a0a1b 100644 --- a/litellm/llms/openai/vector_stores/transformation.py +++ b/litellm/llms/openai/vector_stores/transformation.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast import httpx import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfig from litellm.secret_managers.main import get_secret_str from litellm.types.router import GenericLiteLLMParams @@ -108,7 +109,10 @@ class OpenAIVectorStoreConfig(BaseVectorStoreConfig): litellm_params: dict, extra_body: Optional[Dict[str, Any]] = None, ) -> Tuple[str, Dict]: - url = f"{api_base}/{vector_store_id}/search" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}/search" typed_request_body = VectorStoreSearchRequest( query=query, filters=vector_store_search_optional_params.get("filters", None), diff --git a/litellm/llms/openai/videos/transformation.py b/litellm/llms/openai/videos/transformation.py index 61baa56949..2d165a7d7d 100644 --- a/litellm/llms/openai/videos/transformation.py +++ b/litellm/llms/openai/videos/transformation.py @@ -1,11 +1,13 @@ import mimetypes from io import BufferedReader, BytesIO from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast +from urllib.parse import quote import httpx from httpx._types import RequestFiles import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.videos.transformation import BaseVideoConfig from litellm.llms.openai.image_edit.transformation import ImageEditRequestUtils from litellm.secret_managers.main import get_secret_str @@ -220,11 +222,18 @@ class OpenAIVideoConfig(BaseVideoConfig): - GET /v1/videos/{video_id}/content?variant=thumbnail """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Construct the URL for video content download - url = f"{api_base.rstrip('/')}/{original_video_id}/content" + url = f"{api_base.rstrip('/')}/{encoded_video_id}/content" if variant is not None: - url = f"{url}?variant={variant}" + # Encode the user-controlled ``variant`` so a value like + # ``thumbnail&extra=1`` cannot inject additional query params + # into the upstream request — same hardening rationale as the + # path-segment encoding above. + url = f"{url}?variant={quote(variant, safe='')}" # No additional data needed for GET content request data: Dict[str, Any] = {} @@ -247,9 +256,12 @@ class OpenAIVideoConfig(BaseVideoConfig): - POST /v1/videos/{video_id}/remix """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Construct the URL for video remix - url = f"{api_base.rstrip('/')}/{original_video_id}/remix" + url = f"{api_base.rstrip('/')}/{encoded_video_id}/remix" # Prepare the request data data = {"prompt": prompt} @@ -391,9 +403,12 @@ class OpenAIVideoConfig(BaseVideoConfig): - DELETE /v1/videos/{video_id} """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Construct the URL for video delete - url = f"{api_base.rstrip('/')}/{original_video_id}" + url = f"{api_base.rstrip('/')}/{encoded_video_id}" # No data needed for DELETE request data: Dict[str, Any] = {} @@ -427,9 +442,12 @@ class OpenAIVideoConfig(BaseVideoConfig): """ # Extract the original video_id (remove provider encoding if present) original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # For video retrieve, we just need to construct the URL - url = f"{api_base.rstrip('/')}/{original_video_id}" + url = f"{api_base.rstrip('/')}/{encoded_video_id}" # No additional data needed for GET request data: Dict[str, Any] = {} @@ -494,7 +512,11 @@ class OpenAIVideoConfig(BaseVideoConfig): litellm_params: GenericLiteLLMParams, headers: dict, ) -> Tuple[str, Dict]: - url = f"{api_base.rstrip('/')}/characters/{character_id}" + original_character_id = extract_original_character_id(character_id) + encoded_character_id = encode_url_path_segment( + original_character_id, field_name="character_id" + ) + url = f"{api_base.rstrip('/')}/characters/{encoded_character_id}" return url, {} def transform_video_get_character_response( diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index 5dd1247001..b5e5aa4ea2 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -106,5 +106,13 @@ "base_url": "https://aihubmix.com/v1", "api_key_env": "AIHUBMIX_API_KEY", "api_base_env": "AIHUBMIX_API_BASE" + }, + "crusoe": { + "base_url": "https://managed-inference-api-proxy.crusoecloud.com/v1", + "api_key_env": "CRUSOE_API_KEY", + "api_base_env": "CRUSOE_API_BASE", + "param_mappings": { + "max_completion_tokens": "max_tokens" + } } } diff --git a/litellm/llms/pg_vector/vector_stores/transformation.py b/litellm/llms/pg_vector/vector_stores/transformation.py index 7b22edd867..fc4cfc7b08 100644 --- a/litellm/llms/pg_vector/vector_stores/transformation.py +++ b/litellm/llms/pg_vector/vector_stores/transformation.py @@ -1,5 +1,6 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.openai.vector_stores.transformation import OpenAIVectorStoreConfig from litellm.secret_managers.main import get_secret_str from litellm.types.router import GenericLiteLLMParams @@ -82,7 +83,10 @@ class PGVectorStoreConfig(OpenAIVectorStoreConfig): litellm_params: dict, extra_body: Optional[Dict[str, Any]] = None, ) -> Tuple[str, Dict]: - url = f"{api_base}/{vector_store_id}/search" + encoded_vector_store_id = encode_url_path_segment( + vector_store_id, field_name="vector_store_id" + ) + url = f"{api_base}/{encoded_vector_store_id}/search" _, request_body = super().transform_search_vector_store_request( vector_store_id=vector_store_id, query=query, diff --git a/litellm/llms/ragflow/chat/transformation.py b/litellm/llms/ragflow/chat/transformation.py index d49a5fd370..990fc2b2e6 100644 --- a/litellm/llms/ragflow/chat/transformation.py +++ b/litellm/llms/ragflow/chat/transformation.py @@ -13,6 +13,7 @@ Model name format: from typing import List, Optional, Tuple import litellm +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.openai.openai import OpenAIConfig from litellm.secret_managers.main import get_secret, get_secret_str from litellm.types.llms.openai import AllMessageValues @@ -126,10 +127,11 @@ class RAGFlowConfig(OpenAIConfig): api_base = api_base[:-3] # Remove /v1 # Construct the RAGFlow-specific path + encoded_entity_id = encode_url_path_segment(entity_id, field_name="entity_id") if endpoint_type == "chat": - path = f"/api/v1/chats_openai/{entity_id}/chat/completions" + path = f"/api/v1/chats_openai/{encoded_entity_id}/chat/completions" else: # agent - path = f"/api/v1/agents_openai/{entity_id}/chat/completions" + path = f"/api/v1/agents_openai/{encoded_entity_id}/chat/completions" # Ensure path starts with / if not path.startswith("/"): diff --git a/litellm/llms/runwayml/videos/transformation.py b/litellm/llms/runwayml/videos/transformation.py index 8377dea952..4f84816a2b 100644 --- a/litellm/llms/runwayml/videos/transformation.py +++ b/litellm/llms/runwayml/videos/transformation.py @@ -6,6 +6,7 @@ from httpx._types import RequestFiles import litellm from litellm.constants import RUNWAYML_DEFAULT_API_VERSION +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.videos.transformation import BaseVideoConfig from litellm.llms.custom_httpx.http_handler import ( @@ -334,9 +335,12 @@ class RunwayMLVideoConfig(BaseVideoConfig): We'll retrieve the task and extract the video URL. """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Get task status to retrieve video URL - url = f"{api_base}/tasks/{original_video_id}" + url = f"{api_base}/tasks/{encoded_video_id}" params: Dict[str, Any] = {} @@ -495,9 +499,12 @@ class RunwayMLVideoConfig(BaseVideoConfig): RunwayML uses task cancellation. """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Construct the URL for task cancellation - url = f"{api_base}/tasks/{original_video_id}/cancel" + url = f"{api_base}/tasks/{encoded_video_id}/cancel" data: Dict[str, Any] = {} @@ -533,9 +540,12 @@ class RunwayMLVideoConfig(BaseVideoConfig): RunwayML uses GET /v1/tasks/{task_id} to retrieve task status. """ original_video_id = extract_original_video_id(video_id) + encoded_video_id = encode_url_path_segment( + original_video_id, field_name="video_id" + ) # Construct the full URL for task status retrieval - url = f"{api_base}/tasks/{original_video_id}" + url = f"{api_base}/tasks/{encoded_video_id}" # Empty dict for GET request (no body) data: Dict[str, Any] = {} diff --git a/litellm/llms/vertex_ai/batches/handler.py b/litellm/llms/vertex_ai/batches/handler.py index 7436bfef58..c627599da8 100644 --- a/litellm/llms/vertex_ai/batches/handler.py +++ b/litellm/llms/vertex_ai/batches/handler.py @@ -4,7 +4,11 @@ from typing import Any, Coroutine, Dict, Optional, Union import httpx import litellm -from litellm.litellm_core_utils.url_utils import async_safe_get, safe_get +from litellm.litellm_core_utils.url_utils import ( + async_safe_get, + encode_url_path_segment, + safe_get, +) from litellm.llms.custom_httpx.http_handler import ( _get_httpx_client, get_async_httpx_client, @@ -170,7 +174,8 @@ class VertexAIBatchPrediction(VertexLLM): ) # Append batch_id to the URL - default_api_base = f"{default_api_base}/{batch_id}" + encoded_batch_id = encode_url_path_segment(batch_id, field_name="batch_id") + default_api_base = f"{default_api_base}/{encoded_batch_id}" if len(default_api_base.split(":")) > 1: endpoint = default_api_base.split(":")[-1] @@ -413,7 +418,8 @@ class VertexAIBatchPrediction(VertexLLM): vertex_project=vertex_project or project_id, ) - retrieve_api_base_default = f"{default_api_base}/{batch_id}" + encoded_batch_id = encode_url_path_segment(batch_id, field_name="batch_id") + retrieve_api_base_default = f"{default_api_base}/{encoded_batch_id}" cancel_api_base_default = f"{retrieve_api_base_default}:cancel" _, api_base = self._check_custom_proxy( diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index fae175612b..e6e3965110 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -97,7 +97,7 @@ def get_vertex_ai_model_route( Determine which handler to use for a Vertex AI model based on the model name. Args: - model: The model name (e.g., "llama3-405b", "gemini-pro", "gemma/gemma-3-12b-it", "openai/gpt-oss-120b") + model: The model name (e.g., "llama3-405b", "gemini-pro", "gemma/gemma-3-12b-it", "xai/grok-4.1-fast-non-reasoning") litellm_params: Optional litellm parameters dict that may contain base_model for routing Returns: @@ -113,7 +113,7 @@ def get_vertex_ai_model_route( >>> get_vertex_ai_model_route("gemma/gemma-3-12b-it") VertexAIModelRoute.GEMMA - >>> get_vertex_ai_model_route("openai/gpt-oss-120b") + >>> get_vertex_ai_model_route("xai/grok-4.1-fast-non-reasoning") VertexAIModelRoute.MODEL_GARDEN >>> get_vertex_ai_model_route("1234567890", {"api_base": "http://10.96.32.8"}) @@ -149,8 +149,11 @@ def get_vertex_ai_model_route( if "gemma/" in model: return VertexAIModelRoute.GEMMA - # Check for model garden openai models - if "openai" in model: + # Check for model garden OpenAI-compatible publisher models. + # Examples: + # - openai/gpt-oss-120b-maas + # - xai/grok-4.1-fast-non-reasoning + if "openai" in model or model.startswith("xai/"): return VertexAIModelRoute.MODEL_GARDEN # Check for gemini models @@ -256,8 +259,8 @@ def get_vertex_base_model_name(model: str) -> str: >>> get_vertex_base_model_name("gemma/gemma-3-12b-it") "gemma-3-12b-it" - >>> get_vertex_base_model_name("openai/gpt-oss-120b") - "gpt-oss-120b" + >>> get_vertex_base_model_name("xai/grok-4.1-fast-non-reasoning") + "grok-4.1-fast-non-reasoning" >>> get_vertex_base_model_name("1234567890") "1234567890" @@ -653,6 +656,8 @@ def process_items(schema, depth=0): and ("items" not in schema or schema.get("items") == {}) ): schema["items"] = {"type": "object"} + elif schema.get("type") == "array" and "items" not in schema: + schema["items"] = {"type": "object"} for key, value in schema.items(): if isinstance(value, dict): process_items(value, depth + 1) diff --git a/litellm/llms/vertex_ai/files/handler.py b/litellm/llms/vertex_ai/files/handler.py index 6636bccd6a..c31bfde69e 100644 --- a/litellm/llms/vertex_ai/files/handler.py +++ b/litellm/llms/vertex_ai/files/handler.py @@ -1,5 +1,6 @@ import asyncio -import urllib.parse +import time +from urllib.parse import unquote from typing import Any, Coroutine, Optional, Tuple, Union import httpx @@ -9,6 +10,11 @@ from litellm.integrations.gcs_bucket.gcs_bucket_base import ( GCSBucketBase, GCSLoggingConfig, ) +from litellm.litellm_core_utils.cloud_storage_security import ( + VERTEX_AI_MANAGED_GCS_PREFIX, + should_allow_legacy_cloud_file_ids, + validate_managed_cloud_file_id, +) from litellm.llms.custom_httpx.http_handler import get_async_httpx_client from litellm.types.llms.openai import ( CreateFileRequest, @@ -16,9 +22,10 @@ from litellm.types.llms.openai import ( HttpxBinaryResponseContent, OpenAIFileObject, ) +from litellm.litellm_core_utils.litellm_logging import Logging from litellm.types.llms.vertex_ai import VERTEX_CREDENTIALS_TYPES -from .transformation import VertexAIJsonlFilesTransformation +from .transformation import VertexAIFilesConfig, VertexAIJsonlFilesTransformation vertex_ai_files_transformation = VertexAIJsonlFilesTransformation() @@ -112,34 +119,31 @@ class VertexAIFilesHandler(GCSBucketBase): ) ) - def _extract_bucket_and_object_from_file_id(self, file_id: str) -> Tuple[str, str]: + def _extract_bucket_and_object_from_file_id( + self, + file_id: str, + configured_bucket_name: str, + litellm_params: Optional[dict] = None, + ) -> Tuple[str, str]: """ - Extract bucket name and object path from URL-encoded file_id. + Validate and extract bucket name and object path from file_id. - Expected format: gs%3A%2F%2Fbucket-name%2Fpath%2Fto%2Ffile - Which decodes to: gs://bucket-name/path/to/file + Expected format: gs://bucket-name/litellm-vertex-files/path/to/file Returns: - tuple: (bucket_name, url_encoded_object_path) + tuple: (bucket_name, object_path) - bucket_name: "bucket-name" - - url_encoded_object_path: "path%2Fto%2Ffile" + - object_path: "litellm-vertex-files/path/to/file" """ - decoded_path = urllib.parse.unquote(file_id) - - if decoded_path.startswith("gs://"): - full_path = decoded_path[5:] # Remove 'gs://' prefix - else: - full_path = decoded_path - - if "/" in full_path: - bucket_name, object_path = full_path.split("/", 1) - else: - bucket_name = full_path - object_path = "" - - encoded_object_path = urllib.parse.quote(object_path, safe="") - - return bucket_name, encoded_object_path + return validate_managed_cloud_file_id( + file_id=file_id, + scheme="gs://", + configured_bucket_name=configured_bucket_name, + allowed_object_prefixes=(VERTEX_AI_MANAGED_GCS_PREFIX,), + allow_legacy_cloud_file_ids=should_allow_legacy_cloud_file_ids( + litellm_params + ), + ) async def afile_content( self, @@ -149,6 +153,7 @@ class VertexAIFilesHandler(GCSBucketBase): vertex_location: Optional[str], timeout: Union[float, httpx.Timeout], max_retries: Optional[int], + litellm_params: Optional[dict] = None, ) -> HttpxBinaryResponseContent: """ Download file content from GCS bucket for VertexAI files. @@ -168,31 +173,57 @@ class VertexAIFilesHandler(GCSBucketBase): if not file_id: raise ValueError("file_id is required in file_content_request") - bucket_name, encoded_object_path = self._extract_bucket_and_object_from_file_id( - file_id + gcs_logging_config: GCSLoggingConfig = await self.get_gcs_logging_config( + kwargs={} + ) + bucket_name, object_path = self._extract_bucket_and_object_from_file_id( + file_id=file_id, + configured_bucket_name=gcs_logging_config["bucket_name"], + litellm_params=litellm_params, ) download_kwargs = { - "standard_callback_dynamic_params": {"gcs_bucket_name": bucket_name} + "standard_callback_dynamic_params": { + "gcs_bucket_name": bucket_name, + "gcs_path_service_account": gcs_logging_config["path_service_account"], + } } file_content = await self.download_gcs_object( - object_name=encoded_object_path, **download_kwargs + object_name=object_path, **download_kwargs ) + decoded_file_id = unquote(file_id) if file_content is None: - decoded_path = urllib.parse.unquote(file_id) - raise ValueError(f"Failed to download file from GCS: {decoded_path}") + raise ValueError(f"Failed to download file from GCS: {decoded_file_id}") - decoded_path = urllib.parse.unquote(file_id) mock_response = httpx.Response( status_code=200, content=file_content, - headers={"content-type": "application/octet-stream"}, - request=httpx.Request(method="GET", url=decoded_path), + headers={ + "content-type": "application/octet-stream", + "content-length": str(len(file_content)), + }, + request=httpx.Request(method="GET", url=decoded_file_id), ) - return HttpxBinaryResponseContent(response=mock_response) + # Apply transformation to convert Vertex AI batch outputs to OpenAI format + config = VertexAIFilesConfig() + + # Create a logging object for transformation + logging_obj = Logging( + model="", + messages=[], + stream=False, + call_type="afile_content", + start_time=time.time(), + litellm_call_id="", + function_id="", + ) + + return config.transform_file_content_response( + raw_response=mock_response, logging_obj=logging_obj, litellm_params={} + ) def file_content( self, @@ -204,6 +235,7 @@ class VertexAIFilesHandler(GCSBucketBase): vertex_location: Optional[str], timeout: Union[float, httpx.Timeout], max_retries: Optional[int], + litellm_params: Optional[dict] = None, ) -> Union[ HttpxBinaryResponseContent, Coroutine[Any, Any, HttpxBinaryResponseContent] ]: @@ -232,6 +264,7 @@ class VertexAIFilesHandler(GCSBucketBase): vertex_location=vertex_location, timeout=timeout, max_retries=max_retries, + litellm_params=litellm_params, ) else: return asyncio.run( @@ -242,5 +275,6 @@ class VertexAIFilesHandler(GCSBucketBase): vertex_location=vertex_location, timeout=timeout, max_retries=max_retries, + litellm_params=litellm_params, ) ) diff --git a/litellm/llms/vertex_ai/files/transformation.py b/litellm/llms/vertex_ai/files/transformation.py index 070ec50828..f30518bc7c 100644 --- a/litellm/llms/vertex_ai/files/transformation.py +++ b/litellm/llms/vertex_ai/files/transformation.py @@ -1,13 +1,27 @@ +import base64 import json import os +import re import time -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Tuple, Union +import httpx from httpx import Headers, Response from openai.types.file_deleted import FileDeleted +import litellm from litellm._uuid import uuid from litellm.files.utils import FilesAPIUtils +from litellm.litellm_core_utils.cloud_storage_security import ( + VERTEX_AI_MANAGED_GCS_PREFIX, + build_managed_cloud_object_name, + encode_gcs_object_name_for_url, + sanitize_cloud_object_path, + should_allow_legacy_cloud_file_ids, + split_configured_cloud_bucket_name, + validate_managed_cloud_file_id, +) +from litellm.litellm_core_utils.litellm_logging import Logging from litellm.litellm_core_utils.prompt_templates.common_utils import extract_file_data from litellm.llms.base_llm.chat.transformation import BaseLLMException from litellm.llms.base_llm.files.transformation import ( @@ -31,11 +45,135 @@ from litellm.types.llms.openai import ( PathLike, ) from litellm.types.llms.vertex_ai import GcsBucketResponse -from litellm.types.utils import ExtractedFileData, LlmProviders +from litellm.types.utils import ExtractedFileData, LlmProviders, ModelResponse from ..common_utils import VertexAIError from ..vertex_llm_base import VertexBase +_GCP_LABEL_VALUE_MAX_LEN = 63 +_CUSTOM_ID_RAW_LABEL_PREFIX = "b32_" + + +def _sanitize_gcp_label_value(value: str) -> str: + """ + Sanitize a string to meet GCP label value constraints. + + GCP label values must: + - Be lowercase + - Contain only letters, numbers, underscores, and hyphens + - Be max 63 characters + + Args: + value: The string to sanitize + + Returns: + A sanitized string that meets GCP label constraints + """ + sanitized = re.sub(r"[^a-z0-9_-]", "_", value.lower()) + return sanitized[:_GCP_LABEL_VALUE_MAX_LEN] + + +def _encode_gcp_label_value_chunks(value: str) -> List[str]: + """Encode arbitrary text across one or more GCP-label-safe values.""" + max_encoded_len = _GCP_LABEL_VALUE_MAX_LEN - len(_CUSTOM_ID_RAW_LABEL_PREFIX) + encoded = ( + base64.b32encode(value.encode("utf-8")).decode("ascii").rstrip("=").lower() + ) + return [ + f"{_CUSTOM_ID_RAW_LABEL_PREFIX}{encoded[i : i + max_encoded_len]}" + for i in range(0, len(encoded), max_encoded_len) + ] or [_CUSTOM_ID_RAW_LABEL_PREFIX] + + +def _decode_gcp_label_value_chunks(values: List[str]) -> Optional[str]: + """Decode values produced by _encode_gcp_label_value_chunks.""" + encoded_parts = [] + for value in values: + if not value.startswith(_CUSTOM_ID_RAW_LABEL_PREFIX): + return None + encoded_parts.append(value[len(_CUSTOM_ID_RAW_LABEL_PREFIX) :]) + encoded = "".join(encoded_parts).upper() + padding = "=" * (-len(encoded) % 8) + try: + return base64.b32decode(encoded + padding).decode("utf-8") + except Exception: + return None + + +def _set_litellm_batch_custom_id_labels(labels: Dict[str, str], custom_id: Any) -> None: + """ + Store OpenAI batch custom_id for Vertex batch correlation. + + ``litellm_custom_id`` is GCP-label-safe (may alter casing and characters). + ``litellm_custom_id_raw`` encodes the original string for + round-trip correlation in batch output transforms. + """ + custom_id_str = str(custom_id) + labels["litellm_custom_id"] = _sanitize_gcp_label_value(custom_id_str) + raw_label_chunks = _encode_gcp_label_value_chunks(custom_id_str) + labels["litellm_custom_id_raw"] = raw_label_chunks[0] + for index, raw_label_chunk in enumerate(raw_label_chunks[1:], start=1): + labels[f"litellm_custom_id_raw_{index}"] = raw_label_chunk + + +def _get_litellm_batch_custom_id_from_labels(labels: Dict[str, Any]) -> str: + """Prefer encoded custom_id when present (see _set_litellm_batch_custom_id_labels).""" + raw = labels.get("litellm_custom_id_raw") + if raw: + raw_chunks = [str(raw)] + chunk_prefix = "litellm_custom_id_raw_" + indexed_chunks = [] + for key, value in labels.items(): + if key.startswith(chunk_prefix) and key[len(chunk_prefix) :].isdigit(): + indexed_chunks.append((int(key[len(chunk_prefix) :]), str(value))) + raw_chunks.extend( + raw_label_chunk + for _, raw_label_chunk in sorted(indexed_chunks, key=lambda item: item[0]) + ) + decoded = _decode_gcp_label_value_chunks(raw_chunks) + if decoded is not None: + return decoded + return str(raw) + return str(labels.get("litellm_custom_id", "unknown")) + + +def _openai_batch_jsonl_entries_to_vertex_wrapped_requests( + openai_jsonl_content: List[Dict[str, Any]], + map_openai_to_vertex_params: Callable[[Dict[str, Any]], Dict[str, Any]], +) -> List[Dict[str, Any]]: + """ + Transforms OpenAI JSONL batch entries to Vertex AI JSONL lines. + + jsonl body for vertex is {"request": } + Example Vertex jsonl + {"request":{"contents": [{"role": "user", "parts": [{"text": "What is the relation between the following video and image samples?"}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/animals.mp4", "mimeType": "video/mp4"}}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/image/cricket.jpeg", "mimeType": "image/jpeg"}}]}]}} + {"request":{"contents": [{"role": "user", "parts": [{"text": "Describe what is happening in this video."}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/another_video.mov", "mimeType": "video/mov"}}]}]}} + """ + + vertex_jsonl_content = [] + for _openai_jsonl_content in openai_jsonl_content: + openai_request_body = _openai_jsonl_content.get("body") or {} + vertex_request_body = _transform_request_body( + messages=openai_request_body.get("messages", []), + model=openai_request_body.get("model", ""), + optional_params=map_openai_to_vertex_params(openai_request_body), + custom_llm_provider="vertex_ai", + litellm_params={}, + cached_content=None, + ) + + # Add custom_id as a label for correlation in batch outputs + custom_id = _openai_jsonl_content.get("custom_id") + if custom_id is not None: + if "labels" not in vertex_request_body: + vertex_request_body["labels"] = {} + _set_litellm_batch_custom_id_labels( + vertex_request_body["labels"], custom_id + ) + + vertex_jsonl_content.append({"request": vertex_request_body}) + return vertex_jsonl_content + class VertexAIFilesConfig(VertexBase, BaseFilesConfig): """ @@ -119,7 +257,8 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): _model = openai_jsonl_content[0].get("body", {}).get("model", "") if "publishers/google/models" not in _model: _model = f"publishers/google/models/{_model}" - object_name = f"litellm-vertex-files/{_model}/{uuid.uuid4()}" + safe_model_path = sanitize_cloud_object_path(_model, fallback="model") + object_name = f"{VERTEX_AI_MANAGED_GCS_PREFIX}{safe_model_path}/{uuid.uuid4()}" return object_name def get_object_name( @@ -146,12 +285,19 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): if len(openai_jsonl_content) > 0: return self._get_gcs_object_name_from_batch_jsonl(openai_jsonl_content) - ## 2. If not jsonl, return the filename + ## 2. If not jsonl, store under a server-generated managed object name filename = extracted_file_data.get("filename") - if filename: - return filename - ## 3. If no file name, return timestamp - return str(int(time.time())) + return build_managed_cloud_object_name( + prefix=f"{VERTEX_AI_MANAGED_GCS_PREFIX}uploads/", + filename=filename, + fallback_filename="file", + ) + + def _get_configured_bucket_name(self, litellm_params: Dict) -> str: + bucket_name = litellm_params.get("bucket_name") or os.getenv("GCS_BUCKET_NAME") + if not bucket_name: + raise ValueError("GCS bucket_name is required") + return bucket_name def get_complete_file_url( self, @@ -165,13 +311,8 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): """ Get the complete url for the request """ - bucket_name = ( - litellm_params.get("bucket_name") - or litellm_params.get("litellm_metadata", {}).pop("gcs_bucket_name", None) - or os.getenv("GCS_BUCKET_NAME") - ) - if not bucket_name: - raise ValueError("GCS bucket_name is required") + bucket_name = self._get_configured_bucket_name(litellm_params) + bucket_name, object_prefix = split_configured_cloud_bucket_name(bucket_name) file_data = data.get("file") purpose = data.get("purpose") if file_data is None: @@ -180,9 +321,10 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): raise ValueError("purpose is required") extracted_file_data = extract_file_data(file_data) object_name = self.get_object_name(extracted_file_data, purpose) - endpoint = ( - f"upload/storage/v1/b/{bucket_name}/o?uploadType=media&name={object_name}" - ) + if object_prefix: + object_name = f"{object_prefix}/{object_name}" + encoded_object_name = encode_gcs_object_name_for_url(object_name) + endpoint = f"upload/storage/v1/b/{bucket_name}/o?uploadType=media&name={encoded_object_name}" api_base = api_base or "https://storage.googleapis.com" if not api_base: raise ValueError("api_base is required") @@ -227,28 +369,10 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): def _transform_openai_jsonl_content_to_vertex_ai_jsonl_content( self, openai_jsonl_content: List[Dict[str, Any]] ) -> List[Dict[str, Any]]: - """ - Transforms OpenAI JSONL content to VertexAI JSONL content - - jsonl body for vertex is {"request": } - Example Vertex jsonl - {"request":{"contents": [{"role": "user", "parts": [{"text": "What is the relation between the following video and image samples?"}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/animals.mp4", "mimeType": "video/mp4"}}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/image/cricket.jpeg", "mimeType": "image/jpeg"}}]}]}} - {"request":{"contents": [{"role": "user", "parts": [{"text": "Describe what is happening in this video."}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/another_video.mov", "mimeType": "video/mov"}}]}]}} - """ - - vertex_jsonl_content = [] - for _openai_jsonl_content in openai_jsonl_content: - openai_request_body = _openai_jsonl_content.get("body") or {} - vertex_request_body = _transform_request_body( - messages=openai_request_body.get("messages", []), - model=openai_request_body.get("model", ""), - optional_params=self._map_openai_to_vertex_params(openai_request_body), - custom_llm_provider="vertex_ai", - litellm_params={}, - cached_content=None, - ) - vertex_jsonl_content.append({"request": vertex_request_body}) - return vertex_jsonl_content + return _openai_batch_jsonl_entries_to_vertex_wrapped_requests( + openai_jsonl_content=openai_jsonl_content, + map_openai_to_vertex_params=self._map_openai_to_vertex_params, + ) def transform_create_file_request( self, @@ -339,27 +463,23 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): status_code=status_code, message=error_message, headers=headers ) - def _parse_gcs_uri(self, file_id: str) -> Tuple[str, str]: + def _parse_gcs_uri( + self, file_id: str, litellm_params: Optional[Dict] = None + ) -> Tuple[str, str]: """ - Parse a GCS URI (gs://bucket/path/to/object) into (bucket, url-encoded-object-path). - Handles both raw and URL-encoded input. + Validate a managed GCS file_id and return (bucket, url-encoded-object-path). """ - import urllib.parse - - decoded = urllib.parse.unquote(file_id) - if decoded.startswith("gs://"): - full_path = decoded[5:] - else: - full_path = decoded - - if "/" in full_path: - bucket_name, object_path = full_path.split("/", 1) - else: - bucket_name = full_path - object_path = "" - - encoded_object = urllib.parse.quote(object_path, safe="") - return bucket_name, encoded_object + configured_bucket_name = self._get_configured_bucket_name(litellm_params or {}) + bucket_name, object_path = validate_managed_cloud_file_id( + file_id=file_id, + scheme="gs://", + configured_bucket_name=configured_bucket_name, + allowed_object_prefixes=(VERTEX_AI_MANAGED_GCS_PREFIX,), + allow_legacy_cloud_file_ids=should_allow_legacy_cloud_file_ids( + litellm_params + ), + ) + return bucket_name, encode_gcs_object_name_for_url(object_path) def transform_retrieve_file_request( self, @@ -367,7 +487,7 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): optional_params: dict, litellm_params: dict, ) -> tuple[str, dict]: - bucket, encoded_object = self._parse_gcs_uri(file_id) + bucket, encoded_object = self._parse_gcs_uri(file_id, litellm_params) url = f"https://storage.googleapis.com/storage/v1/b/{bucket}/o/{encoded_object}" return url, {} @@ -399,7 +519,7 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): optional_params: dict, litellm_params: dict, ) -> tuple[str, dict]: - bucket, encoded_object = self._parse_gcs_uri(file_id) + bucket, encoded_object = self._parse_gcs_uri(file_id, litellm_params) url = f"https://storage.googleapis.com/storage/v1/b/{bucket}/o/{encoded_object}" return url, {} @@ -443,7 +563,7 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): litellm_params: dict, ) -> tuple[str, dict]: file_id = file_content_request.get("file_id", "") - bucket, encoded_object = self._parse_gcs_uri(file_id) + bucket, encoded_object = self._parse_gcs_uri(file_id, litellm_params) url = f"https://storage.googleapis.com/storage/v1/b/{bucket}/o/{encoded_object}?alt=media" return url, {} @@ -453,8 +573,229 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig): logging_obj: LiteLLMLoggingObj, litellm_params: dict, ) -> HttpxBinaryResponseContent: + """ + Transform file content response, converting Vertex AI batch output to OpenAI format if applicable. + + This method automatically detects and transforms Vertex AI batch prediction outputs + (predictions.jsonl files) into OpenAI-compatible batch response format. + + If the file is not a batch output or transformation fails, the original content + is returned as-is to maintain backward compatibility. + """ + try: + # Allow users to opt out of automatic Vertex batch output -> OpenAI + # transformation, e.g. if they consume raw `predictions.jsonl` directly. + if getattr(litellm, "disable_vertex_batch_output_transformation", False): + return HttpxBinaryResponseContent(response=raw_response) + + # Try to transform batch output if it's a JSONL file + content = raw_response.content + if content: + transformed_content = self._try_transform_vertex_batch_output_to_openai( + content=content, + logging_obj=logging_obj, + ) + if transformed_content != content: + # Create a new response with transformed content and updated Content-Length + # Update headers with correct Content-Length + new_headers = dict(raw_response.headers) + new_headers["content-length"] = str(len(transformed_content)) + + mock_response = httpx.Response( + status_code=raw_response.status_code, + content=transformed_content, + headers=new_headers, + request=raw_response.request, + ) + return HttpxBinaryResponseContent(response=mock_response) + except Exception: + # If transformation fails, return as-is + pass + return HttpxBinaryResponseContent(response=raw_response) + def _try_transform_vertex_batch_output_to_openai( + self, content: bytes, logging_obj: Optional[LiteLLMLoggingObj] = None + ) -> bytes: + """ + Try to transform Vertex AI batch output to OpenAI format. + If conversion fails at any point, return the original content as-is. + + Vertex AI batch output format (predictions.jsonl): + { + "request": {"contents": [...], "labels": {"litellm_custom_id": "request-1", "litellm_custom_id_raw": "..."}}, + "status": "", + "response": {"candidates": [...], "modelVersion": "gemini-2.5-flash", ...}, + "processed_time": "2026-04-13T10:18:18.102004+00:00" + } + + OpenAI batch output format: + { + "id": "batch_req_...", + "custom_id": "request-1", + "response": { + "status_code": 200, + "request_id": "chatcmpl-...", + "body": {} + }, + "error": null + } + """ + try: + # Decode content + content_str = content.decode("utf-8") + + # Check if it's JSONL (multiple lines) + lines = content_str.strip().split("\n") + if not lines: + return content + + # Try to parse the first line to see if it's Vertex AI batch output + first_line = json.loads(lines[0]) + + # Check if it has Vertex AI batch output structure with discriminating fields + # Must have request, response, and processed_time + # Plus either candidates (success) or status (error) + has_base_structure = ( + "response" in first_line + and "request" in first_line + and "processed_time" in first_line + ) + has_success_or_error = ( + "candidates" in first_line.get("response", {}) + or "promptFeedback" in first_line.get("response", {}) + or bool(first_line.get("status")) + ) + + if not (has_base_structure and has_success_or_error): + # Not a Vertex AI batch output, return as-is + return content + + vertex_gemini_config = VertexGeminiConfig() + # Always use a fresh local Logging object for the per-line transformation + # so we never mutate the caller's logging_obj (which already went through + # pre_call and has its own model/start_time/optional_params set). + batch_transform_logging_obj = Logging( + model="", + messages=[], + stream=False, + call_type="batch_transform", + start_time=time.time(), + litellm_call_id="", + function_id="", + ) + batch_transform_logging_obj.optional_params = {} + mock_httpx_response = httpx.Response( + status_code=200, + headers={"content-type": "application/json"}, + request=httpx.Request(method="POST", url="https://example.com"), + ) + + # Transform all lines + transformed_lines = [] + for line in lines: + if not line.strip(): + continue + + try: + vertex_output = json.loads(line) + openai_output = ( + self._transform_single_vertex_batch_output_to_openai( + vertex_output=vertex_output, + vertex_gemini_config=vertex_gemini_config, + logging_obj=batch_transform_logging_obj, + mock_httpx_response=mock_httpx_response, + ) + ) + transformed_lines.append(json.dumps(openai_output)) + except Exception: + # If any line fails, return original content + return content + + # Return transformed content + return "\n".join(transformed_lines).encode("utf-8") + + except Exception: + # If anything fails, return original content + return content + + def _transform_single_vertex_batch_output_to_openai( + self, + vertex_output: Dict[str, Any], + vertex_gemini_config: VertexGeminiConfig, + logging_obj: Logging, + mock_httpx_response: httpx.Response, + ) -> Dict[str, Any]: + """ + Transform a single Vertex AI batch output line to OpenAI format. + Uses the existing VertexGeminiConfig transformation for the response. + """ + # Extract custom_id from request labels (prefer raw for OpenAI round-trip) + request_data = vertex_output.get("request", {}) + labels = request_data.get("labels", {}) or {} + custom_id = _get_litellm_batch_custom_id_from_labels(labels) + + # Check if there's an error + status = vertex_output.get("status", "") + has_error = bool(status) + + if has_error: + return { + "id": f"batch_req_{uuid.uuid4()}", + "custom_id": custom_id, + "response": None, + "error": { + "code": "vertex_ai_error", + "message": status, + }, + } + + # Transform successful response using existing transformation + vertex_response = vertex_output.get("response", {}) + + # Extract model from response + model = vertex_response.get("modelVersion", "gemini-1.5-flash-001") + if "@" in model: + model = model.split("@")[0] + + try: + # Use existing VertexGeminiConfig transformation + model_response = ModelResponse() + + transformed_response = vertex_gemini_config._transform_google_generate_content_to_openai_model_response( + completion_response=vertex_response, + model_response=model_response, + model=model, + logging_obj=logging_obj, + raw_response=mock_httpx_response, + ) + + # Convert ModelResponse to dict + response_dict = transformed_response.model_dump() + + # Return in OpenAI batch format + return { + "id": f"batch_req_{uuid.uuid4()}", + "custom_id": custom_id, + "response": { + "status_code": 200, + "request_id": response_dict.get("id", ""), + "body": response_dict, + }, + "error": None, + } + + except Exception as e: + return { + "id": f"batch_req_{uuid.uuid4()}", + "custom_id": custom_id, + "response": None, + "error": { + "code": "transformation_error", + "message": f"Failed to transform response: {str(e)}", + }, + } + class VertexAIJsonlFilesTransformation(VertexGeminiConfig): """ @@ -492,29 +833,11 @@ class VertexAIJsonlFilesTransformation(VertexGeminiConfig): def _transform_openai_jsonl_content_to_vertex_ai_jsonl_content( self, openai_jsonl_content: List[Dict[str, Any]] - ): - """ - Transforms OpenAI JSONL content to VertexAI JSONL content - - jsonl body for vertex is {"request": } - Example Vertex jsonl - {"request":{"contents": [{"role": "user", "parts": [{"text": "What is the relation between the following video and image samples?"}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/animals.mp4", "mimeType": "video/mp4"}}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/image/cricket.jpeg", "mimeType": "image/jpeg"}}]}]}} - {"request":{"contents": [{"role": "user", "parts": [{"text": "Describe what is happening in this video."}, {"fileData": {"fileUri": "gs://cloud-samples-data/generative-ai/video/another_video.mov", "mimeType": "video/mov"}}]}]}} - """ - - vertex_jsonl_content = [] - for _openai_jsonl_content in openai_jsonl_content: - openai_request_body = _openai_jsonl_content.get("body") or {} - vertex_request_body = _transform_request_body( - messages=openai_request_body.get("messages", []), - model=openai_request_body.get("model", ""), - optional_params=self._map_openai_to_vertex_params(openai_request_body), - custom_llm_provider="vertex_ai", - litellm_params={}, - cached_content=None, - ) - vertex_jsonl_content.append({"request": vertex_request_body}) - return vertex_jsonl_content + ) -> List[Dict[str, Any]]: + return _openai_batch_jsonl_entries_to_vertex_wrapped_requests( + openai_jsonl_content=openai_jsonl_content, + map_openai_to_vertex_params=self._map_openai_to_vertex_params, + ) def _get_gcs_object_name( self, @@ -528,7 +851,8 @@ class VertexAIJsonlFilesTransformation(VertexGeminiConfig): _model = openai_jsonl_content[0].get("body", {}).get("model", "") if "publishers/google/models" not in _model: _model = f"publishers/google/models/{_model}" - object_name = f"litellm-vertex-files/{_model}/{uuid.uuid4()}" + safe_model_path = sanitize_cloud_object_path(_model, fallback="model") + object_name = f"{VERTEX_AI_MANAGED_GCS_PREFIX}{safe_model_path}/{uuid.uuid4()}" return object_name def _map_openai_to_vertex_params( diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index 87bd484382..9afa5dec46 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -212,6 +212,22 @@ def _process_gemini_media( return _apply_gemini_metadata( part, model, media_resolution_enum, video_metadata ) + elif image_url.startswith( + "https://generativelanguage.googleapis.com/v1beta/files/" + ): + # Gemini Files API URIs — the file is already uploaded to Google's + # servers; pass the URI through as file_data without fetching it. + # These URLs return 403 when accessed directly, so we must not try + # to resolve their MIME type via HTTP. + if format: + file_data = FileDataType(mime_type=format, file_uri=image_url) + else: + # Gemini Files API references can be passed through as URI-only. + file_data = cast(FileDataType, {"file_uri": image_url}) + part = {"file_data": file_data} + return _apply_gemini_metadata( + part, model, media_resolution_enum, video_metadata + ) elif ( "https://" in image_url and (image_type := format or _get_image_mime_type_from_url(image_url)) @@ -743,16 +759,22 @@ def _transform_request_body( # noqa: PLR0915 ] data = RequestBody(contents=content) - if system_instructions is not None: - data["system_instruction"] = system_instructions - if tools is not None: - data["tools"] = tools - if tool_choice is not None: - data["toolConfig"] = tool_choice - if include_server_side_tool_invocations: - if "toolConfig" not in data: - data["toolConfig"] = {} - data["toolConfig"]["includeServerSideToolInvocations"] = True + # Vertex rejects system_instruction/tools/toolConfig alongside cachedContent. + # Treat dropping these fields as a request mutation guarded by modify_params. + can_send_cache_incompatible_fields = ( + cached_content is None or litellm.modify_params is False + ) + if can_send_cache_incompatible_fields: + if system_instructions is not None: + data["system_instruction"] = system_instructions + if tools is not None: + data["tools"] = tools + if tool_choice is not None: + data["toolConfig"] = tool_choice + if include_server_side_tool_invocations: + if "toolConfig" not in data: + data["toolConfig"] = {} + data["toolConfig"]["includeServerSideToolInvocations"] = True if safety_settings is not None: data["safetySettings"] = safety_settings if generation_config is not None and len(generation_config) > 0: diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index 474ddb402a..6278de662f 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -979,15 +979,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): params["includeThoughts"] = False else: params["includeThoughts"] = True - if thinking_budget >= 10000: - is_gemini3flash = ( - "gemini-3-flash-preview" in model.lower() - or "gemini-3-flash" in model.lower() - ) - params["thinkingLevel"] = ( - "minimal" if is_gemini3flash else "low" - ) - else: + # Follow provider defaults unless explicitly opted into legacy behavior. + if litellm.enable_gemini_default_thinking_level_low is True: is_gemini3flash = ( "gemini-3-flash-preview" in model.lower() or "gemini-3-flash" in model.lower() diff --git a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_handler.py b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_handler.py index 2371bc4865..99165c37c9 100644 --- a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_handler.py +++ b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_handler.py @@ -3,7 +3,7 @@ Google AI Studio /batchEmbedContents Embeddings Endpoint """ import json -from typing import Any, Dict, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Tuple, Union import httpx @@ -13,8 +13,8 @@ from litellm.llms.custom_httpx.http_handler import ( HTTPHandler, get_async_httpx_client, ) -from litellm.types.llms.openai import EmbeddingInput from litellm.types.llms.vertex_ai import ( + GeminiEmbeddingInput, VertexAIBatchEmbeddingsRequestBody, VertexAIBatchEmbeddingsResponseObject, ) @@ -23,7 +23,6 @@ from litellm.types.utils import EmbeddingResponse from ..gemini.vertex_and_google_ai_studio_gemini import VertexLLM from .batch_embed_content_transformation import ( _is_file_reference, - _is_multimodal_input, process_embed_content_response, process_response, transform_openai_input_gemini_content, @@ -32,9 +31,24 @@ from .batch_embed_content_transformation import ( class GoogleBatchEmbeddings(VertexLLM): + @staticmethod + def _flatten_and_detect_file_refs( + input: GeminiEmbeddingInput, + ) -> Tuple[List[str], bool]: + """Flatten nested input lists and detect file references.""" + input_list = [input] if isinstance(input, str) else input + flat_elements = [ + e + for item in input_list + for e in (item if isinstance(item, list) else [item]) + if isinstance(e, str) + ] + has_file_refs = any(_is_file_reference(e) for e in flat_elements) + return flat_elements, has_file_refs + def _resolve_file_references( self, - input: EmbeddingInput, + input: GeminiEmbeddingInput, api_key: str, sync_handler: HTTPHandler, ) -> Dict[str, Dict[str, str]]: @@ -42,7 +56,7 @@ class GoogleBatchEmbeddings(VertexLLM): Resolve Gemini file references (files/...) to get mime_type and uri. Args: - input: EmbeddingInput that may contain file references + input: GeminiEmbeddingInput that may contain file references api_key: Gemini API key sync_handler: HTTP client @@ -73,7 +87,7 @@ class GoogleBatchEmbeddings(VertexLLM): async def _async_resolve_file_references( self, - input: EmbeddingInput, + input: GeminiEmbeddingInput, api_key: str, async_handler: AsyncHTTPHandler, ) -> Dict[str, Dict[str, str]]: @@ -81,7 +95,7 @@ class GoogleBatchEmbeddings(VertexLLM): Async version of _resolve_file_references. Args: - input: EmbeddingInput that may contain file references + input: GeminiEmbeddingInput that may contain file references api_key: Gemini API key async_handler: Async HTTP client @@ -110,10 +124,10 @@ class GoogleBatchEmbeddings(VertexLLM): return resolved_files - def batch_embeddings( + def batch_embeddings( # noqa: PLR0915 self, model: str, - input: EmbeddingInput, + input: GeminiEmbeddingInput, print_verbose, model_response: EmbeddingResponse, custom_llm_provider: Literal["gemini", "vertex_ai"], @@ -151,8 +165,7 @@ class GoogleBatchEmbeddings(VertexLLM): optional_params = optional_params or {} - is_multimodal = _is_multimodal_input(input) - use_embed_content = is_multimodal or (custom_llm_provider == "vertex_ai") + use_embed_content = custom_llm_provider == "vertex_ai" mode: Literal["embedding", "batch_embedding"] if use_embed_content: mode = "embedding" @@ -215,8 +228,22 @@ class GoogleBatchEmbeddings(VertexLLM): resolved_files=resolved_files, ) else: + flat_elements, has_file_refs = self._flatten_and_detect_file_refs(input) + if has_file_refs and not api_key: + raise ValueError( + "An API key is required to resolve Gemini file references (files/...). " + "Pass api_key= or set GEMINI_API_KEY." + ) + resolved_files = {} + if api_key and has_file_refs: + resolved_files = self._resolve_file_references( + input=flat_elements, api_key=api_key, sync_handler=sync_handler + ) request_data = transform_openai_input_gemini_content( - input=input, model=model, optional_params=optional_params + input=input, + model=model, + optional_params=optional_params, + resolved_files=resolved_files, ) ## LOGGING @@ -264,7 +291,7 @@ class GoogleBatchEmbeddings(VertexLLM): url: str, data: Optional[Union[VertexAIBatchEmbeddingsRequestBody, dict]], model_response: EmbeddingResponse, - input: EmbeddingInput, + input: GeminiEmbeddingInput, timeout: Optional[Union[float, httpx.Timeout]], headers={}, client: Optional[AsyncHTTPHandler] = None, @@ -303,8 +330,22 @@ class GoogleBatchEmbeddings(VertexLLM): resolved_files=resolved_files, ) else: + flat_elements, has_file_refs = self._flatten_and_detect_file_refs(input) + if has_file_refs and not api_key: + raise ValueError( + "An API key is required to resolve Gemini file references (files/...). " + "Pass api_key= or set GEMINI_API_KEY." + ) + resolved_files = {} + if api_key and has_file_refs: + resolved_files = await self._async_resolve_file_references( + input=flat_elements, api_key=api_key, async_handler=async_handler + ) data = transform_openai_input_gemini_content( - input=input, model=model, optional_params=optional_params or {} + input=input, + model=model, + optional_params=optional_params or {}, + resolved_files=resolved_files, ) ## LOGGING diff --git a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py index 34fc95e0af..e1b365c9f4 100644 --- a/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py +++ b/litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py @@ -6,12 +6,12 @@ Why separate file? Make it easy to see how transformation works from typing import Dict, List, Optional, Tuple -from litellm.types.llms.openai import EmbeddingInput from litellm.types.llms.vertex_ai import ( BlobType, ContentType, EmbedContentRequest, FileDataType, + GeminiEmbeddingInput, PartType, VertexAIBatchEmbeddingsRequestBody, VertexAIBatchEmbeddingsResponseObject, @@ -114,33 +114,77 @@ def _parse_data_url(data_url: str) -> Tuple[str, str]: return media_type, base64_data -def _is_multimodal_input(input: EmbeddingInput) -> bool: +def _is_multimodal_input(input: GeminiEmbeddingInput) -> bool: """ - Check if the input contains multimodal data (data URIs, file references, or GCS URLs). + Check if the input contains multimodal data (data URIs, file references, + GCS URLs, or nested lists for combined embeddings). Args: - input: EmbeddingInput (str or List[str]) + input: GeminiEmbeddingInput — str, List[str], or List[List[str]] for combined embeddings Returns: - bool: True if any element is a data URI, file reference, or GCS URL + bool: True if any element is multimodal or a nested list """ if isinstance(input, str): - input_list = [input] - else: - input_list = input + return _is_multimodal_element(input) - for element in input_list: - if isinstance(element, str): - if element.startswith("data:") and ";base64," in element: - return True - if _is_file_reference(element): - return True - if _is_gcs_url(element): + for element in input: + if isinstance(element, list): + if any( + _is_multimodal_element(sub) for sub in element if isinstance(sub, str) + ): return True + elif isinstance(element, str) and _is_multimodal_element(element): + return True return False +def _is_multimodal_element(element: str) -> bool: + """Check if a single string element is multimodal.""" + if element.startswith("data:") and ";base64," in element: + return True + if _is_file_reference(element): + return True + if _is_gcs_url(element): + return True + return False + + +def _build_part_for_input( + element: str, + resolved_files: Optional[Dict[str, Dict[str, str]]] = None, +) -> PartType: + """ + Build a single PartType for an input element, handling text, data URIs, + file references, and GCS URLs. + """ + resolved_files = resolved_files or {} + + if element.startswith("data:") and ";base64," in element: + mime_type, base64_data = _parse_data_url(element) + blob: BlobType = {"mime_type": mime_type, "data": base64_data} + return PartType(inline_data=blob) + elif _is_gcs_url(element): + mime_type = _infer_mime_type_from_gcs_url(element) + file_data: FileDataType = { + "mime_type": mime_type, + "file_uri": element, + } + return PartType(file_data=file_data) + elif _is_file_reference(element): + if element not in resolved_files: + raise ValueError(f"File reference {element} not resolved") + file_info = resolved_files[element] + file_data_ref: FileDataType = { + "mime_type": file_info["mime_type"], + "file_uri": file_info["uri"], + } + return PartType(file_data=file_data_ref) + else: + return PartType(text=element) + + _SUPPORTED_EMBED_PARAMS = {"outputDimensionality", "taskType", "title"} @@ -155,37 +199,60 @@ def _filter_embed_params(optional_params: dict) -> dict: def transform_openai_input_gemini_content( - input: EmbeddingInput, model: str, optional_params: dict + input: GeminiEmbeddingInput, + model: str, + optional_params: dict, + resolved_files: Optional[Dict[str, Dict[str, str]]] = None, ) -> VertexAIBatchEmbeddingsRequestBody: """ - The content to embed. Only the parts.text fields will be counted. + Transform OpenAI embedding input to Gemini batchEmbedContents format. + + Each input element becomes a separate EmbedContentRequest, supporting + text, data URIs, file references, and GCS URLs. + + If an element is a list (nested input), all sub-elements are combined + into a single content with multiple parts, producing one combined + embedding for the group. + + Examples: + input=["text", "image"] → 2 separate embeddings + input=[["text", "image"]] → 1 combined embedding + input=[["text", "image"], "x"] → 2 embeddings (1 combined + 1 separate) """ gemini_model_name = "models/{}".format(model) gemini_params = _filter_embed_params(optional_params) + input_list = [input] if isinstance(input, str) else input requests: List[EmbedContentRequest] = [] - if isinstance(input, str): + + for element in input_list: + if isinstance(element, list): + if not element: + raise ValueError("Nested input list must not be empty") + for sub in element: + if not isinstance(sub, str): + raise ValueError( + f"Elements inside a nested input list must be strings, got {type(sub)}" + ) + parts = [ + _build_part_for_input(sub, resolved_files=resolved_files) + for sub in element + ] + else: + parts = [_build_part_for_input(element, resolved_files=resolved_files)] request = EmbedContentRequest( model=gemini_model_name, - content=ContentType(parts=[PartType(text=input)]), + content=ContentType(parts=parts), **gemini_params, ) requests.append(request) - else: - for i in input: - request = EmbedContentRequest( - model=gemini_model_name, - content=ContentType(parts=[PartType(text=i)]), - **gemini_params, - ) - requests.append(request) return VertexAIBatchEmbeddingsRequestBody(requests=requests) def transform_openai_input_gemini_embed_content( - input: EmbeddingInput, + input: GeminiEmbeddingInput, model: str, optional_params: dict, resolved_files: Optional[Dict[str, Dict[str, str]]] = None, @@ -194,7 +261,7 @@ def transform_openai_input_gemini_embed_content( Transform OpenAI embedding input to Gemini embedContent format (multimodal). Args: - input: EmbeddingInput (str or List[str]) with text, data URIs, or file references + input: GeminiEmbeddingInput with text, data URIs, or file references model: Model name optional_params: Additional parameters (taskType, outputDimensionality, etc.) resolved_files: Dict mapping file names (files/abc) to {mime_type, uri} @@ -210,31 +277,14 @@ def transform_openai_input_gemini_embed_content( parts: List[PartType] = [] for element in input_list: + if isinstance(element, list): + raise ValueError( + "Nested (combined) embeddings are not supported on the embedContent path. " + "Use the batchEmbedContents path or pass a flat list instead." + ) if not isinstance(element, str): raise ValueError(f"Unsupported input type: {type(element)}") - - if element.startswith("data:") and ";base64," in element: - mime_type, base64_data = _parse_data_url(element) - blob: BlobType = {"mime_type": mime_type, "data": base64_data} - parts.append(PartType(inline_data=blob)) - elif _is_gcs_url(element): - mime_type = _infer_mime_type_from_gcs_url(element) - file_data: FileDataType = { - "mime_type": mime_type, - "file_uri": element, - } - parts.append(PartType(file_data=file_data)) - elif _is_file_reference(element): - if element not in resolved_files: - raise ValueError(f"File reference {element} not resolved") - file_info = resolved_files[element] - file_data_ref: FileDataType = { - "mime_type": file_info["mime_type"], - "file_uri": file_info["uri"], - } - parts.append(PartType(file_data=file_data_ref)) - else: - parts.append(PartType(text=element)) + parts.append(_build_part_for_input(element, resolved_files=resolved_files)) request_body: dict = { "content": ContentType(parts=parts), @@ -245,7 +295,7 @@ def transform_openai_input_gemini_embed_content( def process_embed_content_response( - input: EmbeddingInput, + input: GeminiEmbeddingInput, model_response: EmbeddingResponse, model: str, response_json: dict, @@ -291,7 +341,7 @@ def process_embed_content_response( def process_response( - input: EmbeddingInput, + input: GeminiEmbeddingInput, model_response: EmbeddingResponse, model: str, _predictions: VertexAIBatchEmbeddingsResponseObject, @@ -308,8 +358,29 @@ def process_response( model_response.data = openai_embeddings model_response.model = model - input_text = get_formatted_prompt(data={"input": input}, call_type="embedding") - prompt_tokens = token_counter(model=model, text=input_text) + has_nested = isinstance(input, list) and any(isinstance(e, list) for e in input) + if _is_multimodal_input(input) or has_nested: + input_list = input if isinstance(input, list) else [input] + text_elements: List[str] = [] + for e in input_list: + if isinstance(e, list): + text_elements.extend( + sub + for sub in e + if isinstance(sub, str) and not _is_multimodal_element(sub) + ) + elif isinstance(e, str) and not _is_multimodal_element(e): + text_elements.append(e) + if text_elements: + input_text = get_formatted_prompt( + data={"input": text_elements}, call_type="embedding" + ) + prompt_tokens = token_counter(model=model, text=input_text) + else: + prompt_tokens = 0 + else: + input_text = get_formatted_prompt(data={"input": input}, call_type="embedding") + prompt_tokens = token_counter(model=model, text=input_text) model_response.usage = Usage( prompt_tokens=prompt_tokens, total_tokens=prompt_tokens ) diff --git a/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py b/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py index 6cb7a86bea..61fb848b40 100644 --- a/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py +++ b/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import httpx from litellm import get_model_info +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.llms.base_llm.vector_store.transformation import BaseVectorStoreConfig from litellm.llms.vertex_ai.vertex_llm_base import VertexBase from litellm.types.router import GenericLiteLLMParams @@ -91,12 +92,18 @@ class VertexSearchAPIVectorStoreConfig(BaseVectorStoreConfig, VertexBase): raise ValueError("vector_store_id is required") if api_base: return api_base.rstrip("/") + encoded_collection_id = encode_url_path_segment( + collection_id, field_name="vertex_collection_id" + ) + encoded_datastore_id = encode_url_path_segment( + datastore_id, field_name="vector_store_id" + ) # Vertex AI Search API endpoint for search return ( f"https://discoveryengine.googleapis.com/v1/" f"projects/{vertex_project}/locations/{vertex_location}/" - f"collections/{collection_id}/dataStores/{datastore_id}/servingConfigs/default_config" + f"collections/{encoded_collection_id}/dataStores/{encoded_datastore_id}/servingConfigs/default_config" ) def transform_search_vector_store_request( diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py index 5c3bbf61ee..4be4c2d5e7 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py @@ -13,6 +13,7 @@ from litellm.types.llms.vertex_ai import VertexPartnerProvider from litellm.types.router import GenericLiteLLMParams from ....vertex_llm_base import VertexBase +from ..output_params_utils import sanitize_vertex_anthropic_output_params class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, VertexBase): @@ -158,12 +159,6 @@ class VertexAIPartnerModelsAnthropicMessagesConfig(AnthropicMessagesConfig, Vert "model", None ) # do not pass model in request body to vertex ai - anthropic_messages_request.pop( - "output_format", None - ) # do not pass output_format in request body to vertex ai - vertex ai does not support output_format as yet - - anthropic_messages_request.pop( - "output_config", None - ) # do not pass output_config in request body to vertex ai - vertex ai does not support output_config + sanitize_vertex_anthropic_output_params(anthropic_messages_request) return anthropic_messages_request diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/output_params_utils.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/output_params_utils.py new file mode 100644 index 0000000000..a33ad67778 --- /dev/null +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/output_params_utils.py @@ -0,0 +1,48 @@ +""" +Shared sanitization for ``output_config`` / ``output_format`` on Vertex AI +Claude. Lives in its own module so both the chat-completion transformation +(``transformation.py``) and the Messages pass-through transformation +(``experimental_pass_through/transformation.py``) can import it without +forming a cycle through the parent module's heavier imports. + +CodeQL flagged the ``..transformation`` import path as a potential cyclic +import; extracting the helper into a leaf module resolves the warning and +keeps the parent module's import surface narrow. +""" + +# Keys inside ``output_config`` that Vertex AI Claude does not accept. +# Add an entry only when a 400 "Extra inputs are not permitted" is +# reproducible against the live Vertex endpoint. +VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS: frozenset = frozenset() + + +def sanitize_vertex_anthropic_output_params(data: dict) -> None: + """ + Strip Vertex-unsupported keys from ``output_config`` / + ``output_format`` in-place; forward whatever remains. + + Behavior: + * ``output_config`` containing only unsupported keys (e.g. ``effort`` + alone) is removed entirely so the request body has no empty dict. + * ``output_config`` containing a mix of supported + unsupported keys + has the unsupported subset filtered out and the rest forwarded. + * ``output_config`` that is supported in full passes through unchanged. + * ``output_format`` is forwarded as-is (Vertex AI Claude accepts it). + * Non-dict values for ``output_config`` are dropped to avoid sending + malformed payloads downstream. + """ + output_config = data.get("output_config") + if output_config is None: + return + if not isinstance(output_config, dict): + data.pop("output_config", None) + return + sanitized = { + k: v + for k, v in output_config.items() + if k not in VERTEX_UNSUPPORTED_OUTPUT_CONFIG_KEYS + } + if sanitized: + data["output_config"] = sanitized + else: + data.pop("output_config", None) diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py index 504914c479..4627d9f6df 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py @@ -10,6 +10,7 @@ from litellm.types.llms.openai import AllMessageValues from litellm.types.utils import ModelResponse from ....anthropic.chat.transformation import AnthropicConfig +from .output_params_utils import sanitize_vertex_anthropic_output_params class VertexAIError(Exception): @@ -105,11 +106,7 @@ class VertexAIAnthropicConfig(AnthropicConfig): data.pop("model", None) # vertex anthropic doesn't accept 'model' parameter - # VertexAI doesn't support output_format parameter, remove it if present - data.pop("output_format", None) - - # VertexAI doesn't support output_config parameter, remove it if present - data.pop("output_config", None) + sanitize_vertex_anthropic_output_params(data) tools = optional_params.get("tools") tool_search_used = self.is_tool_search_used(tools) diff --git a/litellm/llms/vertex_ai/vertex_model_garden/main.py b/litellm/llms/vertex_ai/vertex_model_garden/main.py index c37bb449ec..7240d9dce5 100644 --- a/litellm/llms/vertex_ai/vertex_model_garden/main.py +++ b/litellm/llms/vertex_ai/vertex_model_garden/main.py @@ -27,6 +27,17 @@ from ..common_utils import VertexAIError, get_vertex_base_model_name from ..vertex_llm_base import VertexBase +def _vertex_model_garden_model_id_in_json_body(model: str) -> bool: + """ + Vertex catalog / publisher models are addressed as publisher/model (e.g. + xai/grok-4.1-fast-reasoning) on the shared OpenAPI URL, with the id in the JSON body. + + Deployed Model Garden endpoints are typically a single segment (often numeric) + and use .../endpoints/{ENDPOINT_ID}/chat/completions with an empty model field. + """ + return "/" in model + + def create_vertex_url( vertex_location: str, vertex_project: str, @@ -34,8 +45,13 @@ def create_vertex_url( model: str, api_base: Optional[str] = None, ) -> str: - """Return the base url for the vertex garden models""" + """Return the api base for vertex model garden (without /chat/completions).""" base_url = get_vertex_base_url(vertex_location) + if _vertex_model_garden_model_id_in_json_body(model): + return ( + f"{base_url}/v1/projects/{vertex_project}/locations/{vertex_location}" + "/endpoints/openapi" + ) return f"{base_url}/v1beta1/projects/{vertex_project}/locations/{vertex_location}/endpoints/{model}" @@ -129,7 +145,10 @@ class VertexAIModelGardenModels(VertexBase): vertex_location=vertex_location or "us-central1", vertex_api_version="v1beta1", ) - model = "" + # Publisher/catalog models: model id must be sent in the JSON body (OpenAPI route). + # Single-segment endpoint ids: model is encoded in the URL path; body model stays empty. + if not _vertex_model_garden_model_id_in_json_body(model): + model = "" return openai_like_chat_completions.completion( model=model, messages=messages, diff --git a/litellm/llms/volcengine/responses/transformation.py b/litellm/llms/volcengine/responses/transformation.py index f6dda4dd25..99e0a958ef 100644 --- a/litellm/llms/volcengine/responses/transformation.py +++ b/litellm/llms/volcengine/responses/transformation.py @@ -17,6 +17,7 @@ from pydantic import fields as pyd_fields import litellm from litellm._logging import verbose_logger from litellm.litellm_core_utils.core_helpers import process_response_headers +from litellm.litellm_core_utils.url_utils import encode_url_path_segment from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import ( _safe_convert_created_field, ) @@ -300,7 +301,10 @@ class VolcEngineResponsesAPIConfig(OpenAIResponsesAPIConfig): litellm_params: GenericLiteLLMParams, headers: dict, ) -> Tuple[str, Dict]: - url = f"{api_base}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}" data: Dict = {} return url, data @@ -333,7 +337,10 @@ class VolcEngineResponsesAPIConfig(OpenAIResponsesAPIConfig): litellm_params: GenericLiteLLMParams, headers: dict, ) -> Tuple[str, Dict]: - url = f"{api_base}/{response_id}" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}" data: Dict = {} return url, data @@ -372,7 +379,10 @@ class VolcEngineResponsesAPIConfig(OpenAIResponsesAPIConfig): limit: int = 20, order: Literal["asc", "desc"] = "desc", ) -> Tuple[str, Dict]: - url = f"{api_base}/{response_id}/input_items" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}/input_items" params: Dict[str, Any] = {} if after is not None: params["after"] = after @@ -408,7 +418,10 @@ class VolcEngineResponsesAPIConfig(OpenAIResponsesAPIConfig): litellm_params: GenericLiteLLMParams, headers: dict, ) -> Tuple[str, Dict]: - url = f"{api_base}/{response_id}/cancel" + encoded_response_id = encode_url_path_segment( + response_id, field_name="response_id" + ) + url = f"{api_base}/{encoded_response_id}/cancel" data: Dict = {} return url, data diff --git a/litellm/llms/xai/chat/transformation.py b/litellm/llms/xai/chat/transformation.py index bfa55105a6..6300868a64 100644 --- a/litellm/llms/xai/chat/transformation.py +++ b/litellm/llms/xai/chat/transformation.py @@ -43,6 +43,7 @@ class XAIChatConfig(OpenAIGPTConfig): "logprobs", "max_tokens", "n", + "parallel_tool_calls", "presence_penalty", "response_format", "seed", @@ -222,8 +223,43 @@ class XAIChatConfig(OpenAIGPTConfig): self._enhance_usage_with_xai_web_search_fields(response, raw_response_json) except Exception as e: verbose_logger.debug(f"Error extracting X.AI web search usage: {e}") + + self._fold_reasoning_tokens_into_completion(response) return response + @staticmethod + def _fold_reasoning_tokens_into_completion(model_response: ModelResponse) -> None: + """Reconcile xAI Usage to the OpenAI invariant. + + xAI accounts ``reasoning_tokens`` separately from + ``completion_tokens`` while still summing them into ``total_tokens``. + OpenAI's contract (o1/o3) folds reasoning into ``completion_tokens``, + so fold here to keep ``total = prompt + completion``. Idempotent. + """ + usage = getattr(model_response, "usage", None) + if usage is None: + return + + details = getattr(usage, "completion_tokens_details", None) + reasoning_tokens = ( + int(getattr(details, "reasoning_tokens", 0) or 0) if details else 0 + ) + if reasoning_tokens <= 0: + return + + prompt_tokens = int(getattr(usage, "prompt_tokens", 0) or 0) + completion_tokens = int(getattr(usage, "completion_tokens", 0) or 0) + total_tokens = int(getattr(usage, "total_tokens", 0) or 0) + + if total_tokens == prompt_tokens + completion_tokens: + return + + # Guard against double-counting if xAI changes accounting. + if total_tokens != prompt_tokens + completion_tokens + reasoning_tokens: + return + + usage.completion_tokens = completion_tokens + reasoning_tokens + def _enhance_usage_with_xai_web_search_fields( self, model_response: ModelResponse, raw_response_json: dict ) -> None: diff --git a/litellm/llms/xai/cost_calculator.py b/litellm/llms/xai/cost_calculator.py index 0cfcfe9841..8edfd0c27a 100644 --- a/litellm/llms/xai/cost_calculator.py +++ b/litellm/llms/xai/cost_calculator.py @@ -25,16 +25,25 @@ def cost_per_token(model: str, usage: Usage) -> Tuple[float, float]: Returns: Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd """ - # XAI-specific completion cost calculation - # For XAI models, completion is billed as (visible completion tokens + reasoning tokens) + # XAI-specific completion cost: completion is billed as visible + reasoning + # tokens. Detect when the transformation layer already folded them so we + # don't double-count; fall back to raw xAI shape for callers that bypass + # the transformation (e.g. proxy logs replayed into cost calc). + prompt_tokens = int(getattr(usage, "prompt_tokens", 0) or 0) completion_tokens = int(getattr(usage, "completion_tokens", 0) or 0) + total_tokens = int(getattr(usage, "total_tokens", 0) or 0) reasoning_tokens = 0 if hasattr(usage, "completion_tokens_details") and usage.completion_tokens_details: reasoning_tokens = int( getattr(usage.completion_tokens_details, "reasoning_tokens", 0) or 0 ) - total_completion_tokens = completion_tokens + reasoning_tokens + already_normalised = total_tokens == prompt_tokens + completion_tokens + total_completion_tokens = ( + completion_tokens + if already_normalised + else completion_tokens + reasoning_tokens + ) modified_usage = Usage( prompt_tokens=usage.prompt_tokens, diff --git a/litellm/main.py b/litellm/main.py index 0079bd750c..0553cf9d42 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -4923,8 +4923,17 @@ def embedding( # noqa: PLR0915 if encoding_format is not None: optional_params["encoding_format"] = encoding_format else: - # Omiting causes openai sdk to add default value of "float" - optional_params["encoding_format"] = None + env_fmt = get_secret_str("LITELLM_DEFAULT_EMBEDDING_ENCODING_FORMAT") + if env_fmt is not None and env_fmt.strip().lower() == "none": + optional_params.pop("encoding_format", None) + else: + _default_fmt = ( + optional_params.get("encoding_format") or env_fmt or "float" + ) + if _default_fmt.strip().lower() == "none": + optional_params.pop("encoding_format", None) + else: + optional_params["encoding_format"] = _default_fmt api_version = None diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 13a45fd165..7946e2dcee 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -977,6 +977,7 @@ "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true, @@ -1162,6 +1163,21 @@ "supports_max_reasoning_effort": true, "supports_minimal_reasoning_effort": true }, + "anthropic.claude-mythos-preview": { + "input_cost_per_token": 0, + "output_cost_per_token": 0, + "litellm_provider": "bedrock", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "supports_function_calling": true, + "supports_vision": true, + "supports_prompt_caching": false, + "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, + "supports_tool_choice": true + }, "global.anthropic.claude-opus-4-7": { "cache_creation_input_token_cost": 6.25e-06, "cache_creation_input_token_cost_above_1hr": 1e-05, @@ -1307,6 +1323,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -1336,6 +1353,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -1365,6 +1383,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -1393,6 +1412,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -1421,6 +1441,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -1915,6 +1936,7 @@ "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true @@ -2038,6 +2060,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -9212,6 +9235,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -9347,6 +9371,7 @@ "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true, @@ -9374,6 +9399,7 @@ "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true, @@ -9477,7 +9503,6 @@ "us": 1.1, "fast": 6.0 }, - "supports_max_reasoning_effort": true, "supports_minimal_reasoning_effort": true }, "claude-opus-4-7-20260416": { @@ -9512,7 +9537,6 @@ "us": 1.1, "fast": 6.0 }, - "supports_max_reasoning_effort": true, "supports_minimal_reasoning_effort": true }, "claude-sonnet-4-20250514": { @@ -10790,6 +10814,7 @@ "supports_assistant_prefill": true, "supports_function_calling": true, "supports_reasoning": true, + "supports_minimal_reasoning_effort": true, "supports_tool_choice": true }, "databricks/databricks-claude-sonnet-4": { @@ -15548,7 +15573,7 @@ "mode": "embedding", "output_cost_per_token": 0, "output_vector_size": 3072, - "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing", + "source": "https://ai.google.dev/gemini-api/docs/embeddings#multimodal", "supports_multimodal": true, "uses_embed_content": true }, @@ -17150,7 +17175,8 @@ ], "supports_function_calling": true, "supports_parallel_function_calling": true, - "supports_vision": true + "supports_vision": true, + "supports_minimal_reasoning_effort": true }, "github_copilot/claude-opus-4.6-fast": { "litellm_provider": "github_copilot", @@ -17663,7 +17689,8 @@ "mode": "chat", "output_cost_per_token": 2.5e-05, "supports_function_calling": true, - "supports_vision": true + "supports_vision": true, + "supports_minimal_reasoning_effort": true }, "gmi/anthropic/claude-sonnet-4.5": { "input_cost_per_token": 3e-06, @@ -19928,7 +19955,7 @@ "supports_web_search": true, "supports_none_reasoning_effort": true, "supports_xhigh_reasoning_effort": true, - "supports_minimal_reasoning_effort": true + "supports_minimal_reasoning_effort": false }, "gpt-5.5-2026-04-23": { "cache_read_input_token_cost": 5e-07, @@ -19976,7 +20003,7 @@ "supports_web_search": true, "supports_none_reasoning_effort": true, "supports_xhigh_reasoning_effort": true, - "supports_minimal_reasoning_effort": true + "supports_minimal_reasoning_effort": false }, "gpt-5.5-pro": { "cache_read_input_token_cost": 3e-06, @@ -20019,7 +20046,8 @@ "supports_web_search": true, "supports_none_reasoning_effort": false, "supports_xhigh_reasoning_effort": true, - "supports_minimal_reasoning_effort": true + "supports_minimal_reasoning_effort": false, + "supports_low_reasoning_effort": false }, "gpt-5.5-pro-2026-04-23": { "cache_read_input_token_cost": 3e-06, @@ -20062,7 +20090,8 @@ "supports_web_search": true, "supports_none_reasoning_effort": false, "supports_xhigh_reasoning_effort": true, - "supports_minimal_reasoning_effort": true + "supports_minimal_reasoning_effort": false, + "supports_low_reasoning_effort": false }, "gpt-5.4": { "cache_read_input_token_cost": 2.5e-07, @@ -21140,7 +21169,7 @@ }, "gradient_ai/alibaba-qwen3-32b": { "litellm_provider": "gradient_ai", - "max_tokens": 2048, + "max_tokens": 40960, "mode": "chat", "supported_endpoints": [ "/v1/chat/completions" @@ -21148,7 +21177,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 131072, + "max_output_tokens": 40960 }, "gradient_ai/anthropic-claude-3-opus": { "input_cost_per_token": 1.5e-05, @@ -21162,7 +21193,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 1024 }, "gradient_ai/anthropic-claude-3.5-haiku": { "input_cost_per_token": 8e-07, @@ -21176,7 +21209,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 1024 }, "gradient_ai/anthropic-claude-3.5-sonnet": { "input_cost_per_token": 3e-06, @@ -21190,7 +21225,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 1024 }, "gradient_ai/anthropic-claude-3.7-sonnet": { "input_cost_per_token": 3e-06, @@ -21204,7 +21241,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 1024 }, "gradient_ai/deepseek-r1-distill-llama-70b": { "input_cost_per_token": 9.9e-07, @@ -21218,7 +21257,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 32768, + "max_output_tokens": 8000 }, "gradient_ai/llama3-8b-instruct": { "input_cost_per_token": 2e-07, @@ -21232,7 +21273,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 8192, + "max_output_tokens": 512 }, "gradient_ai/llama3.3-70b-instruct": { "input_cost_per_token": 6.5e-07, @@ -21246,7 +21289,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 128000, + "max_output_tokens": 2048 }, "gradient_ai/mistral-nemo-instruct-2407": { "input_cost_per_token": 3e-07, @@ -21260,7 +21305,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 128000, + "max_output_tokens": 512 }, "gradient_ai/openai-gpt-4o": { "litellm_provider": "gradient_ai", @@ -21272,7 +21319,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 128000, + "max_output_tokens": 16384 }, "gradient_ai/openai-gpt-4o-mini": { "litellm_provider": "gradient_ai", @@ -21284,7 +21333,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 128000, + "max_output_tokens": 16384 }, "gradient_ai/openai-o3": { "input_cost_per_token": 2e-06, @@ -21298,7 +21349,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 100000 }, "gradient_ai/openai-o3-mini": { "input_cost_per_token": 1.1e-06, @@ -21312,7 +21365,9 @@ "supported_modalities": [ "text" ], - "supports_tool_choice": false + "supports_tool_choice": false, + "max_input_tokens": 200000, + "max_output_tokens": 100000 }, "lemonade/Qwen3-Coder-30B-A3B-Instruct-GGUF": { "input_cost_per_token": 0, @@ -21612,11 +21667,13 @@ }, "heroku/claude-3-5-haiku": { "litellm_provider": "heroku", - "max_tokens": 4096, + "max_tokens": 8192, "mode": "chat", "supports_function_calling": true, "supports_system_messages": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 200000, + "max_output_tokens": 8192 }, "heroku/claude-3-5-sonnet-latest": { "litellm_provider": "heroku", @@ -21624,7 +21681,9 @@ "mode": "chat", "supports_function_calling": true, "supports_system_messages": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 200000, + "max_output_tokens": 8192 }, "heroku/claude-3-7-sonnet": { "litellm_provider": "heroku", @@ -21632,7 +21691,9 @@ "mode": "chat", "supports_function_calling": true, "supports_system_messages": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 200000, + "max_output_tokens": 8192 }, "heroku/claude-4-sonnet": { "litellm_provider": "heroku", @@ -21640,7 +21701,9 @@ "mode": "chat", "supports_function_calling": true, "supports_system_messages": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 200000, + "max_output_tokens": 8192 }, "high/1024-x-1024/gpt-image-1": { "input_cost_per_image": 0.167, @@ -22061,6 +22124,98 @@ "tool_use_system_prompt_tokens": 346, "supports_native_structured_output": true }, + "crusoe/deepseek-ai/DeepSeek-R1-0528": { + "input_cost_per_token": 3e-06, + "litellm_provider": "crusoe", + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "max_tokens": 163840, + "mode": "chat", + "output_cost_per_token": 7e-06, + "supports_function_calling": false, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": false + }, + "crusoe/deepseek-ai/DeepSeek-V3-0324": { + "input_cost_per_token": 1.5e-06, + "litellm_provider": "crusoe", + "max_input_tokens": 163840, + "max_output_tokens": 163840, + "max_tokens": 163840, + "mode": "chat", + "output_cost_per_token": 1.5e-06, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true + }, + "crusoe/google/gemma-3-12b-it": { + "input_cost_per_token": 1e-07, + "litellm_provider": "crusoe", + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 1e-07, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "crusoe/meta-llama/Llama-3.3-70B-Instruct": { + "input_cost_per_token": 2e-07, + "litellm_provider": "crusoe", + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 2e-07, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true + }, + "crusoe/moonshotai/Kimi-K2-Thinking": { + "input_cost_per_token": 2.5e-06, + "litellm_provider": "crusoe", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "supports_function_calling": false, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": false + }, + "crusoe/openai/gpt-oss-120b": { + "input_cost_per_token": 8e-07, + "litellm_provider": "crusoe", + "max_input_tokens": 131072, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 8e-07, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true + }, + "crusoe/Qwen/Qwen3-235B-A22B-Instruct-2507": { + "input_cost_per_token": 3e-06, + "litellm_provider": "crusoe", + "max_input_tokens": 262144, + "max_output_tokens": 262144, + "max_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3e-06, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true + }, "lambda_ai/deepseek-llama3.3-70b": { "input_cost_per_token": 2e-07, "litellm_provider": "lambda_ai", @@ -22356,48 +22511,6 @@ "/v1/images/generations" ] }, - "luminous-base": { - "input_cost_per_token": 3e-05, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "completion", - "output_cost_per_token": 3.3e-05 - }, - "luminous-base-control": { - "input_cost_per_token": 3.75e-05, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "chat", - "output_cost_per_token": 4.125e-05 - }, - "luminous-extended": { - "input_cost_per_token": 4.5e-05, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "completion", - "output_cost_per_token": 4.95e-05 - }, - "luminous-extended-control": { - "input_cost_per_token": 5.625e-05, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "chat", - "output_cost_per_token": 6.1875e-05 - }, - "luminous-supreme": { - "input_cost_per_token": 0.000175, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "completion", - "output_cost_per_token": 0.0001925 - }, - "luminous-supreme-control": { - "input_cost_per_token": 0.00021875, - "litellm_provider": "aleph_alpha", - "max_tokens": 2048, - "mode": "chat", - "output_cost_per_token": 0.000240625 - }, "max-x-max/50-steps/stability.stable-diffusion-xl-v0": { "litellm_provider": "bedrock", "max_input_tokens": 77, @@ -25869,12 +25982,14 @@ "input_cost_per_image": 0.0004, "input_cost_per_token": 2.5e-07, "litellm_provider": "openrouter", - "max_tokens": 200000, + "max_tokens": 4096, "mode": "chat", "output_cost_per_token": 1.25e-06, "supports_function_calling": true, "supports_tool_choice": true, - "supports_vision": true + "supports_vision": true, + "max_input_tokens": 200000, + "max_output_tokens": 4096 }, "openrouter/anthropic/claude-3.5-sonnet": { "input_cost_per_token": 3e-06, @@ -25993,6 +26108,7 @@ "supports_function_calling": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 159, @@ -26011,6 +26127,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true, @@ -26032,6 +26149,7 @@ "supports_function_calling": true, "supports_prompt_caching": true, "supports_reasoning": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -26080,6 +26198,29 @@ "supports_vision": true, "tool_use_system_prompt_tokens": 346 }, + "openrouter/anthropic/claude-opus-4.7": { + "cache_creation_input_token_cost": 6.25e-06, + "cache_read_input_token_cost": 5e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "openrouter", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "supports_assistant_prefill": false, + "supports_computer_use": true, + "supports_function_calling": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_max_reasoning_effort": true, + "supports_tool_choice": true, + "supports_vision": true, + "supports_xhigh_reasoning_effort": true, + "tool_use_system_prompt_tokens": 346 + }, "openrouter/bytedance/ui-tars-1.5-7b": { "input_cost_per_token": 1e-07, "litellm_provider": "openrouter", @@ -26445,18 +26586,22 @@ "openrouter/mancer/weaver": { "input_cost_per_token": 5.625e-06, "litellm_provider": "openrouter", - "max_tokens": 8000, + "max_tokens": 2000, "mode": "chat", "output_cost_per_token": 5.625e-06, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 8000, + "max_output_tokens": 2000 }, "openrouter/meta-llama/llama-3-70b-instruct": { "input_cost_per_token": 5.9e-07, "litellm_provider": "openrouter", - "max_tokens": 8192, + "max_tokens": 8000, "mode": "chat", "output_cost_per_token": 7.9e-07, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 8192, + "max_output_tokens": 8000 }, "openrouter/minimax/minimax-m2": { "input_cost_per_token": 2.55e-07, @@ -26544,34 +26689,42 @@ "openrouter/mistralai/mistral-7b-instruct": { "input_cost_per_token": 1.3e-07, "litellm_provider": "openrouter", - "max_tokens": 8192, + "max_tokens": 8191, "mode": "chat", "output_cost_per_token": 1.3e-07, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 32768, + "max_output_tokens": 8191 }, "openrouter/mistralai/mistral-large": { "input_cost_per_token": 8e-06, "litellm_provider": "openrouter", - "max_tokens": 32000, + "max_tokens": 8191, "mode": "chat", "output_cost_per_token": 2.4e-05, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 128000, + "max_output_tokens": 8191 }, "openrouter/mistralai/mistral-small-3.1-24b-instruct": { "input_cost_per_token": 1e-07, "litellm_provider": "openrouter", - "max_tokens": 32000, + "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 3e-07, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 131072, + "max_output_tokens": 131072 }, "openrouter/mistralai/mistral-small-3.2-24b-instruct": { "input_cost_per_token": 1e-07, "litellm_provider": "openrouter", - "max_tokens": 32000, + "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 3e-07, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 128000, + "max_output_tokens": 128000 }, "openrouter/mistralai/mixtral-8x22b-instruct": { "input_cost_per_token": 6.5e-07, @@ -26579,7 +26732,9 @@ "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 6.5e-07, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 65536, + "max_output_tokens": 65536 }, "openrouter/moonshotai/kimi-k2.5": { "cache_read_input_token_cost": 1e-07, @@ -26599,26 +26754,32 @@ "openrouter/openai/gpt-3.5-turbo": { "input_cost_per_token": 1.5e-06, "litellm_provider": "openrouter", - "max_tokens": 4095, + "max_tokens": 4096, "mode": "chat", "output_cost_per_token": 2e-06, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 16385, + "max_output_tokens": 4096 }, "openrouter/openai/gpt-3.5-turbo-16k": { "input_cost_per_token": 3e-06, "litellm_provider": "openrouter", - "max_tokens": 16383, + "max_tokens": 4096, "mode": "chat", "output_cost_per_token": 4e-06, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 16385, + "max_output_tokens": 4096 }, "openrouter/openai/gpt-4": { "input_cost_per_token": 3e-05, "litellm_provider": "openrouter", - "max_tokens": 8192, + "max_tokens": 4096, "mode": "chat", "output_cost_per_token": 6e-05, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 8191, + "max_output_tokens": 4096 }, "openrouter/openai/gpt-4.1": { "cache_read_input_token_cost": 5e-07, @@ -27126,10 +27287,12 @@ "openrouter/undi95/remm-slerp-l2-13b": { "input_cost_per_token": 1.875e-06, "litellm_provider": "openrouter", - "max_tokens": 6144, + "max_tokens": 4096, "mode": "chat", "output_cost_per_token": 1.875e-06, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 6144, + "max_output_tokens": 4096 }, "openrouter/x-ai/grok-4": { "input_cost_per_token": 3e-06, @@ -27932,7 +28095,8 @@ "mode": "responses", "supports_web_search": true, "supports_reasoning": false, - "supports_function_calling": true + "supports_function_calling": true, + "supports_minimal_reasoning_effort": true }, "perplexity/anthropic/claude-sonnet-4-5": { "litellm_provider": "perplexity", @@ -29750,14 +29914,16 @@ "together_ai/deepseek-ai/DeepSeek-V3.1": { "input_cost_per_token": 6e-07, "litellm_provider": "together_ai", - "max_tokens": 128000, + "max_tokens": 16384, "mode": "chat", "output_cost_per_token": 1.7e-06, "source": "https://www.together.ai/models/deepseek-v3-1", "supports_function_calling": true, "supports_parallel_function_calling": true, "supports_reasoning": true, - "supports_tool_choice": true + "supports_tool_choice": true, + "max_input_tokens": 128000, + "max_output_tokens": 16384 }, "together_ai/meta-llama/Llama-3.2-3B-Instruct-Turbo": { "litellm_provider": "together_ai", @@ -30409,6 +30575,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -30437,6 +30604,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -30464,6 +30632,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -31044,6 +31213,7 @@ "output_cost_per_token": 2.5e-05, "supports_assistant_prefill": true, "supports_computer_use": true, + "supports_minimal_reasoning_effort": true, "supports_function_calling": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -32236,6 +32406,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -32262,6 +32433,7 @@ "supports_assistant_prefill": true, "supports_computer_use": true, "supports_function_calling": true, + "supports_minimal_reasoning_effort": true, "supports_pdf_input": true, "supports_prompt_caching": true, "supports_reasoning": true, @@ -32428,6 +32600,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -33337,6 +33510,72 @@ "source": "https://console.cloud.google.com/vertex-ai/publishers/openai/model-garden/gpt-oss-120b-maas", "supports_reasoning": true }, + "vertex_ai/xai/grok-4.1-fast-non-reasoning": { + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 2e-07, + "litellm_provider": "vertex_ai", + "max_input_tokens": 2000000, + "max_output_tokens": 2000000, + "max_tokens": 2000000, + "mode": "chat", + "output_cost_per_token": 5e-07, + "source": "https://docs.x.ai/docs/models (Vertex AI Model Garden)", + "supports_function_calling": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "supports_web_search": true + }, + "vertex_ai/xai/grok-4.1-fast-reasoning": { + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 2e-07, + "litellm_provider": "vertex_ai", + "max_input_tokens": 2000000, + "max_output_tokens": 2000000, + "max_tokens": 2000000, + "mode": "chat", + "output_cost_per_token": 5e-07, + "source": "https://docs.x.ai/docs/models (Vertex AI Model Garden)", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "supports_web_search": true + }, + "vertex_ai/xai/grok-4.20-non-reasoning": { + "cache_read_input_token_cost": 2e-07, + "input_cost_per_token": 2e-06, + "litellm_provider": "vertex_ai", + "max_input_tokens": 2000000, + "max_output_tokens": 2000000, + "max_tokens": 2000000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://docs.x.ai/docs/models (Vertex AI Model Garden)", + "supports_function_calling": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "supports_web_search": true + }, + "vertex_ai/xai/grok-4.20-reasoning": { + "cache_read_input_token_cost": 2e-07, + "input_cost_per_token": 2e-06, + "litellm_provider": "vertex_ai", + "max_input_tokens": 2000000, + "max_output_tokens": 2000000, + "max_tokens": 2000000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://docs.x.ai/docs/models (Vertex AI Model Garden)", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true, + "supports_web_search": true + }, "vertex_ai/qwen/qwen3-235b-a22b-instruct-2507-maas": { "input_cost_per_token": 2.5e-07, "litellm_provider": "vertex_ai-qwen_models", @@ -34266,6 +34505,7 @@ "output_cost_per_token": 1.5e-05, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": false, "supports_tool_choice": true, "supports_web_search": true @@ -34281,6 +34521,7 @@ "output_cost_per_token": 1.5e-05, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": false, "supports_tool_choice": true, "supports_web_search": true @@ -34296,6 +34537,7 @@ "output_cost_per_token": 2.5e-05, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": false, "supports_tool_choice": true, "supports_web_search": true @@ -34311,6 +34553,7 @@ "output_cost_per_token": 2.5e-05, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": false, "supports_tool_choice": true, "supports_web_search": true @@ -34326,6 +34569,7 @@ "output_cost_per_token": 1.5e-05, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": false, "supports_tool_choice": true, "supports_web_search": true @@ -34342,6 +34586,7 @@ "output_cost_per_token": 5e-07, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34359,6 +34604,7 @@ "output_cost_per_token": 5e-07, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34375,6 +34621,7 @@ "output_cost_per_token": 4e-06, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34391,6 +34638,7 @@ "output_cost_per_token": 4e-06, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34407,6 +34655,7 @@ "output_cost_per_token": 4e-06, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34423,6 +34672,7 @@ "output_cost_per_token": 5e-07, "source": "https://x.ai/api#pricing", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": false, "supports_tool_choice": true, @@ -34438,38 +34688,41 @@ "output_cost_per_token": 1.5e-05, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_web_search": true }, "xai/grok-4-fast-reasoning": { + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 2e-07, + "input_cost_per_token_above_128k_tokens": 4e-07, "litellm_provider": "xai", "max_input_tokens": 2000000.0, "max_output_tokens": 2000000.0, "max_tokens": 2000000.0, "mode": "chat", - "input_cost_per_token": 2e-07, - "input_cost_per_token_above_128k_tokens": 4e-07, "output_cost_per_token": 5e-07, "output_cost_per_token_above_128k_tokens": 1e-06, - "cache_read_input_token_cost": 5e-08, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_web_search": true }, "xai/grok-4-fast-non-reasoning": { + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 2e-07, + "input_cost_per_token_above_128k_tokens": 4e-07, "litellm_provider": "xai", "max_input_tokens": 2000000.0, "max_output_tokens": 2000000.0, - "cache_read_input_token_cost": 5e-08, "max_tokens": 2000000.0, "mode": "chat", - "input_cost_per_token": 2e-07, - "input_cost_per_token_above_128k_tokens": 4e-07, "output_cost_per_token": 5e-07, "output_cost_per_token_above_128k_tokens": 1e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_web_search": true }, @@ -34485,6 +34738,7 @@ "output_cost_per_token_above_128k_tokens": 3e-05, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_web_search": true }, @@ -34500,6 +34754,7 @@ "output_cost_per_token_above_128k_tokens": 3e-05, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_web_search": true }, @@ -34517,6 +34772,7 @@ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning", "supports_audio_input": true, "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, "supports_tool_choice": true, @@ -34537,6 +34793,7 @@ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning", "supports_audio_input": true, "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, "supports_tool_choice": true, @@ -34557,6 +34814,7 @@ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning", "supports_audio_input": true, "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, "supports_tool_choice": true, @@ -34577,6 +34835,7 @@ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-non-reasoning", "supports_audio_input": true, "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true, @@ -34596,6 +34855,7 @@ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-non-reasoning", "supports_audio_input": true, "supports_function_calling": true, + "supports_prompt_caching": true, "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true, @@ -34612,6 +34872,7 @@ "output_cost_per_token": 6e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true, "supports_vision": true, @@ -34628,6 +34889,7 @@ "output_cost_per_token": 6e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true, "supports_vision": true, @@ -34660,6 +34922,7 @@ "output_cost_per_token": 6e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_tool_choice": true, "supports_vision": true, "supports_web_search": true @@ -34688,6 +34951,7 @@ "output_cost_per_token": 1.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true }, @@ -34702,6 +34966,7 @@ "output_cost_per_token": 1.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true }, @@ -34716,6 +34981,7 @@ "output_cost_per_token": 1.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, + "supports_prompt_caching": true, "supports_reasoning": true, "supports_tool_choice": true }, @@ -34747,6 +35013,20 @@ "supports_tool_choice": true, "source": "https://aws.amazon.com/bedrock/pricing/" }, + "zai.glm-5": { + "input_cost_per_token": 1e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3.2e-06, + "supports_function_calling": true, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, "zai.glm-4.7-flash": { "input_cost_per_token": 7e-08, "litellm_provider": "bedrock_converse", @@ -39332,6 +39612,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_max_reasoning_effort": true, "supports_tool_choice": true, "supports_vision": true, "tool_use_system_prompt_tokens": 346, @@ -39556,6 +39837,87 @@ } ] }, + "zai.glm-5": { + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3.2e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, + "bedrock/us-east-1/zai.glm-5": { + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3.2e-06, + "litellm_provider": "bedrock", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, + "bedrock/us-west-2/zai.glm-5": { + "input_cost_per_token": 1e-06, + "output_cost_per_token": 3.2e-06, + "litellm_provider": "bedrock", + "max_input_tokens": 200000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, + "minimax.minimax-m2.5": { + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1.2e-06, + "litellm_provider": "bedrock_converse", + "max_input_tokens": 1000000, + "max_output_tokens": 8192, + "max_tokens": 8192, + "mode": "chat", + "supports_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, + "bedrock/us-east-1/minimax.minimax-m2.5": { + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1.2e-06, + "litellm_provider": "bedrock", + "max_input_tokens": 1000000, + "max_output_tokens": 8192, + "max_tokens": 8192, + "mode": "chat", + "supports_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, + "bedrock/us-west-2/minimax.minimax-m2.5": { + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1.2e-06, + "litellm_provider": "bedrock", + "max_input_tokens": 1000000, + "max_output_tokens": 8192, + "max_tokens": 8192, + "mode": "chat", + "supports_function_calling": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "source": "https://aws.amazon.com/bedrock/pricing/" + }, "bedrock/us-gov-east-1/anthropic.claude-haiku-4-5-20251001-v1:0": { "cache_creation_input_token_cost": 1.5e-06, "cache_read_input_token_cost": 1.2e-07, diff --git a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py index 756b2ed91d..a05af66118 100644 --- a/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py +++ b/litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py @@ -409,9 +409,12 @@ class MCPRequestHandler: Permission hierarchy (all rules are intersections): 1. Get allowed servers from key permissions - 2. Get allowed servers from team permissions - 3. Get allowed servers from end_user permissions - 4. Final result = intersection of key/team AND end_user (if end_user has permissions set) + 2. Get allowed servers from team permissions (key inherits from team, or intersection) + 3. Get allowed servers from end_user permissions (intersected if set) + 4. Get allowed servers from agent permissions (intersected if set) + 5. Get allowed servers from org permissions — org acts as a ceiling: if the org + has an explicit MCP server list, the combined key/team/end_user/agent result is + capped to that list. If the org has no list, no extra restriction is applied. Returns: List[str]: List of allowed MCP servers by server id @@ -435,6 +438,10 @@ class MCPRequestHandler: # Calculate key/team allowed servers using inheritance and intersection logic ######################################################### allowed_mcp_servers: List[str] = [] + has_lower_level_mcp_restrictions = ( + len(allowed_mcp_servers_for_key) > 0 + or len(allowed_mcp_servers_for_team) > 0 + ) if len(allowed_mcp_servers_for_team) > 0: if len(allowed_mcp_servers_for_key) > 0: # Key has its own MCP permissions - use intersection with team permissions @@ -459,6 +466,7 @@ class MCPRequestHandler: # If end_user has explicit MCP server permissions, apply intersection if len(allowed_mcp_servers_for_end_user) > 0: + has_lower_level_mcp_restrictions = True verbose_logger.debug( f"End user {user_api_key_auth.end_user_id} has explicit MCP permissions: {allowed_mcp_servers_for_end_user}" ) @@ -490,6 +498,7 @@ class MCPRequestHandler: ) ) if len(allowed_mcp_servers_for_agent) > 0: + has_lower_level_mcp_restrictions = True # Intersect: agent can only use servers allowed by BOTH key/team AND agent config allowed_mcp_servers = [ s @@ -500,6 +509,30 @@ class MCPRequestHandler: f"Applied agent intersection filter. Final allowed servers: {allowed_mcp_servers}" ) + ######################################################### + # Apply org-level ceiling if org_id is set + ######################################################### + if user_api_key_auth and user_api_key_auth.org_id: + allowed_mcp_servers_for_org = ( + await MCPRequestHandler._get_allowed_mcp_servers_for_org( + user_api_key_auth + ) + ) + if len(allowed_mcp_servers_for_org) > 0: + if has_lower_level_mcp_restrictions: + # Lower-level restrictions exist, so org can only cap them. + allowed_mcp_servers = [ + s + for s in allowed_mcp_servers + if s in allowed_mcp_servers_for_org + ] + else: + # No lower-level restrictions → org list becomes the ceiling + allowed_mcp_servers = allowed_mcp_servers_for_org + verbose_logger.debug( + f"Applied org ceiling filter. Final allowed servers: {allowed_mcp_servers}" + ) + return list(set(allowed_mcp_servers)) except Exception as e: verbose_logger.warning(f"Failed to get allowed MCP servers: {str(e)}") @@ -638,6 +671,27 @@ class MCPRequestHandler: allowed_tools = list(set(allowed_tools) & set(agent_tools)) else: allowed_tools = agent_tools + + # Apply org-level tool ceiling if org_id is set + if user_api_key_auth.org_id: + # _get_org_object_permission uses user_api_key_cache, so this is not a + # fresh DB round-trip when get_allowed_mcp_servers was already called. + org_obj_perm = await MCPRequestHandler._get_org_object_permission( + user_api_key_auth + ) + org_tools = ( + global_mcp_server_manager.expand_tool_permissions( + org_obj_perm.mcp_tool_permissions + ).get(server_id) + if org_obj_perm and org_obj_perm.mcp_tool_permissions + else None + ) + if org_tools is not None: + if allowed_tools is not None: + allowed_tools = list(set(allowed_tools) & set(org_tools)) + else: + allowed_tools = list(org_tools) + return allowed_tools except Exception as e: @@ -805,6 +859,120 @@ class MCPRequestHandler: ) return [] + # Sentinel stored in cache when an org has no object_permission, so we + # don't re-query the DB on every MCP request for that org. + _ORG_NO_PERMISSION_SENTINEL = "__org_no_mcp_permission__" + + @staticmethod + async def _get_org_object_permission( + user_api_key_auth: Optional[UserAPIKeyAuth] = None, + ): + """ + Get org object_permission, using user_api_key_cache to avoid DB hits on every request. + + Caches both positive results and the absence of an object_permission so that orgs + with no MCP permissions configured (the common default) do not trigger a DB query + on every request. + """ + from litellm.proxy.proxy_server import prisma_client, user_api_key_cache + + if not user_api_key_auth or not user_api_key_auth.org_id: + return None + + if prisma_client is None: + verbose_logger.debug("prisma_client is None") + return None + + org_id = user_api_key_auth.org_id + cache_key = f"org_object_permission:{org_id}" + + from litellm.proxy._types import LiteLLM_ObjectPermissionTable + + try: + cached = await user_api_key_cache.async_get_cache(key=cache_key) + if cached is not None: + # Sentinel means the DB confirmed no object_permission for this org + if cached == MCPRequestHandler._ORG_NO_PERMISSION_SENTINEL: + return None + # Redis deserialises to a plain dict; reconstruct the Pydantic model + # so callers can access .mcp_servers / .mcp_tool_permissions as attrs. + if isinstance(cached, dict): + return LiteLLM_ObjectPermissionTable(**cached) + return cached + + org_row = await prisma_client.db.litellm_organizationtable.find_unique( + where={"organization_id": org_id}, + include={"object_permission": True}, + ) + + if org_row is None or org_row.object_permission is None: + # Cache the negative result so subsequent calls skip the DB + await user_api_key_cache.async_set_cache( + key=cache_key, + value=MCPRequestHandler._ORG_NO_PERMISSION_SENTINEL, + ) + return None + + # Convert raw Prisma model → Pydantic before caching. Caching the + # Pydantic .dict() ensures the value survives a Redis JSON round-trip + # as a plain dict that we can reconstruct above (same pattern used by + # get_end_user_object / get_team_object in auth_checks.py). + obj_perm = LiteLLM_ObjectPermissionTable(**org_row.object_permission.dict()) + await user_api_key_cache.async_set_cache( + key=cache_key, value=obj_perm.dict() + ) + return obj_perm + except Exception as e: + verbose_logger.warning(f"Failed to get org object permission: {str(e)}") + return None + + @staticmethod + async def _get_allowed_mcp_servers_for_org( + user_api_key_auth: Optional[UserAPIKeyAuth] = None, + ) -> List[str]: + """ + Get allowed MCP servers for an organization. + + Returns the MCP servers from the org's object_permission. + An empty result means the org places no restriction (allow-all from this level). + """ + try: + object_permissions = await MCPRequestHandler._get_org_object_permission( + user_api_key_auth + ) + + if object_permissions is None: + return [] + + from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( + global_mcp_server_manager, + ) + + # Expand names/aliases to canonical server IDs (consistent with key/team/end-user path) + direct_mcp_servers = global_mcp_server_manager.expand_permission_list( + object_permissions.mcp_servers or [] + ) + + access_group_servers = ( + await MCPRequestHandler._get_mcp_servers_from_access_groups( + object_permissions.mcp_access_groups or [] + ) + ) + + tool_perm_servers = list( + global_mcp_server_manager.expand_tool_permissions( + object_permissions.mcp_tool_permissions + ).keys() + ) + + all_servers = direct_mcp_servers + access_group_servers + tool_perm_servers + return list(set(all_servers)) + except Exception as e: + verbose_logger.warning( + f"Failed to get allowed MCP servers for org: {str(e)}" + ) + return [] + @staticmethod async def _get_allowed_mcp_servers_for_end_user( user_api_key_auth: Optional[UserAPIKeyAuth] = None, diff --git a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py index cebd224a1a..1794cd1438 100644 --- a/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py +++ b/litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py @@ -33,10 +33,12 @@ def get_request_base_url(request: Request) -> str: """ Get the base URL for the request, considering X-Forwarded-* headers. - When behind a proxy (like nginx), the proxy may set: - - X-Forwarded-Proto: The original protocol (http/https) - - X-Forwarded-Host: The original host (may include port) - - X-Forwarded-Port: The original port (if not in Host header) + X-Forwarded-Proto / X-Forwarded-Host / X-Forwarded-Port are only honoured + when the request comes from a configured trusted proxy + (``use_x_forwarded_for`` enabled AND caller in ``mcp_trusted_proxy_ranges``). + Otherwise the request's literal ``base_url`` is returned, so an + untrusted caller cannot poison OAuth-discovery / redirect_uri values + by injecting headers. Args: request: FastAPI Request object @@ -47,34 +49,28 @@ def get_request_base_url(request: Request) -> str: base_url = str(request.base_url).rstrip("/") parsed = urlparse(base_url) - # Get forwarded headers + if not IPAddressUtils.is_request_from_trusted_proxy(request): + return base_url + x_forwarded_proto = request.headers.get("X-Forwarded-Proto") x_forwarded_host = request.headers.get("X-Forwarded-Host") x_forwarded_port = request.headers.get("X-Forwarded-Port") - # Start with the original scheme scheme = x_forwarded_proto if x_forwarded_proto else parsed.scheme - # Handle host and port if x_forwarded_host: # X-Forwarded-Host may already include port (e.g., "example.com:8080") if ":" in x_forwarded_host and not x_forwarded_host.startswith("["): - # Host includes port netloc = x_forwarded_host elif x_forwarded_port: - # Port is separate netloc = f"{x_forwarded_host}:{x_forwarded_port}" else: - # Just host, no explicit port netloc = x_forwarded_host else: - # No X-Forwarded-Host, use original netloc netloc = parsed.netloc if x_forwarded_port and ":" not in netloc: - # Add forwarded port if not already in netloc netloc = f"{netloc}:{x_forwarded_port}" - # Reconstruct the URL return urlunparse((scheme, netloc, parsed.path, "", "", "")) diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index f96350500d..9923c3ce4b 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -169,6 +169,37 @@ def _deserialize_json_dict(data: Any) -> Optional[Dict[str, str]]: class MCPServerManager: _STDIO_ENV_TEMPLATE_PATTERN = re.compile(r"^\$\{(X-[^}]+)\}$") + @staticmethod + def _resolve_oauth2_flow( + *, + auth_type: Optional[MCPAuthType], + oauth2_flow: Optional[str], + token_url: Optional[str], + authorization_url: Optional[str], + client_id: Optional[str], + client_secret: Optional[str], + ) -> Optional[Literal["client_credentials", "authorization_code"]]: + """Infer oauth2_flow for legacy records that omit the field. + + DB rows created before oauth2_flow support may have OAuth2 client + credentials + token_url but a null oauth2_flow. Treat these as M2M, + unless authorization_url is present (interactive OAuth). + """ + if oauth2_flow in ("client_credentials", "authorization_code"): + return cast( + Literal["client_credentials", "authorization_code"], oauth2_flow + ) + if oauth2_flow: + # Ignore unknown/untyped values and continue legacy inference. + return None + if auth_type != MCPAuth.oauth2: + return None + if authorization_url: + return None + if token_url and client_id and client_secret: + return "client_credentials" + return None + def __init__(self): self.registry: Dict[str, MCPServer] = {} self.config_mcp_servers: Dict[str, MCPServer] = {} @@ -342,7 +373,14 @@ class MCPServerManager: # oauth specific fields client_id=server_config.get("client_id", None), client_secret=server_config.get("client_secret", None), - oauth2_flow=server_config.get("oauth2_flow", None), + oauth2_flow=self._resolve_oauth2_flow( + auth_type=auth_type, + oauth2_flow=server_config.get("oauth2_flow", None), + token_url=resolved_token_url, + authorization_url=resolved_authorization_url, + client_id=server_config.get("client_id", None), + client_secret=server_config.get("client_secret", None), + ), scopes=resolved_scopes, authorization_url=resolved_authorization_url, token_url=resolved_token_url, @@ -679,7 +717,17 @@ class MCPServerManager: client_id=client_id_value or getattr(mcp_server, "client_id", None), client_secret=client_secret_value or getattr(mcp_server, "client_secret", None), - oauth2_flow=getattr(mcp_server, "oauth2_flow", None), + oauth2_flow=self._resolve_oauth2_flow( + auth_type=auth_type, + oauth2_flow=getattr(mcp_server, "oauth2_flow", None), + token_url=mcp_server.token_url + or getattr(mcp_oauth_metadata, "token_url", None), + authorization_url=mcp_server.authorization_url + or getattr(mcp_oauth_metadata, "authorization_url", None), + client_id=client_id_value or getattr(mcp_server, "client_id", None), + client_secret=client_secret_value + or getattr(mcp_server, "client_secret", None), + ), scopes=resolved_scopes, authorization_url=mcp_server.authorization_url or getattr(mcp_oauth_metadata, "authorization_url", None), @@ -2426,7 +2474,7 @@ class MCPServerManager: ) ) - async def _call_regular_mcp_tool( + async def _call_regular_mcp_tool( # noqa: PLR0915 self, mcp_server: MCPServer, original_tool_name: str, @@ -2489,7 +2537,11 @@ class MCPServerManager: # oauth2 headers extra_headers: Optional[Dict[str, str]] = None if mcp_server.auth_type == MCPAuth.oauth2: - extra_headers = oauth2_headers + if mcp_server.has_client_credentials: + # For M2M OAuth servers, Authorization must come from token fetch. + extra_headers = None + else: + extra_headers = oauth2_headers if mcp_server.extra_headers and raw_headers: if extra_headers is None: @@ -2501,6 +2553,11 @@ class MCPServerManager: for header in mcp_server.extra_headers: if not isinstance(header, str): continue + if ( + mcp_server.has_client_credentials + and header.lower() == "authorization" + ): + continue header_value = normalized_raw_headers.get(header.lower()) if header_value is None: continue @@ -2536,6 +2593,10 @@ class MCPServerManager: ) extra_headers.update(hook_extra_headers) + # Reset to None if no headers were actually added + if extra_headers is not None and len(extra_headers) == 0: + extra_headers = None + stdio_env = self._build_stdio_env(mcp_server, raw_headers) client = await self._create_mcp_client( diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index ae6055217b..54d9bbe6e2 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -153,6 +153,7 @@ if MCP_AVAILABLE: MCPAuthenticatedUser, ) from litellm.proxy._experimental.mcp_server.mcp_server_manager import ( + MCPServerManager, global_mcp_server_manager, ) from litellm.proxy._experimental.mcp_server.openapi_to_mcp_generator import ( @@ -900,6 +901,20 @@ if MCP_AVAILABLE: allowed_mcp_server_id ) if mcp_server is not None: + # Apply oauth2_flow resolution for legacy DB rows where it may be NULL + resolved_flow = MCPServerManager._resolve_oauth2_flow( + auth_type=mcp_server.auth_type, + oauth2_flow=mcp_server.oauth2_flow, + token_url=mcp_server.token_url, + authorization_url=mcp_server.authorization_url, + client_id=mcp_server.client_id, + client_secret=mcp_server.client_secret, + ) + if resolved_flow and resolved_flow != mcp_server.oauth2_flow: + # Create a new instance with the resolved flow for this request + mcp_server = mcp_server.model_copy( + update={"oauth2_flow": resolved_flow} + ) allowed_mcp_servers.append(mcp_server) if mcp_servers is not None: @@ -1100,8 +1115,13 @@ if MCP_AVAILABLE: extra_headers: Optional[Dict[str, str]] = None if server.auth_type == MCPAuth.oauth2: - # Copy to avoid mutating the original dict (important for parallel fetching) - extra_headers = oauth2_headers.copy() if oauth2_headers else None + # For OAuth2 M2M servers, upstream Authorization must come from + # client_credentials token fetch, never from caller headers. + if server.has_client_credentials: + extra_headers = None + else: + # Copy to avoid mutating the original dict (important for parallel fetching) + extra_headers = oauth2_headers.copy() if oauth2_headers else None if server.extra_headers and raw_headers: if extra_headers is None: @@ -1114,11 +1134,17 @@ if MCP_AVAILABLE: for header in server.extra_headers: if not isinstance(header, str): continue + if server.has_client_credentials and header.lower() == "authorization": + continue header_value = normalized_raw_headers.get(header.lower()) if header_value is None: continue extra_headers[header] = header_value + # Reset to None if no headers were actually added + if extra_headers is not None and len(extra_headers) == 0: + extra_headers = None + if server_auth_header is None: server_auth_header = mcp_auth_header @@ -1377,11 +1403,19 @@ if MCP_AVAILABLE: spend_meta["per_server_tool_counts"] = per_server_tool_counts end_time = datetime.now() - await litellm_logging_obj.async_success_handler( - result=all_tools, - start_time=list_tools_start_time, - end_time=end_time, - ) + try: + await litellm_logging_obj.async_success_handler( + result=all_tools, + start_time=list_tools_start_time, + end_time=end_time, + ) + except Exception as log_exc: + # list_tools responses must not be dropped due to non-blocking + # observability/serialization failures. + verbose_logger.warning( + "MCP list_tools success logging failed (continuing): %s", + log_exc, + ) verbose_logger.info( f"Successfully fetched {len(all_tools)} tools total from all MCP servers" @@ -2104,6 +2138,47 @@ if MCP_AVAILABLE: ######################################################### local_tool = global_mcp_tool_registry.get_tool(name) if local_tool: + # OpenAPI-backed tools used to bypass `pre_call_tool_check` — + # only the managed path ran allowed/banned-tool checks, key/team + # tool permissions, and parameter validation. Run the same checks + # before dispatching to the local registry. Refuse the call if + # we cannot resolve a server: tools registered via + # openapi_to_mcp_generator are always tied to a server, so a + # missing mcp_server here means the tool->server mapping has + # not finished initializing or the registry entry is orphaned. + # Skipping the check would re-open the same authorization gap. + if mcp_server is None: + raise HTTPException( + status_code=503, + detail=( + f"MCP server for tool '{name}' is not available; " + "refusing to dispatch without authorization checks. " + "Retry once the server is registered." + ), + ) + + # `pre_call_tool_check` calls into `proxy_logging_obj` for the + # pre-call guardrail hooks, so source it from the canonical + # `proxy_server` module the same way `_handle_managed_mcp_tool` + # does. `kwargs.get("proxy_logging_obj")` is None on the MCP + # entry path and would crash with AttributeError after the + # security checks pass. + from litellm.proxy.proxy_server import proxy_logging_obj + + hook_result = await global_mcp_server_manager.pre_call_tool_check( + name=original_tool_name, + arguments=arguments or {}, + server_name=server_name or mcp_server.name, + user_api_key_auth=user_api_key_auth, + proxy_logging_obj=proxy_logging_obj, + server=mcp_server, + raw_headers=raw_headers, + ) + # `pre_call_tool_check` may return guardrail-modified + # arguments; honor them on the local path too. + if isinstance(hook_result, dict) and "arguments" in hook_result: + arguments = hook_result["arguments"] + verbose_logger.debug(f"Executing local registry tool: {name}") # For BYOK servers the credential must be injected via a ContextVar # because the tool function has headers baked into its closure. diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html index a3e8dd80e8..17fdb3b358 100644 --- a/litellm/proxy/_experimental/out/404.html +++ b/litellm/proxy/_experimental/out/404.html @@ -1 +1 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/__next.__PAGE__.txt b/litellm/proxy/_experimental/out/__next.__PAGE__.txt index 8f751e4781..cf19a1edd6 100644 --- a/litellm/proxy/_experimental/out/__next.__PAGE__.txt +++ b/litellm/proxy/_experimental/out/__next.__PAGE__.txt @@ -1,27 +1,30 @@ 1:"$Sreact.fragment" 2:I[347257,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ClientPageRoot"] -3:I[952683,["/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","/litellm-asset-prefix/_next/static/chunks/cd677ff381b90c30.js","/litellm-asset-prefix/_next/static/chunks/738efbc0d941f9d2.js","/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","/litellm-asset-prefix/_next/static/chunks/c53c9c7afec96700.js","/litellm-asset-prefix/_next/static/chunks/1fe0596a309ad6cf.js","/litellm-asset-prefix/_next/static/chunks/c0b640cc12a2b90e.js","/litellm-asset-prefix/_next/static/chunks/35e1b31334447d6e.js","/litellm-asset-prefix/_next/static/chunks/40ec1228b231a0d1.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/d8cd2d44272d51c8.js","/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/fe5abdcdb57db543.js","/litellm-asset-prefix/_next/static/chunks/47a838c67cdd745e.js","/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","/litellm-asset-prefix/_next/static/chunks/7149faf92f484aca.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","/litellm-asset-prefix/_next/static/chunks/4b8dcb3ad5dfb8de.js","/litellm-asset-prefix/_next/static/chunks/eaa9f9b9bb3e054b.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/ddcd1fd842a79e55.js","/litellm-asset-prefix/_next/static/chunks/3daef8922b68e600.js","/litellm-asset-prefix/_next/static/chunks/4f6e5b838f18b8e6.js","/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","/litellm-asset-prefix/_next/static/chunks/052aaa8d01e02cd3.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","/litellm-asset-prefix/_next/static/chunks/65968777d52ff874.js","/litellm-asset-prefix/_next/static/chunks/a1b5b0c54192471e.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/341e7c75250f4f40.js","/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","/litellm-asset-prefix/_next/static/chunks/50d8a95e62930b35.js","/litellm-asset-prefix/_next/static/chunks/2005c732f6d6cbb4.js","/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","/litellm-asset-prefix/_next/static/chunks/7c797521435cb59c.js","/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","/litellm-asset-prefix/_next/static/chunks/e7cc7b98b893b20d.js","/litellm-asset-prefix/_next/static/chunks/ca91b0fa4d619698.js","/litellm-asset-prefix/_next/static/chunks/e1f572e8226962e3.js"],"default"] -17:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] -18:"$Sreact.suspense" +3:I[952683,["/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","/litellm-asset-prefix/_next/static/chunks/0493aafc4891dd29.js","/litellm-asset-prefix/_next/static/chunks/f7e1d08418645368.js","/litellm-asset-prefix/_next/static/chunks/b3d198d6c56a21b8.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/37e77c06e99eb8ff.js","/litellm-asset-prefix/_next/static/chunks/adb8beb738574863.js","/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","/litellm-asset-prefix/_next/static/chunks/0b470ffc60999bf4.js","/litellm-asset-prefix/_next/static/chunks/c847ecdf8c790b0b.js","/litellm-asset-prefix/_next/static/chunks/baadbd26839e7b66.js","/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","/litellm-asset-prefix/_next/static/chunks/4e17b625d75327a7.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/a06cc76a774dd182.js","/litellm-asset-prefix/_next/static/chunks/264fd32eefec52b6.js","/litellm-asset-prefix/_next/static/chunks/86828bdbafb8b581.js","/litellm-asset-prefix/_next/static/chunks/10dc4591ef08a91f.js","/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","/litellm-asset-prefix/_next/static/chunks/fbe12a36d22e9554.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","/litellm-asset-prefix/_next/static/chunks/679dbd657c8b5aef.js","/litellm-asset-prefix/_next/static/chunks/94f7208f5087e27c.js","/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","/litellm-asset-prefix/_next/static/chunks/4e06277331e725da.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","/litellm-asset-prefix/_next/static/chunks/fb125648f2dae104.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","/litellm-asset-prefix/_next/static/chunks/6967a3b4ecbd3785.js","/litellm-asset-prefix/_next/static/chunks/3e917c79aadd945b.js","/litellm-asset-prefix/_next/static/chunks/9bbebdeb3f1cb03f.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","/litellm-asset-prefix/_next/static/chunks/5f2d62a75803a3f7.js","/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","/litellm-asset-prefix/_next/static/chunks/9b0ee76cbdef1a2a.js","/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","/litellm-asset-prefix/_next/static/chunks/878832edb30e99a4.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/8e3d0ce9505a304f.js","/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/0cdfadbcf4b8c9e4.js","/litellm-asset-prefix/_next/static/chunks/8f3bf592254c6c3b.js","/litellm-asset-prefix/_next/static/chunks/8c17e934bd227606.js","/litellm-asset-prefix/_next/static/chunks/b98447395b5d37ef.js"],"default"] +1a:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] +1b:"$Sreact.suspense" :HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] -0:{"buildId":"zxkD4-EPlgfKHDTw8O869","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/cd677ff381b90c30.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/738efbc0d941f9d2.js","async":true}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","async":true}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","async":true}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/c53c9c7afec96700.js","async":true}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/1fe0596a309ad6cf.js","async":true}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/c0b640cc12a2b90e.js","async":true}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/35e1b31334447d6e.js","async":true}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/40ec1228b231a0d1.js","async":true}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/d8cd2d44272d51c8.js","async":true}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","async":true}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","async":true}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/fe5abdcdb57db543.js","async":true}],["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/47a838c67cdd745e.js","async":true}],["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","async":true}],["$","script","script-18",{"src":"/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","async":true}],["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","async":true}],["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/7149faf92f484aca.js","async":true}],["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true}],["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","async":true}],["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/4b8dcb3ad5dfb8de.js","async":true}],["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/eaa9f9b9bb3e054b.js","async":true}],["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true}],["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/ddcd1fd842a79e55.js","async":true}],["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/3daef8922b68e600.js","async":true}],["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/4f6e5b838f18b8e6.js","async":true}],["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","async":true}],["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/052aaa8d01e02cd3.js","async":true}],["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true}],["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","async":true}],["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","async":true}],"$L6","$L7","$L8","$L9","$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15"],"$L16"]}],"loading":null,"isPartial":false} +0:{"buildId":"8TZ2JbOi7SZ6BCj9ScTHW","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/0493aafc4891dd29.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/f7e1d08418645368.js","async":true}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/b3d198d6c56a21b8.js","async":true}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/37e77c06e99eb8ff.js","async":true}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/adb8beb738574863.js","async":true}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","async":true}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/0b470ffc60999bf4.js","async":true}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/c847ecdf8c790b0b.js","async":true}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/baadbd26839e7b66.js","async":true}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","async":true}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","async":true}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/4e17b625d75327a7.js","async":true}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/a06cc76a774dd182.js","async":true}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/264fd32eefec52b6.js","async":true}],["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/86828bdbafb8b581.js","async":true}],["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/10dc4591ef08a91f.js","async":true}],["$","script","script-18",{"src":"/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","async":true}],["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/fbe12a36d22e9554.js","async":true}],["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true}],["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","async":true}],["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/679dbd657c8b5aef.js","async":true}],["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/94f7208f5087e27c.js","async":true}],["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","async":true}],["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/4e06277331e725da.js","async":true}],["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true}],["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","async":true}],["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/fb125648f2dae104.js","async":true}],["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true}],["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","async":true}],["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/6967a3b4ecbd3785.js","async":true}],["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/3e917c79aadd945b.js","async":true}],["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/9bbebdeb3f1cb03f.js","async":true}],"$L6","$L7","$L8","$L9","$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15","$L16","$L17","$L18"],"$L19"]}],"loading":null,"isPartial":false} 4:{} 5:"$0:rsc:props:children:0:props:serverProvidedParams:params" -6:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/65968777d52ff874.js","async":true}] -7:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/a1b5b0c54192471e.js","async":true}] -8:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true}] -9:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true}] -a:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/341e7c75250f4f40.js","async":true}] -b:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","async":true}] -c:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true}] -d:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","async":true}] -e:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/50d8a95e62930b35.js","async":true}] -f:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/2005c732f6d6cbb4.js","async":true}] -10:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","async":true}] -11:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/7c797521435cb59c.js","async":true}] -12:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","async":true}] -13:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/e7cc7b98b893b20d.js","async":true}] -14:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/ca91b0fa4d619698.js","async":true}] -15:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f572e8226962e3.js","async":true}] -16:["$","$L17",null,{"children":["$","$18",null,{"name":"Next.MetadataOutlet","children":"$@19"}]}] -19:null +6:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true}] +7:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","async":true}] +8:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/5f2d62a75803a3f7.js","async":true}] +9:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","async":true}] +a:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","async":true}] +b:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/9b0ee76cbdef1a2a.js","async":true}] +c:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","async":true}] +d:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","async":true}] +e:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/878832edb30e99a4.js","async":true}] +f:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true}] +10:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/8e3d0ce9505a304f.js","async":true}] +11:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","async":true}] +12:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true}] +13:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","async":true}] +14:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true}] +15:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/0cdfadbcf4b8c9e4.js","async":true}] +16:["$","script","script-50",{"src":"/litellm-asset-prefix/_next/static/chunks/8f3bf592254c6c3b.js","async":true}] +17:["$","script","script-51",{"src":"/litellm-asset-prefix/_next/static/chunks/8c17e934bd227606.js","async":true}] +18:["$","script","script-52",{"src":"/litellm-asset-prefix/_next/static/chunks/b98447395b5d37ef.js","async":true}] +19:["$","$L1a",null,{"children":["$","$1b",null,{"name":"Next.MetadataOutlet","children":"$@1c"}]}] +1c:null diff --git a/litellm/proxy/_experimental/out/__next._full.txt b/litellm/proxy/_experimental/out/__next._full.txt index 66ed8c623b..6b75bee883 100644 --- a/litellm/proxy/_experimental/out/__next._full.txt +++ b/litellm/proxy/_experimental/out/__next._full.txt @@ -4,56 +4,59 @@ 4:I[339756,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] 5:I[837457,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] 6:I[347257,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ClientPageRoot"] -7:I[952683,["/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","/litellm-asset-prefix/_next/static/chunks/cd677ff381b90c30.js","/litellm-asset-prefix/_next/static/chunks/738efbc0d941f9d2.js","/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","/litellm-asset-prefix/_next/static/chunks/c53c9c7afec96700.js","/litellm-asset-prefix/_next/static/chunks/1fe0596a309ad6cf.js","/litellm-asset-prefix/_next/static/chunks/c0b640cc12a2b90e.js","/litellm-asset-prefix/_next/static/chunks/35e1b31334447d6e.js","/litellm-asset-prefix/_next/static/chunks/40ec1228b231a0d1.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/d8cd2d44272d51c8.js","/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/fe5abdcdb57db543.js","/litellm-asset-prefix/_next/static/chunks/47a838c67cdd745e.js","/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","/litellm-asset-prefix/_next/static/chunks/7149faf92f484aca.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","/litellm-asset-prefix/_next/static/chunks/4b8dcb3ad5dfb8de.js","/litellm-asset-prefix/_next/static/chunks/eaa9f9b9bb3e054b.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/ddcd1fd842a79e55.js","/litellm-asset-prefix/_next/static/chunks/3daef8922b68e600.js","/litellm-asset-prefix/_next/static/chunks/4f6e5b838f18b8e6.js","/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","/litellm-asset-prefix/_next/static/chunks/052aaa8d01e02cd3.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","/litellm-asset-prefix/_next/static/chunks/65968777d52ff874.js","/litellm-asset-prefix/_next/static/chunks/a1b5b0c54192471e.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/341e7c75250f4f40.js","/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","/litellm-asset-prefix/_next/static/chunks/50d8a95e62930b35.js","/litellm-asset-prefix/_next/static/chunks/2005c732f6d6cbb4.js","/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","/litellm-asset-prefix/_next/static/chunks/7c797521435cb59c.js","/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","/litellm-asset-prefix/_next/static/chunks/e7cc7b98b893b20d.js","/litellm-asset-prefix/_next/static/chunks/ca91b0fa4d619698.js","/litellm-asset-prefix/_next/static/chunks/e1f572e8226962e3.js"],"default"] -2e:I[168027,[],"default"] +7:I[952683,["/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","/litellm-asset-prefix/_next/static/chunks/0493aafc4891dd29.js","/litellm-asset-prefix/_next/static/chunks/f7e1d08418645368.js","/litellm-asset-prefix/_next/static/chunks/b3d198d6c56a21b8.js","/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","/litellm-asset-prefix/_next/static/chunks/37e77c06e99eb8ff.js","/litellm-asset-prefix/_next/static/chunks/adb8beb738574863.js","/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","/litellm-asset-prefix/_next/static/chunks/0b470ffc60999bf4.js","/litellm-asset-prefix/_next/static/chunks/c847ecdf8c790b0b.js","/litellm-asset-prefix/_next/static/chunks/baadbd26839e7b66.js","/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","/litellm-asset-prefix/_next/static/chunks/4e17b625d75327a7.js","/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","/litellm-asset-prefix/_next/static/chunks/a06cc76a774dd182.js","/litellm-asset-prefix/_next/static/chunks/264fd32eefec52b6.js","/litellm-asset-prefix/_next/static/chunks/86828bdbafb8b581.js","/litellm-asset-prefix/_next/static/chunks/10dc4591ef08a91f.js","/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","/litellm-asset-prefix/_next/static/chunks/fbe12a36d22e9554.js","/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","/litellm-asset-prefix/_next/static/chunks/679dbd657c8b5aef.js","/litellm-asset-prefix/_next/static/chunks/94f7208f5087e27c.js","/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","/litellm-asset-prefix/_next/static/chunks/4e06277331e725da.js","/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","/litellm-asset-prefix/_next/static/chunks/fb125648f2dae104.js","/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","/litellm-asset-prefix/_next/static/chunks/6967a3b4ecbd3785.js","/litellm-asset-prefix/_next/static/chunks/3e917c79aadd945b.js","/litellm-asset-prefix/_next/static/chunks/9bbebdeb3f1cb03f.js","/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","/litellm-asset-prefix/_next/static/chunks/5f2d62a75803a3f7.js","/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","/litellm-asset-prefix/_next/static/chunks/9b0ee76cbdef1a2a.js","/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","/litellm-asset-prefix/_next/static/chunks/878832edb30e99a4.js","/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","/litellm-asset-prefix/_next/static/chunks/8e3d0ce9505a304f.js","/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","/litellm-asset-prefix/_next/static/chunks/0cdfadbcf4b8c9e4.js","/litellm-asset-prefix/_next/static/chunks/8f3bf592254c6c3b.js","/litellm-asset-prefix/_next/static/chunks/8c17e934bd227606.js","/litellm-asset-prefix/_next/static/chunks/b98447395b5d37ef.js"],"default"] +31:I[168027,[],"default"] :HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] -:HL["/litellm-asset-prefix/_next/static/chunks/e0cb6755699177c1.css","style"] +:HL["/litellm-asset-prefix/_next/static/chunks/91037395c95e366d.css","style"] :HL["/litellm-asset-prefix/_next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2","font",{"crossOrigin":"","type":"font/woff2"}] :HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] -0:{"P":null,"b":"zxkD4-EPlgfKHDTw8O869","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/e0cb6755699177c1.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L6",null,{"Component":"$7","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@8","$@9"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/cd677ff381b90c30.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/738efbc0d941f9d2.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/c53c9c7afec96700.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/1fe0596a309ad6cf.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/c0b640cc12a2b90e.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/35e1b31334447d6e.js","async":true,"nonce":"$undefined"}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/40ec1228b231a0d1.js","async":true,"nonce":"$undefined"}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true,"nonce":"$undefined"}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/d8cd2d44272d51c8.js","async":true,"nonce":"$undefined"}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","async":true,"nonce":"$undefined"}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","async":true,"nonce":"$undefined"}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true,"nonce":"$undefined"}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/fe5abdcdb57db543.js","async":true,"nonce":"$undefined"}],"$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15","$L16","$L17","$L18","$L19","$L1a","$L1b","$L1c","$L1d","$L1e","$L1f","$L20","$L21","$L22","$L23","$L24","$L25","$L26","$L27","$L28","$L29","$L2a","$L2b"],"$L2c"]}],{},null,false,false]},null,false,false],"$L2d",false]],"m":"$undefined","G":["$2e",[]],"S":true} -2f:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] -30:"$Sreact.suspense" -32:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ViewportBoundary"] -34:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"MetadataBoundary"] -a:["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/47a838c67cdd745e.js","async":true,"nonce":"$undefined"}] -b:["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","async":true,"nonce":"$undefined"}] +0:{"P":null,"b":"8TZ2JbOi7SZ6BCj9ScTHW","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/91037395c95e366d.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L6",null,{"Component":"$7","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@8","$@9"]}}],[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/0493aafc4891dd29.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/f7e1d08418645368.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/litellm-asset-prefix/_next/static/chunks/b3d198d6c56a21b8.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/litellm-asset-prefix/_next/static/chunks/403c4d96324c23a6.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/litellm-asset-prefix/_next/static/chunks/37e77c06e99eb8ff.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/litellm-asset-prefix/_next/static/chunks/adb8beb738574863.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/litellm-asset-prefix/_next/static/chunks/0549bc9afa7d4888.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/litellm-asset-prefix/_next/static/chunks/0b470ffc60999bf4.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/litellm-asset-prefix/_next/static/chunks/c847ecdf8c790b0b.js","async":true,"nonce":"$undefined"}],["$","script","script-9",{"src":"/litellm-asset-prefix/_next/static/chunks/baadbd26839e7b66.js","async":true,"nonce":"$undefined"}],["$","script","script-10",{"src":"/litellm-asset-prefix/_next/static/chunks/ee5f9a39a526e423.js","async":true,"nonce":"$undefined"}],["$","script","script-11",{"src":"/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","async":true,"nonce":"$undefined"}],["$","script","script-12",{"src":"/litellm-asset-prefix/_next/static/chunks/4e17b625d75327a7.js","async":true,"nonce":"$undefined"}],["$","script","script-13",{"src":"/litellm-asset-prefix/_next/static/chunks/7b788dd93ad868b3.js","async":true,"nonce":"$undefined"}],["$","script","script-14",{"src":"/litellm-asset-prefix/_next/static/chunks/a06cc76a774dd182.js","async":true,"nonce":"$undefined"}],["$","script","script-15",{"src":"/litellm-asset-prefix/_next/static/chunks/264fd32eefec52b6.js","async":true,"nonce":"$undefined"}],"$La","$Lb","$Lc","$Ld","$Le","$Lf","$L10","$L11","$L12","$L13","$L14","$L15","$L16","$L17","$L18","$L19","$L1a","$L1b","$L1c","$L1d","$L1e","$L1f","$L20","$L21","$L22","$L23","$L24","$L25","$L26","$L27","$L28","$L29","$L2a","$L2b","$L2c","$L2d","$L2e"],"$L2f"]}],{},null,false,false]},null,false,false],"$L30",false]],"m":"$undefined","G":["$31",[]],"S":true} +32:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"OutletBoundary"] +33:"$Sreact.suspense" +35:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"ViewportBoundary"] +37:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"MetadataBoundary"] +a:["$","script","script-16",{"src":"/litellm-asset-prefix/_next/static/chunks/86828bdbafb8b581.js","async":true,"nonce":"$undefined"}] +b:["$","script","script-17",{"src":"/litellm-asset-prefix/_next/static/chunks/10dc4591ef08a91f.js","async":true,"nonce":"$undefined"}] c:["$","script","script-18",{"src":"/litellm-asset-prefix/_next/static/chunks/e099566e8bd4ee4e.js","async":true,"nonce":"$undefined"}] -d:["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","async":true,"nonce":"$undefined"}] -e:["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/7149faf92f484aca.js","async":true,"nonce":"$undefined"}] -f:["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true,"nonce":"$undefined"}] -10:["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","async":true,"nonce":"$undefined"}] -11:["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/4b8dcb3ad5dfb8de.js","async":true,"nonce":"$undefined"}] -12:["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/eaa9f9b9bb3e054b.js","async":true,"nonce":"$undefined"}] -13:["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true,"nonce":"$undefined"}] -14:["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/ddcd1fd842a79e55.js","async":true,"nonce":"$undefined"}] -15:["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/3daef8922b68e600.js","async":true,"nonce":"$undefined"}] -16:["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/4f6e5b838f18b8e6.js","async":true,"nonce":"$undefined"}] -17:["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","async":true,"nonce":"$undefined"}] -18:["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/052aaa8d01e02cd3.js","async":true,"nonce":"$undefined"}] -19:["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true,"nonce":"$undefined"}] -1a:["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","async":true,"nonce":"$undefined"}] -1b:["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","async":true,"nonce":"$undefined"}] -1c:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/65968777d52ff874.js","async":true,"nonce":"$undefined"}] -1d:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/a1b5b0c54192471e.js","async":true,"nonce":"$undefined"}] -1e:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true,"nonce":"$undefined"}] -1f:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true,"nonce":"$undefined"}] -20:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/341e7c75250f4f40.js","async":true,"nonce":"$undefined"}] -21:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","async":true,"nonce":"$undefined"}] -22:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true,"nonce":"$undefined"}] -23:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","async":true,"nonce":"$undefined"}] -24:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/50d8a95e62930b35.js","async":true,"nonce":"$undefined"}] -25:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/2005c732f6d6cbb4.js","async":true,"nonce":"$undefined"}] -26:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/6eee262391715440.js","async":true,"nonce":"$undefined"}] -27:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/7c797521435cb59c.js","async":true,"nonce":"$undefined"}] -28:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","async":true,"nonce":"$undefined"}] -29:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/e7cc7b98b893b20d.js","async":true,"nonce":"$undefined"}] -2a:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/ca91b0fa4d619698.js","async":true,"nonce":"$undefined"}] -2b:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f572e8226962e3.js","async":true,"nonce":"$undefined"}] -2c:["$","$L2f",null,{"children":["$","$30",null,{"name":"Next.MetadataOutlet","children":"$@31"}]}] -2d:["$","$1","h",{"children":[null,["$","$L32",null,{"children":"$L33"}],["$","div",null,{"hidden":true,"children":["$","$L34",null,{"children":["$","$30",null,{"name":"Next.Metadata","children":"$L35"}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}] +d:["$","script","script-19",{"src":"/litellm-asset-prefix/_next/static/chunks/fbe12a36d22e9554.js","async":true,"nonce":"$undefined"}] +e:["$","script","script-20",{"src":"/litellm-asset-prefix/_next/static/chunks/2971c4658f1bcd7d.js","async":true,"nonce":"$undefined"}] +f:["$","script","script-21",{"src":"/litellm-asset-prefix/_next/static/chunks/134f728fa7099e3e.js","async":true,"nonce":"$undefined"}] +10:["$","script","script-22",{"src":"/litellm-asset-prefix/_next/static/chunks/679dbd657c8b5aef.js","async":true,"nonce":"$undefined"}] +11:["$","script","script-23",{"src":"/litellm-asset-prefix/_next/static/chunks/94f7208f5087e27c.js","async":true,"nonce":"$undefined"}] +12:["$","script","script-24",{"src":"/litellm-asset-prefix/_next/static/chunks/43f6fc3c2ab9cf23.js","async":true,"nonce":"$undefined"}] +13:["$","script","script-25",{"src":"/litellm-asset-prefix/_next/static/chunks/4e06277331e725da.js","async":true,"nonce":"$undefined"}] +14:["$","script","script-26",{"src":"/litellm-asset-prefix/_next/static/chunks/3b30ab8eaa03bc21.js","async":true,"nonce":"$undefined"}] +15:["$","script","script-27",{"src":"/litellm-asset-prefix/_next/static/chunks/ac3cf77acb5bf234.js","async":true,"nonce":"$undefined"}] +16:["$","script","script-28",{"src":"/litellm-asset-prefix/_next/static/chunks/fb125648f2dae104.js","async":true,"nonce":"$undefined"}] +17:["$","script","script-29",{"src":"/litellm-asset-prefix/_next/static/chunks/7e417dd24c8becd0.js","async":true,"nonce":"$undefined"}] +18:["$","script","script-30",{"src":"/litellm-asset-prefix/_next/static/chunks/a09028cd611c08ef.js","async":true,"nonce":"$undefined"}] +19:["$","script","script-31",{"src":"/litellm-asset-prefix/_next/static/chunks/6967a3b4ecbd3785.js","async":true,"nonce":"$undefined"}] +1a:["$","script","script-32",{"src":"/litellm-asset-prefix/_next/static/chunks/3e917c79aadd945b.js","async":true,"nonce":"$undefined"}] +1b:["$","script","script-33",{"src":"/litellm-asset-prefix/_next/static/chunks/9bbebdeb3f1cb03f.js","async":true,"nonce":"$undefined"}] +1c:["$","script","script-34",{"src":"/litellm-asset-prefix/_next/static/chunks/0a65da2cd24e2ab6.js","async":true,"nonce":"$undefined"}] +1d:["$","script","script-35",{"src":"/litellm-asset-prefix/_next/static/chunks/908828a91f602d8b.js","async":true,"nonce":"$undefined"}] +1e:["$","script","script-36",{"src":"/litellm-asset-prefix/_next/static/chunks/5f2d62a75803a3f7.js","async":true,"nonce":"$undefined"}] +1f:["$","script","script-37",{"src":"/litellm-asset-prefix/_next/static/chunks/ca5fbafaf3826374.js","async":true,"nonce":"$undefined"}] +20:["$","script","script-38",{"src":"/litellm-asset-prefix/_next/static/chunks/d3ac82723ec9e30d.js","async":true,"nonce":"$undefined"}] +21:["$","script","script-39",{"src":"/litellm-asset-prefix/_next/static/chunks/9b0ee76cbdef1a2a.js","async":true,"nonce":"$undefined"}] +22:["$","script","script-40",{"src":"/litellm-asset-prefix/_next/static/chunks/1bc2898be56acd1b.js","async":true,"nonce":"$undefined"}] +23:["$","script","script-41",{"src":"/litellm-asset-prefix/_next/static/chunks/fcdf7322b0aa3e2e.js","async":true,"nonce":"$undefined"}] +24:["$","script","script-42",{"src":"/litellm-asset-prefix/_next/static/chunks/878832edb30e99a4.js","async":true,"nonce":"$undefined"}] +25:["$","script","script-43",{"src":"/litellm-asset-prefix/_next/static/chunks/496b84010c33cf69.js","async":true,"nonce":"$undefined"}] +26:["$","script","script-44",{"src":"/litellm-asset-prefix/_next/static/chunks/8e3d0ce9505a304f.js","async":true,"nonce":"$undefined"}] +27:["$","script","script-45",{"src":"/litellm-asset-prefix/_next/static/chunks/e1f23fd814ac3500.js","async":true,"nonce":"$undefined"}] +28:["$","script","script-46",{"src":"/litellm-asset-prefix/_next/static/chunks/88c74f8b4b20d25a.js","async":true,"nonce":"$undefined"}] +29:["$","script","script-47",{"src":"/litellm-asset-prefix/_next/static/chunks/99cf9cf99df5ccfc.js","async":true,"nonce":"$undefined"}] +2a:["$","script","script-48",{"src":"/litellm-asset-prefix/_next/static/chunks/4980372eaa37b78b.js","async":true,"nonce":"$undefined"}] +2b:["$","script","script-49",{"src":"/litellm-asset-prefix/_next/static/chunks/0cdfadbcf4b8c9e4.js","async":true,"nonce":"$undefined"}] +2c:["$","script","script-50",{"src":"/litellm-asset-prefix/_next/static/chunks/8f3bf592254c6c3b.js","async":true,"nonce":"$undefined"}] +2d:["$","script","script-51",{"src":"/litellm-asset-prefix/_next/static/chunks/8c17e934bd227606.js","async":true,"nonce":"$undefined"}] +2e:["$","script","script-52",{"src":"/litellm-asset-prefix/_next/static/chunks/b98447395b5d37ef.js","async":true,"nonce":"$undefined"}] +2f:["$","$L32",null,{"children":["$","$33",null,{"name":"Next.MetadataOutlet","children":"$@34"}]}] +30:["$","$1","h",{"children":[null,["$","$L35",null,{"children":"$L36"}],["$","div",null,{"hidden":true,"children":["$","$L37",null,{"children":["$","$33",null,{"name":"Next.Metadata","children":"$L38"}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}] 8:{} 9:"$0:f:0:1:1:children:0:props:children:0:props:serverProvidedParams:params" -33:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] -36:I[27201,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"IconMark"] -31:null -35:[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L36","4",{}]] +36:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] +39:I[27201,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"IconMark"] +34:null +38:[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L39","4",{}]] diff --git a/litellm/proxy/_experimental/out/__next._head.txt b/litellm/proxy/_experimental/out/__next._head.txt index 635c8e398b..680119eb91 100644 --- a/litellm/proxy/_experimental/out/__next._head.txt +++ b/litellm/proxy/_experimental/out/__next._head.txt @@ -3,4 +3,4 @@ 3:I[897367,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"MetadataBoundary"] 4:"$Sreact.suspense" 5:I[27201,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"IconMark"] -0:{"buildId":"zxkD4-EPlgfKHDTw8O869","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L5","4",{}]]}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],"loading":null,"isPartial":false} +0:{"buildId":"8TZ2JbOi7SZ6BCj9ScTHW","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"LiteLLM Dashboard"}],["$","meta","1",{"name":"description","content":"LiteLLM Proxy Admin UI"}],["$","link","2",{"rel":"icon","href":"/favicon.ico?favicon.1d32c690.ico","sizes":"48x48","type":"image/x-icon"}],["$","link","3",{"rel":"icon","href":"./favicon.ico"}],["$","$L5","4",{}]]}]}]}],["$","meta",null,{"name":"next-size-adjust","content":""}]]}],"loading":null,"isPartial":false} diff --git a/litellm/proxy/_experimental/out/__next._index.txt b/litellm/proxy/_experimental/out/__next._index.txt index d026a48036..f23ca44427 100644 --- a/litellm/proxy/_experimental/out/__next._index.txt +++ b/litellm/proxy/_experimental/out/__next._index.txt @@ -4,5 +4,5 @@ 4:I[339756,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] 5:I[837457,["/litellm-asset-prefix/_next/static/chunks/d96012bcfc98706a.js","/litellm-asset-prefix/_next/static/chunks/dbca964212122d58.js"],"default"] :HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] -:HL["/litellm-asset-prefix/_next/static/chunks/e0cb6755699177c1.css","style"] -0:{"buildId":"zxkD4-EPlgfKHDTw8O869","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/e0cb6755699177c1.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","template":["$","$L5",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]}]]}],"loading":null,"isPartial":false} +:HL["/litellm-asset-prefix/_next/static/chunks/91037395c95e366d.css","style"] +0:{"buildId":"8TZ2JbOi7SZ6BCj9ScTHW","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/litellm-asset-prefix/_next/static/chunks/91037395c95e366d.css","precedence":"next"}],["$","script","script-0",{"src":"/litellm-asset-prefix/_next/static/chunks/9e09de50158b3159.js","async":true}],["$","script","script-1",{"src":"/litellm-asset-prefix/_next/static/chunks/7e5fe5584502da06.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"inter_5972bc34-module__OU16Qa__className","children":["$","$L2",null,{"children":["$","$L3",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","template":["$","$L5",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]}]]}],"loading":null,"isPartial":false} diff --git a/litellm/proxy/_experimental/out/__next._tree.txt b/litellm/proxy/_experimental/out/__next._tree.txt index 44f06b2376..45dbee6602 100644 --- a/litellm/proxy/_experimental/out/__next._tree.txt +++ b/litellm/proxy/_experimental/out/__next._tree.txt @@ -1,5 +1,5 @@ :HL["/litellm-asset-prefix/_next/static/chunks/4e20891f2fd03463.css","style"] -:HL["/litellm-asset-prefix/_next/static/chunks/e0cb6755699177c1.css","style"] +:HL["/litellm-asset-prefix/_next/static/chunks/91037395c95e366d.css","style"] :HL["/litellm-asset-prefix/_next/static/media/83afe278b6a6bb3c-s.p.3a6ba036.woff2","font",{"crossOrigin":"","type":"font/woff2"}] :HL["/litellm-asset-prefix/_next/static/chunks/3f3fa56b5786d58c.css","style"] -0:{"buildId":"zxkD4-EPlgfKHDTw8O869","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300} +0:{"buildId":"8TZ2JbOi7SZ6BCj9ScTHW","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300} diff --git a/litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_buildManifest.js b/litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_buildManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_buildManifest.js rename to litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_buildManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_clientMiddlewareManifest.json b/litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_clientMiddlewareManifest.json similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_clientMiddlewareManifest.json rename to litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_clientMiddlewareManifest.json diff --git a/litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_ssgManifest.js b/litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_ssgManifest.js similarity index 100% rename from litellm/proxy/_experimental/out/_next/static/zxkD4-EPlgfKHDTw8O869/_ssgManifest.js rename to litellm/proxy/_experimental/out/_next/static/8TZ2JbOi7SZ6BCj9ScTHW/_ssgManifest.js diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0377ae18aae60c57.js b/litellm/proxy/_experimental/out/_next/static/chunks/0377ae18aae60c57.js new file mode 100644 index 0000000000..66e4d15294 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0377ae18aae60c57.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,362133,457202,439061,182399,234779,374615,330995,592143,372943,899268,87316,655900,299023,25652,882293,e=>{"use strict";e.i(247167);var t=e.i(931067),a=e.i(271645);let s={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M908 640H804V488c0-4.4-3.6-8-8-8H548v-96h108c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16H368c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h108v96H228c-4.4 0-8 3.6-8 8v152H116c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16H292v-88h440v88H620c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h288c8.8 0 16-7.2 16-16V656c0-8.8-7.2-16-16-16zm-564 76v168H176V716h168zm84-408V140h168v168H428zm420 576H680V716h168v168z"}}]},name:"apartment",theme:"outlined"};var l=e.i(9583),r=a.forwardRef(function(e,r){return a.createElement(l.default,(0,t.default)({},e,{ref:r,icon:s}))});e.s(["ApartmentOutlined",0,r],362133);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M296 250c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H296zm184 144H296c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zm-48 458H208V148h560v320c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V108c0-17.7-14.3-32-32-32H168c-17.7 0-32 14.3-32 32v784c0 17.7 14.3 32 32 32h264c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm440-88H728v-36.6c46.3-13.8 80-56.6 80-107.4 0-61.9-50.1-112-112-112s-112 50.1-112 112c0 50.7 33.7 93.6 80 107.4V764H520c-8.8 0-16 7.2-16 16v152c0 8.8 7.2 16 16 16h352c8.8 0 16-7.2 16-16V780c0-8.8-7.2-16-16-16zM646 620c0-27.6 22.4-50 50-50s50 22.4 50 50-22.4 50-50 50-50-22.4-50-50zm180 266H566v-60h260v60z"}}]},name:"audit",theme:"outlined"};var n=a.forwardRef(function(e,s){return a.createElement(l.default,(0,t.default)({},e,{ref:s,icon:i}))});e.s(["AuditOutlined",0,n],457202);let o={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M766.4 744.3c43.7 0 79.4-36.2 79.4-80.5 0-53.5-79.4-140.8-79.4-140.8S687 610.3 687 663.8c0 44.3 35.7 80.5 79.4 80.5zm-377.1-44.1c7.1 7.1 18.6 7.1 25.6 0l256.1-256c7.1-7.1 7.1-18.6 0-25.6l-256-256c-.6-.6-1.3-1.2-2-1.7l-78.2-78.2a9.11 9.11 0 00-12.8 0l-48 48a9.11 9.11 0 000 12.8l67.2 67.2-207.8 207.9c-7.1 7.1-7.1 18.6 0 25.6l255.9 256zm12.9-448.6l178.9 178.9H223.4l178.8-178.9zM904 816H120c-4.4 0-8 3.6-8 8v80c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-80c0-4.4-3.6-8-8-8z"}}]},name:"bg-colors",theme:"outlined"};var d=a.forwardRef(function(e,s){return a.createElement(l.default,(0,t.default)({},e,{ref:s,icon:o}))});e.s(["BgColorsOutlined",0,d],439061);let c={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M856 376H648V168c0-8.8-7.2-16-16-16H168c-8.8 0-16 7.2-16 16v464c0 8.8 7.2 16 16 16h208v208c0 8.8 7.2 16 16 16h464c8.8 0 16-7.2 16-16V392c0-8.8-7.2-16-16-16zm-480 16v188H220V220h360v156H392c-8.8 0-16 7.2-16 16zm204 52v136H444V444h136zm224 360H444V648h188c8.8 0 16-7.2 16-16V444h156v360z"}}]},name:"block",theme:"outlined"};var m=a.forwardRef(function(e,s){return a.createElement(l.default,(0,t.default)({},e,{ref:s,icon:c}))});e.s(["BlockOutlined",0,m],182399);let u={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-260 72h96v209.9L621.5 312 572 347.4V136zm220 752H232V136h280v296.9c0 3.3 1 6.6 3 9.3a15.9 15.9 0 0022.3 3.7l83.8-59.9 81.4 59.4c2.7 2 6 3.1 9.4 3.1 8.8 0 16-7.2 16-16V136h64v752z"}}]},name:"book",theme:"outlined"};var g=a.forwardRef(function(e,s){return a.createElement(l.default,(0,t.default)({},e,{ref:s,icon:u}))});e.s(["BookOutlined",0,g],234779);let x={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-792 72h752v120H136V232zm752 560H136V440h752v352zm-237-64h165c4.4 0 8-3.6 8-8v-72c0-4.4-3.6-8-8-8H651c-4.4 0-8 3.6-8 8v72c0 4.4 3.6 8 8 8z"}}]},name:"credit-card",theme:"outlined"};var p=a.forwardRef(function(e,s){return a.createElement(l.default,(0,t.default)({},e,{ref:s,icon:x}))});e.s(["CreditCardOutlined",0,p],374615);var h=e.i(366845);e.s(["FolderOutlined",()=>h.default],330995);var f=e.i(609587);e.s(["ConfigProvider",()=>f.default],592143);var y=e.i(8211),b=e.i(343794),v=e.i(529681),j=e.i(242064),N=e.i(704914),k=e.i(876556),w=e.i(290224),O=e.i(251224),_=function(e,t){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&0>t.indexOf(s)&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var l=0,s=Object.getOwnPropertySymbols(e);lt.indexOf(s[l])&&Object.prototype.propertyIsEnumerable.call(e,s[l])&&(a[s[l]]=e[s[l]]);return a};function L({suffixCls:e,tagName:t,displayName:s}){return s=>a.forwardRef((l,r)=>a.createElement(s,Object.assign({ref:r,suffixCls:e,tagName:t},l)))}let C=a.forwardRef((e,t)=>{let{prefixCls:s,suffixCls:l,className:r,tagName:i}=e,n=_(e,["prefixCls","suffixCls","className","tagName"]),{getPrefixCls:o}=a.useContext(j.ConfigContext),d=o("layout",s),[c,m,u]=(0,O.default)(d),g=l?`${d}-${l}`:d;return c(a.createElement(i,Object.assign({className:(0,b.default)(s||g,r,m,u),ref:t},n)))}),S=a.forwardRef((e,t)=>{let{direction:s}=a.useContext(j.ConfigContext),[l,r]=a.useState([]),{prefixCls:i,className:n,rootClassName:o,children:d,hasSider:c,tagName:m,style:u}=e,g=_(e,["prefixCls","className","rootClassName","children","hasSider","tagName","style"]),x=(0,v.default)(g,["suffixCls"]),{getPrefixCls:p,className:h,style:f}=(0,j.useComponentConfig)("layout"),L=p("layout",i),C="boolean"==typeof c?c:!!l.length||(0,k.default)(d).some(e=>e.type===w.default),[S,M,P]=(0,O.default)(L),H=(0,b.default)(L,{[`${L}-has-sider`]:C,[`${L}-rtl`]:"rtl"===s},h,n,o,M,P),z=a.useMemo(()=>({siderHook:{addSider:e=>{r(t=>[].concat((0,y.default)(t),[e]))},removeSider:e=>{r(t=>t.filter(t=>t!==e))}}}),[]);return S(a.createElement(N.LayoutContext.Provider,{value:z},a.createElement(m,Object.assign({ref:t,className:H,style:Object.assign(Object.assign({},f),u)},x),d)))}),M=L({tagName:"div",displayName:"Layout"})(S),P=L({suffixCls:"header",tagName:"header",displayName:"Header"})(C),H=L({suffixCls:"footer",tagName:"footer",displayName:"Footer"})(C),z=L({suffixCls:"content",tagName:"main",displayName:"Content"})(C);M.Header=P,M.Footer=H,M.Content=z,M.Sider=w.default,M._InternalSiderContext=w.SiderContext,e.s(["Layout",0,M],372943);var T=e.i(60699);e.s(["Menu",()=>T.default],899268);var R=e.i(475254);let E=(0,R.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);e.s(["Calendar",()=>E],87316);var U=e.i(399219);e.s(["ChevronUp",()=>U.default],655900);let V=(0,R.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);e.s(["Minus",()=>V],299023);let A=(0,R.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]);e.s(["TrendingUp",()=>A],25652);let B=(0,R.default)("user-check",[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);e.s(["UserCheck",()=>B],882293)},761911,98740,e=>{"use strict";let t=(0,e.i(475254).default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);e.s(["default",()=>t],98740),e.s(["Users",()=>t],761911)},111672,e=>{"use strict";var t=e.i(247167),a=e.i(843476),s=e.i(109799),l=e.i(785242),r=e.i(135214),i=e.i(218129),n=e.i(362133),o=e.i(477189),d=e.i(457202),c=e.i(299251),m=e.i(153702),u=e.i(439061),g=e.i(182399),x=e.i(234779),p=e.i(374615),h=e.i(210612),f=e.i(19732),y=e.i(872934),b=e.i(993914),v=e.i(330995),j=e.i(438957),N=e.i(777579),k=e.i(788191),w=e.i(983561),O=e.i(602073),_=e.i(928685),L=e.i(313603),C=e.i(232164),S=e.i(645526),M=e.i(366308),P=e.i(771674),H=e.i(592143),z=e.i(372943),T=e.i(899268),R=e.i(271645),E=e.i(708347),U=e.i(844444),V=e.i(371401);e.i(389083);var A=e.i(878894),B=e.i(87316);e.i(664659),e.i(655900);var $=e.i(531278),I=e.i(299023),D=e.i(25652),K=e.i(882293),F=e.i(761911),W=e.i(764205);let G=(...e)=>e.filter(Boolean).join(" ");function q({accessToken:e,width:t=220}){let s=(0,V.useDisableUsageIndicator)(),[l,r]=(0,R.useState)(!1),[i,n]=(0,R.useState)(!1),[o,d]=(0,R.useState)(null),[c,m]=(0,R.useState)(null),[u,g]=(0,R.useState)(!1),[x,p]=(0,R.useState)(null);(0,R.useEffect)(()=>{(async()=>{if(e){g(!0),p(null);try{let[t,a]=await Promise.all([(0,W.getRemainingUsers)(e),(0,W.getLicenseInfo)(e).catch(()=>null)]);d(t),m(a)}catch(e){console.error("Failed to fetch usage data:",e),p("Failed to load usage data")}finally{g(!1)}}})()},[e]);let h=c?.expiration_date?(e=>{if(!e)return null;let t=new Date(e+"T00:00:00Z"),a=new Date;return a.setHours(0,0,0,0),Math.ceil((t.getTime()-a.getTime())/864e5)})(c.expiration_date):null,f=null!==h&&h<0,y=null!==h&&h>=0&&h<30,{isOverLimit:b,isNearLimit:v,usagePercentage:j,userMetrics:N,teamMetrics:k}=(e=>{if(!e)return{isOverLimit:!1,isNearLimit:!1,usagePercentage:0,userMetrics:{isOverLimit:!1,isNearLimit:!1,usagePercentage:0},teamMetrics:{isOverLimit:!1,isNearLimit:!1,usagePercentage:0}};let t=e.total_users?e.total_users_used/e.total_users*100:0,a=t>100,s=t>=80&&t<=100,l=e.total_teams?e.total_teams_used/e.total_teams*100:0,r=l>100,i=l>=80&&l<=100,n=a||r;return{isOverLimit:n,isNearLimit:(s||i)&&!n,usagePercentage:Math.max(t,l),userMetrics:{isOverLimit:a,isNearLimit:s,usagePercentage:t},teamMetrics:{isOverLimit:r,isNearLimit:i,usagePercentage:l}}})(o),w=b||v||f||y,O=b||f,_=(v||y)&&!O;return s||!e||o?.total_users===null&&o?.total_teams===null?null:(0,a.jsx)("div",{className:"fixed bottom-4 left-4 z-50",style:{width:`${Math.min(t,220)}px`},children:(0,a.jsx)(()=>i?(0,a.jsx)("button",{onClick:()=>n(!1),className:G("bg-white border border-gray-200 rounded-lg shadow-sm p-3 hover:shadow-md transition-all w-full"),title:"Show usage details",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(F.Users,{className:"h-4 w-4 flex-shrink-0"}),w&&(0,a.jsx)("span",{className:"flex-shrink-0",children:O?(0,a.jsx)(A.AlertTriangle,{className:"h-3 w-3"}):_?(0,a.jsx)(D.TrendingUp,{className:"h-3 w-3"}):null}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium truncate",children:[o&&null!==o.total_users&&(0,a.jsxs)("span",{className:G("flex-shrink-0 px-1.5 py-0.5 rounded text-xs border",N.isOverLimit&&"bg-red-50 text-red-700 border-red-200",N.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!N.isOverLimit&&!N.isNearLimit&&"bg-gray-50 text-gray-700 border-gray-200"),children:["U: ",o.total_users_used,"/",o.total_users]}),o&&null!==o.total_teams&&(0,a.jsxs)("span",{className:G("flex-shrink-0 px-1.5 py-0.5 rounded text-xs border",k.isOverLimit&&"bg-red-50 text-red-700 border-red-200",k.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!k.isOverLimit&&!k.isNearLimit&&"bg-gray-50 text-gray-700 border-gray-200"),children:["T: ",o.total_teams_used,"/",o.total_teams]}),c?.expiration_date&&null!==h&&(0,a.jsx)("span",{className:G("flex-shrink-0 px-1.5 py-0.5 rounded text-xs border",f&&"bg-red-50 text-red-700 border-red-200",y&&"bg-yellow-50 text-yellow-700 border-yellow-200",!f&&!y&&"bg-gray-50 text-gray-700 border-gray-200"),children:h<0?"Exp!":`${h}d`}),!o||null===o.total_users&&null===o.total_teams&&!c&&(0,a.jsx)("span",{className:"truncate",children:"Usage"})]})]})}):u?(0,a.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm p-4 w-full",children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2",children:[(0,a.jsx)($.Loader2,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{className:"text-sm text-gray-500 truncate",children:"Loading..."})]})}):x||!o?(0,a.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg shadow-sm p-4 group w-full",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)("span",{className:"text-sm text-gray-500 truncate block",children:x||"No data"})}),(0,a.jsx)("button",{onClick:()=>n(!0),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-gray-100 rounded transition-all flex-shrink-0",title:"Minimize",children:(0,a.jsx)(I.Minus,{className:"h-3 w-3 text-gray-400"})})]})}):(0,a.jsxs)("div",{className:G("bg-white border rounded-lg shadow-sm p-3 transition-all duration-200 group w-full"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,a.jsx)(F.Users,{className:"h-4 w-4 flex-shrink-0"}),(0,a.jsx)("span",{className:"font-medium text-sm truncate",children:"Usage"})]}),(0,a.jsx)("button",{onClick:()=>n(!0),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-gray-100 rounded transition-all flex-shrink-0",title:"Minimize",children:(0,a.jsx)(I.Minus,{className:"h-3 w-3 text-gray-400"})})]}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[c?.has_license&&c.expiration_date&&(0,a.jsxs)("div",{className:G("space-y-1 border rounded-md p-2",f&&"border-red-200 bg-red-50",y&&"border-yellow-200 bg-yellow-50"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-600 mb-1",children:[(0,a.jsx)(B.Calendar,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"font-medium",children:"License"}),(0,a.jsx)("span",{className:G("ml-1 px-1.5 py-0.5 rounded border",f&&"bg-red-50 text-red-700 border-red-200",y&&"bg-yellow-50 text-yellow-700 border-yellow-200",!f&&!y&&"bg-gray-50 text-gray-600 border-gray-200"),children:f?"Expired":y?"Expiring soon":"OK"})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Status:"}),(0,a.jsx)("span",{className:G("font-medium text-right",f&&"text-red-600",y&&"text-yellow-600"),children:(e=>{if(null===e)return"No expiration";if(e<0)return"Expired";if(0===e)return"Expires today";if(1===e)return"1 day remaining";if(e<30)return`${e} days remaining`;if(e<60)return"1 month remaining";let t=Math.floor(e/30);return`${t} months remaining`})(h)})]}),c.license_type&&(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Type:"}),(0,a.jsx)("span",{className:"font-medium text-right capitalize",children:c.license_type})]})]}),null!==o.total_users&&(0,a.jsxs)("div",{className:G("space-y-1 border rounded-md p-2",N.isOverLimit&&"border-red-200 bg-red-50",N.isNearLimit&&"border-yellow-200 bg-yellow-50"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-600 mb-1",children:[(0,a.jsx)(F.Users,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"font-medium",children:"Users"}),(0,a.jsx)("span",{className:G("ml-1 px-1.5 py-0.5 rounded border",N.isOverLimit&&"bg-red-50 text-red-700 border-red-200",N.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!N.isOverLimit&&!N.isNearLimit&&"bg-gray-50 text-gray-600 border-gray-200"),children:N.isOverLimit?"Over limit":N.isNearLimit?"Near limit":"OK"})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Used:"}),(0,a.jsxs)("span",{className:"font-medium text-right",children:[o.total_users_used,"/",o.total_users]})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Remaining:"}),(0,a.jsx)("span",{className:G("font-medium text-right",N.isOverLimit&&"text-red-600",N.isNearLimit&&"text-yellow-600"),children:o.total_users_remaining})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Usage:"}),(0,a.jsxs)("span",{className:"font-medium text-right",children:[Math.round(N.usagePercentage),"%"]})]}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:G("h-2 rounded-full transition-all duration-300",N.isOverLimit&&"bg-red-500",N.isNearLimit&&"bg-yellow-500",!N.isOverLimit&&!N.isNearLimit&&"bg-green-500"),style:{width:`${Math.min(N.usagePercentage,100)}%`}})})]}),null!==o.total_teams&&(0,a.jsxs)("div",{className:G("space-y-1 border rounded-md p-2",k.isOverLimit&&"border-red-200 bg-red-50",k.isNearLimit&&"border-yellow-200 bg-yellow-50"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-600 mb-1",children:[(0,a.jsx)(K.UserCheck,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"font-medium",children:"Teams"}),(0,a.jsx)("span",{className:G("ml-1 px-1.5 py-0.5 rounded border",k.isOverLimit&&"bg-red-50 text-red-700 border-red-200",k.isNearLimit&&"bg-yellow-50 text-yellow-700 border-yellow-200",!k.isOverLimit&&!k.isNearLimit&&"bg-gray-50 text-gray-600 border-gray-200"),children:k.isOverLimit?"Over limit":k.isNearLimit?"Near limit":"OK"})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Used:"}),(0,a.jsxs)("span",{className:"font-medium text-right",children:[o.total_teams_used,"/",o.total_teams]})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Remaining:"}),(0,a.jsx)("span",{className:G("font-medium text-right",k.isOverLimit&&"text-red-600",k.isNearLimit&&"text-yellow-600"),children:o.total_teams_remaining})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-gray-600 text-xs",children:"Usage:"}),(0,a.jsxs)("span",{className:"font-medium text-right",children:[Math.round(k.usagePercentage),"%"]})]}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:G("h-2 rounded-full transition-all duration-300",k.isOverLimit&&"bg-red-500",k.isNearLimit&&"bg-yellow-500",!k.isOverLimit&&!k.isNearLimit&&"bg-green-500"),style:{width:`${Math.min(k.usagePercentage,100)}%`}})})]})]})]}),{})})}let{Sider:Y}=z.Layout,X={"api-reference":"api-reference"},Z=[{groupLabel:"AI GATEWAY",items:[{key:"api-keys",page:"api-keys",label:"Virtual Keys",icon:(0,a.jsx)(j.KeyOutlined,{})},{key:"llm-playground",page:"llm-playground",label:"Playground",icon:(0,a.jsx)(k.PlayCircleOutlined,{}),roles:E.rolesWithWriteAccess},{key:"models",page:"models",label:"Models + Endpoints",icon:(0,a.jsx)(g.BlockOutlined,{}),roles:E.rolesAllowedToViewWriteScopedPages},{key:"agentic",page:"agentic",label:"Agentic",icon:(0,a.jsx)(w.RobotOutlined,{}),children:[{key:"agents",page:"agents",label:"Agents",icon:(0,a.jsx)(w.RobotOutlined,{}),roles:E.rolesAllowedToViewWriteScopedPages},{key:"workflows",page:"workflows",label:"Workflow Runs",icon:(0,a.jsx)(n.ApartmentOutlined,{})},{key:"memory",page:"memory",label:"Memory",icon:(0,a.jsx)(x.BookOutlined,{})}]},{key:"mcp-servers",page:"mcp-servers",label:"MCP Servers",icon:(0,a.jsx)(M.ToolOutlined,{})},{key:"skills",page:"skills",label:"Skills",icon:(0,a.jsx)(i.ApiOutlined,{}),roles:E.all_admin_roles},{key:"guardrails",page:"guardrails",label:"Guardrails",icon:(0,a.jsx)(O.SafetyOutlined,{})},{key:"policies",page:"policies",label:(0,a.jsx)("span",{className:"flex items-center gap-4",children:"Policies"}),icon:(0,a.jsx)(d.AuditOutlined,{}),roles:E.all_admin_roles},{key:"tools",page:"tools",label:"Tools",icon:(0,a.jsx)(M.ToolOutlined,{}),children:[{key:"search-tools",page:"search-tools",label:"Search Tools",icon:(0,a.jsx)(_.SearchOutlined,{})},{key:"vector-stores",page:"vector-stores",label:"Vector Stores",icon:(0,a.jsx)(h.DatabaseOutlined,{})},{key:"tool-policies",page:"tool-policies",label:"Tool Policies",icon:(0,a.jsx)(O.SafetyOutlined,{})}]}]},{groupLabel:"OBSERVABILITY",items:[{key:"new_usage",page:"new_usage",icon:(0,a.jsx)(m.BarChartOutlined,{}),roles:[...E.all_admin_roles,...E.internalUserRoles],label:"Usage"},{key:"logs",page:"logs",label:"Logs",icon:(0,a.jsx)(N.LineChartOutlined,{})},{key:"guardrails-monitor",page:"guardrails-monitor",label:"Guardrails Monitor",icon:(0,a.jsx)(O.SafetyOutlined,{}),roles:[...E.all_admin_roles,...E.internalUserRoles]}]},{groupLabel:"ACCESS CONTROL",items:[{key:"teams",page:"teams",label:"Teams",icon:(0,a.jsx)(S.TeamOutlined,{})},{key:"projects",page:"projects",label:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:["Projects ",(0,a.jsx)(U.default,{})]}),icon:(0,a.jsx)(v.FolderOutlined,{}),roles:E.all_admin_roles},{key:"users",page:"users",label:"Internal Users",icon:(0,a.jsx)(P.UserOutlined,{}),roles:E.all_admin_roles},{key:"organizations",page:"organizations",label:"Organizations",icon:(0,a.jsx)(c.BankOutlined,{}),roles:E.all_admin_roles},{key:"access-groups",page:"access-groups",label:"Access Groups",icon:(0,a.jsx)(g.BlockOutlined,{}),roles:E.all_admin_roles},{key:"budgets",page:"budgets",label:"Budgets",icon:(0,a.jsx)(p.CreditCardOutlined,{}),roles:E.all_admin_roles}]},{groupLabel:"DEVELOPER TOOLS",items:[{key:"api-reference",page:"api-reference",label:"API Reference",icon:(0,a.jsx)(i.ApiOutlined,{})},{key:"model-hub-table",page:"model-hub-table",label:"AI Hub",icon:(0,a.jsx)(o.AppstoreOutlined,{})},{key:"learning-resources",page:"learning-resources",label:"Learning Resources",icon:(0,a.jsx)(x.BookOutlined,{}),external_url:"https://models.litellm.ai/cookbook"},{key:"experimental",page:"experimental",label:"Experimental",icon:(0,a.jsx)(f.ExperimentOutlined,{}),children:[{key:"caching",page:"caching",label:"Caching",icon:(0,a.jsx)(h.DatabaseOutlined,{}),roles:E.all_admin_roles},{key:"prompts",page:"prompts",label:"Prompts",icon:(0,a.jsx)(b.FileTextOutlined,{}),roles:E.all_admin_roles},{key:"transform-request",page:"transform-request",label:"API Playground",icon:(0,a.jsx)(i.ApiOutlined,{}),roles:[...E.all_admin_roles,...E.internalUserRoles]},{key:"tag-management",page:"tag-management",label:"Tag Management",icon:(0,a.jsx)(C.TagsOutlined,{}),roles:E.all_admin_roles},{key:"4",page:"usage",label:"Old Usage",icon:(0,a.jsx)(m.BarChartOutlined,{})}]}]},{groupLabel:"SETTINGS",roles:E.all_admin_roles,items:[{key:"settings",page:"settings",label:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:["Settings ",(0,a.jsx)(U.default,{})]}),icon:(0,a.jsx)(L.SettingOutlined,{}),roles:E.all_admin_roles,children:[{key:"router-settings",page:"router-settings",label:"Router Settings",icon:(0,a.jsx)(L.SettingOutlined,{}),roles:E.all_admin_roles},{key:"logging-and-alerts",page:"logging-and-alerts",label:"Logging & Alerts",icon:(0,a.jsx)(L.SettingOutlined,{}),roles:E.all_admin_roles},{key:"admin-panel",page:"admin-panel",label:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:["Admin Settings ",(0,a.jsx)(U.default,{dot:!0,children:(0,a.jsx)("span",{})})]}),icon:(0,a.jsx)(L.SettingOutlined,{}),roles:E.all_admin_roles},{key:"cost-tracking",page:"cost-tracking",label:"Cost Tracking",icon:(0,a.jsx)(m.BarChartOutlined,{}),roles:E.all_admin_roles},{key:"ui-theme",page:"ui-theme",label:"UI Theme",icon:(0,a.jsx)(u.BgColorsOutlined,{}),roles:E.all_admin_roles}]}]}];e.s(["default",0,({setPage:e,defaultSelectedKey:i,collapsed:n=!1,enabledPagesInternalUsers:o,enableProjectsUI:d,disableAgentsForInternalUsers:c,allowAgentsForTeamAdmins:m,disableVectorStoresForInternalUsers:u,allowVectorStoresForTeamAdmins:g})=>{let x,{userId:p,accessToken:h,userRole:f}=(0,r.default)(),{data:b}=(0,s.useOrganizations)(),{data:v}=(0,l.useTeams)(),j=(0,R.useMemo)(()=>!!p&&!!b&&b.some(e=>e.members?.some(e=>e.user_id===p&&"org_admin"===e.user_role)),[p,b]),N=(0,R.useMemo)(()=>(0,E.isUserTeamAdminForAnyTeam)(v??null,p??""),[v,p]),k=t=>{if(X[t])return void e(t);let a=new URLSearchParams(window.location.search);a.set("page",t),window.history.pushState(null,"",`?${a.toString()}`),e(t)},w=(e,s,l)=>{let r;if(l)return(0,a.jsxs)("a",{href:l,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),style:{color:"inherit",textDecoration:"none"},children:[e," ",(0,a.jsx)(y.ExportOutlined,{style:{fontSize:10,marginLeft:4}})]});let i=X[s],n=i?function(e){let a=(t.default.env.NEXT_PUBLIC_BASE_URL??"").replace(/^\/+|\/+$/g,""),s=a?`/${a}/`:"/";if(W.serverRootPath&&"/"!==W.serverRootPath){let e=W.serverRootPath.replace(/\/+$/,""),t=s.replace(/^\/+/,"");s=`${e}/${t}`}return`${s}${e}`}(i):((r=new URLSearchParams(window.location.search)).set("page",s),`?${r.toString()}`);return(0,a.jsx)("a",{href:n,onClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||1===e.button?e.stopPropagation():e.preventDefault()},style:{color:"inherit",textDecoration:"none"},children:e})},O=e=>{let t=(0,E.isAdminRole)(f);return null!=o&&console.log("[LeftNav] Filtering with enabled pages:",{userRole:f,isAdmin:t,enabledPagesInternalUsers:o}),e.map(e=>({...e,children:e.children?O(e.children):void 0})).filter(e=>{if("organizations"===e.key||"users"===e.key){if(!(!e.roles||e.roles.includes(f)||j))return!1;if(!t&&null!=o){let t=o.includes(e.page);return console.log(`[LeftNav] Page "${e.page}" (${e.key}): ${t?"VISIBLE":"HIDDEN"}`),t}return!0}if("projects"===e.key&&!d||!t&&"agents"===e.key&&c&&!(m&&N)||!t&&"vector-stores"===e.key&&u&&!(g&&N)||e.roles&&!e.roles.includes(f))return!1;if(!t&&null!=o){if(e.children&&e.children.length>0&&e.children.some(e=>o.includes(e.page)))return console.log(`[LeftNav] Parent "${e.page}" (${e.key}): VISIBLE (has visible children)`),!0;let t=o.includes(e.page);return console.log(`[LeftNav] Page "${e.page}" (${e.key}): ${t?"VISIBLE":"HIDDEN"}`),t}return!0})},_=(e=>{for(let t of Z)for(let a of t.items){if(a.page===e)return a.key;if(a.children){let t=a.children.find(t=>t.page===e);if(t)return t.key}}return"api-keys"})(i);return(0,a.jsx)(z.Layout,{children:(0,a.jsxs)(Y,{theme:"light",width:220,collapsed:n,collapsedWidth:80,collapsible:!0,trigger:null,style:{transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",position:"relative"},children:[(0,a.jsx)(H.ConfigProvider,{theme:{components:{Menu:{iconSize:15,fontSize:13,itemMarginInline:4,itemPaddingInline:8,itemHeight:30,itemBorderRadius:6,subMenuItemBorderRadius:6,groupTitleFontSize:10,groupTitleLineHeight:1.5}}},children:(0,a.jsx)(T.Menu,{mode:"inline",selectedKeys:[_],defaultOpenKeys:[],inlineCollapsed:n,className:"custom-sidebar-menu",style:{borderRight:0,backgroundColor:"transparent",fontSize:"13px",paddingTop:"4px"},items:(x=[],Z.forEach(e=>{if(e.roles&&!e.roles.includes(f))return;let t=O(e.items);0!==t.length&&x.push({type:"group",label:n?null:(0,a.jsx)("span",{style:{fontSize:"10px",fontWeight:600,color:"#6b7280",letterSpacing:"0.05em",padding:"12px 0 4px 12px",display:"block",marginBottom:"2px"},children:e.groupLabel}),children:t.map(e=>({key:e.key,icon:e.icon,label:w(e.label,e.page,e.external_url),children:e.children?.map(e=>({key:e.key,icon:e.icon,label:w(e.label,e.page,e.external_url),onClick:()=>{e.external_url?window.open(e.external_url,"_blank"):k(e.page)}})),onClick:e.children?void 0:()=>{e.external_url?window.open(e.external_url,"_blank"):k(e.page)}}))})}),x)})}),(0,E.isAdminRole)(f)&&!n&&(0,a.jsx)(q,{accessToken:h,width:220})]})})},"menuGroups",()=>Z],111672)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/038e83c8eab81a79.js b/litellm/proxy/_experimental/out/_next/static/chunks/038e83c8eab81a79.js deleted file mode 100644 index a0f95ffb2b..0000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/038e83c8eab81a79.js +++ /dev/null @@ -1,84 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,185357,180766,782719,969641,476993,824296,64352,230312,e=>{"use strict";var t,a,l=e.i(843476),r=e.i(808613),i=e.i(311451),s=e.i(212931),n=e.i(199133),o=e.i(262218),d=e.i(898586),c=e.i(464571),m=e.i(271645),u=e.i(727749),p=e.i(764205),g=e.i(770914),x=e.i(515831),h=e.i(175712),f=e.i(646563),y=e.i(519756);let{Text:j}=d.Typography,{Option:_}=n.Select,b=({visible:e,prebuiltPatterns:t,categories:a,selectedPatternName:r,patternAction:i,onPatternNameChange:o,onActionChange:d,onAdd:m,onCancel:u})=>(0,l.jsxs)(s.Modal,{title:"Add prebuilt pattern",open:e,onCancel:u,footer:null,width:800,children:[(0,l.jsxs)(g.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(j,{strong:!0,children:"Pattern type"}),(0,l.jsx)(n.Select,{placeholder:"Choose pattern type",value:r,onChange:o,style:{width:"100%",marginTop:8},showSearch:!0,filterOption:(e,a)=>{let l=t.find(e=>e.name===a?.value);return!!l&&(l.display_name.toLowerCase().includes(e.toLowerCase())||l.name.toLowerCase().includes(e.toLowerCase()))},children:a.map(e=>{let a=t.filter(t=>t.category===e);return 0===a.length?null:(0,l.jsx)(n.Select.OptGroup,{label:e,children:a.map(e=>(0,l.jsx)(_,{value:e.name,children:e.display_name},e.name))},e)})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(j,{strong:!0,children:"Action"}),(0,l.jsx)(j,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this pattern is detected"}),(0,l.jsxs)(n.Select,{value:i,onChange:d,style:{width:"100%"},children:[(0,l.jsx)(_,{value:"BLOCK",children:"Block"}),(0,l.jsx)(_,{value:"MASK",children:"Mask"})]})]})]}),(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,l.jsx)(c.Button,{onClick:u,children:"Cancel"}),(0,l.jsx)(c.Button,{type:"primary",onClick:m,children:"Add"})]})]}),{Text:v}=d.Typography,{Option:w}=n.Select,N=({visible:e,patternName:t,patternRegex:a,patternAction:r,onNameChange:o,onRegexChange:d,onActionChange:m,onAdd:u,onCancel:p})=>(0,l.jsxs)(s.Modal,{title:"Add custom regex pattern",open:e,onCancel:p,footer:null,width:800,children:[(0,l.jsxs)(g.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(v,{strong:!0,children:"Pattern name"}),(0,l.jsx)(i.Input,{placeholder:"e.g., internal_id, employee_code",value:t,onChange:e=>o(e.target.value),style:{marginTop:8}})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(v,{strong:!0,children:"Regex pattern"}),(0,l.jsx)(i.Input,{placeholder:"e.g., ID-[0-9]{6}",value:a,onChange:e=>d(e.target.value),style:{marginTop:8}}),(0,l.jsx)(v,{type:"secondary",style:{fontSize:12},children:"Enter a valid regular expression to match sensitive data"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(v,{strong:!0,children:"Action"}),(0,l.jsx)(v,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this pattern is detected"}),(0,l.jsxs)(n.Select,{value:r,onChange:m,style:{width:"100%"},children:[(0,l.jsx)(w,{value:"BLOCK",children:"Block"}),(0,l.jsx)(w,{value:"MASK",children:"Mask"})]})]})]}),(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,l.jsx)(c.Button,{onClick:p,children:"Cancel"}),(0,l.jsx)(c.Button,{type:"primary",onClick:u,children:"Add"})]})]}),{Text:C}=d.Typography,{Option:S}=n.Select,k=({visible:e,keyword:t,action:a,description:r,onKeywordChange:o,onActionChange:d,onDescriptionChange:m,onAdd:u,onCancel:p})=>(0,l.jsxs)(s.Modal,{title:"Add blocked keyword",open:e,onCancel:p,footer:null,width:800,children:[(0,l.jsxs)(g.Space,{direction:"vertical",style:{width:"100%"},size:"large",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(C,{strong:!0,children:"Keyword"}),(0,l.jsx)(i.Input,{placeholder:"Enter sensitive keyword or phrase",value:t,onChange:e=>o(e.target.value),style:{marginTop:8}})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(C,{strong:!0,children:"Action"}),(0,l.jsx)(C,{type:"secondary",style:{display:"block",marginTop:4,marginBottom:8},children:"Choose what action the guardrail should take when this keyword is detected"}),(0,l.jsxs)(n.Select,{value:a,onChange:d,style:{width:"100%"},children:[(0,l.jsx)(S,{value:"BLOCK",children:"Block"}),(0,l.jsx)(S,{value:"MASK",children:"Mask"})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(C,{strong:!0,children:"Description (optional)"}),(0,l.jsx)(i.Input.TextArea,{placeholder:"Explain why this keyword is sensitive",value:r,onChange:e=>m(e.target.value),rows:3,style:{marginTop:8}})]})]}),(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"24px"},children:[(0,l.jsx)(c.Button,{onClick:p,children:"Cancel"}),(0,l.jsx)(c.Button,{type:"primary",onClick:u,children:"Add"})]})]});var I=e.i(291542),A=e.i(955135);let{Text:O}=d.Typography,{Option:T}=n.Select,P=({patterns:e,onActionChange:t,onRemove:a})=>{let r=[{title:"Type",dataIndex:"type",key:"type",width:100,render:e=>(0,l.jsx)(o.Tag,{color:"prebuilt"===e?"blue":"green",children:"prebuilt"===e?"Prebuilt":"Custom"})},{title:"Pattern name",dataIndex:"name",key:"name",render:(e,t)=>t.display_name||t.name},{title:"Regex pattern",dataIndex:"pattern",key:"pattern",render:e=>e?(0,l.jsxs)(O,{code:!0,style:{fontSize:12},children:[e.substring(0,40),"..."]}):"-"},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,a)=>(0,l.jsxs)(n.Select,{value:e,onChange:e=>t(a.id,e),style:{width:120},size:"small",children:[(0,l.jsx)(T,{value:"BLOCK",children:"Block"}),(0,l.jsx)(T,{value:"MASK",children:"Mask"})]})},{title:"",key:"actions",width:100,render:(e,t)=>(0,l.jsx)(c.Button,{type:"text",danger:!0,size:"small",icon:(0,l.jsx)(A.DeleteOutlined,{}),onClick:()=>a(t.id),children:"Delete"})}];return 0===e.length?(0,l.jsx)("div",{style:{textAlign:"center",padding:"40px 0",color:"#999"},children:"No patterns added."}):(0,l.jsx)(I.Table,{dataSource:e,columns:r,rowKey:"id",pagination:!1,size:"small"})},{Text:L}=d.Typography,{Option:B}=n.Select,F=({keywords:e,onActionChange:t,onRemove:a})=>{let r=[{title:"Keyword",dataIndex:"keyword",key:"keyword"},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,a)=>(0,l.jsxs)(n.Select,{value:e,onChange:e=>t(a.id,"action",e),style:{width:120},size:"small",children:[(0,l.jsx)(B,{value:"BLOCK",children:"Block"}),(0,l.jsx)(B,{value:"MASK",children:"Mask"})]})},{title:"Description",dataIndex:"description",key:"description",render:e=>e||"-"},{title:"",key:"actions",width:100,render:(e,t)=>(0,l.jsx)(c.Button,{type:"text",danger:!0,size:"small",icon:(0,l.jsx)(A.DeleteOutlined,{}),onClick:()=>a(t.id),children:"Delete"})}];return 0===e.length?(0,l.jsx)("div",{style:{textAlign:"center",padding:"40px 0",color:"#999"},children:"No keywords added."}):(0,l.jsx)(I.Table,{dataSource:e,columns:r,rowKey:"id",pagination:!1,size:"small"})};var $=e.i(362024),E=e.i(993914);let{Title:M,Text:R}=d.Typography,{Option:G}=n.Select,z=({availableCategories:e,selectedCategories:t,onCategoryAdd:a,onCategoryRemove:r,onCategoryUpdate:i,accessToken:s,pendingSelection:d,onPendingSelectionChange:u})=>{let[g,x]=m.default.useState(""),y=void 0!==d?d:g,j=u||x,[_,b]=m.default.useState({}),[v,w]=m.default.useState({}),[N,C]=m.default.useState({}),[S,k]=m.default.useState([]),[O,T]=m.default.useState(""),[P,L]=m.default.useState(!1),B=async e=>{if(s&&!_[e]){C(t=>({...t,[e]:!0}));try{let t=await (0,p.getCategoryYaml)(s,e),a=t.yaml_content;if("json"===t.file_type)try{let e=JSON.parse(a);a=JSON.stringify(e,null,2)}catch(t){console.warn(`Failed to format JSON for ${e}:`,t)}b(t=>({...t,[e]:a})),w(a=>({...a,[e]:t.file_type||"yaml"}))}catch(t){console.error(`Failed to fetch content for category ${e}:`,t)}finally{C(t=>({...t,[e]:!1}))}}};m.default.useEffect(()=>{if(y&&s){let e=_[y];if(e)return void T(e);L(!0),console.log(`Fetching content for category: ${y}`,{accessToken:s?"present":"missing"}),(0,p.getCategoryYaml)(s,y).then(e=>{console.log(`Successfully fetched content for ${y}:`,e);let t=e.yaml_content;if("json"===e.file_type)try{let e=JSON.parse(t);t=JSON.stringify(e,null,2)}catch(e){console.warn(`Failed to format JSON for ${y}:`,e)}T(t),b(e=>({...e,[y]:t})),w(t=>({...t,[y]:e.file_type||"yaml"}))}).catch(e=>{console.error(`Failed to fetch preview content for category ${y}:`,e),T("")}).finally(()=>{L(!1)})}else T(""),L(!1)},[y,s]);let F=[{title:"Category",dataIndex:"display_name",key:"display_name",render:(t,a)=>{let r=e.find(e=>e.name===a.category);return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{style:{fontWeight:500},children:t}),r?.description&&(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888",marginTop:"4px"},children:r.description})]})}},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,t)=>(0,l.jsxs)(n.Select,{value:e,onChange:e=>i(t.id,"action",e),style:{width:"100%"},children:[(0,l.jsx)(G,{value:"BLOCK",children:(0,l.jsx)(o.Tag,{color:"red",children:"BLOCK"})}),(0,l.jsx)(G,{value:"MASK",children:(0,l.jsx)(o.Tag,{color:"orange",children:"MASK"})})]})},{title:"Severity Threshold",dataIndex:"severity_threshold",key:"severity_threshold",width:180,render:(e,t)=>(0,l.jsxs)(n.Select,{value:e,onChange:e=>i(t.id,"severity_threshold",e),style:{width:"100%"},children:[(0,l.jsx)(G,{value:"low",children:"Low"}),(0,l.jsx)(G,{value:"medium",children:"Medium"}),(0,l.jsx)(G,{value:"high",children:"High"})]})},{title:"",key:"actions",width:80,render:(e,t)=>(0,l.jsx)(c.Button,{icon:(0,l.jsx)(A.DeleteOutlined,{}),onClick:()=>r(t.id),size:"small",children:"Remove"})}],z=e.filter(e=>!t.some(t=>t.category===e.name));return(0,l.jsxs)(h.Card,{title:(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:8},children:[(0,l.jsx)(M,{level:5,style:{margin:0},children:"Blocked topics"}),(0,l.jsx)(R,{type:"secondary",style:{fontSize:12,fontWeight:400},children:"Select topics to block using keyword and semantic analysis"})]}),size:"small",children:[(0,l.jsxs)("div",{style:{marginBottom:16,display:"flex",gap:8},children:[(0,l.jsx)(n.Select,{placeholder:"Select a content category",value:y||void 0,onChange:j,style:{flex:1},showSearch:!0,optionLabelProp:"label",filterOption:(e,t)=>(t?.label?.toString().toLowerCase()??"").includes(e.toLowerCase()),children:z.map(e=>(0,l.jsx)(G,{value:e.name,label:e.display_name,children:(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{style:{fontWeight:500},children:e.display_name}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#666",marginTop:"2px"},children:e.description})]})},e.name))}),(0,l.jsx)(c.Button,{type:"primary",onClick:()=>{if(!y)return;let l=e.find(e=>e.name===y);!l||t.some(e=>e.category===y)||(a({id:`category-${Date.now()}`,category:l.name,display_name:l.display_name,action:l.default_action,severity_threshold:"medium"}),j(""),T(""))},disabled:!y,icon:(0,l.jsx)(f.PlusOutlined,{}),children:"Add"})]}),y&&(0,l.jsxs)("div",{style:{marginBottom:16,padding:"12px",background:"#f9f9f9",border:"1px solid #e0e0e0",borderRadius:"4px"},children:[(0,l.jsxs)("div",{style:{marginBottom:8,fontWeight:500,fontSize:"14px"},children:["Preview: ",e.find(e=>e.name===y)?.display_name,v[y]&&(0,l.jsxs)("span",{style:{marginLeft:8,fontSize:"12px",color:"#888",fontWeight:400},children:["(",v[y]?.toUpperCase(),")"]})]}),P?(0,l.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"Loading content..."}):O?(0,l.jsx)("pre",{style:{background:"#fff",padding:"12px",borderRadius:"4px",overflow:"auto",maxHeight:"300px",maxWidth:"100%",fontSize:"12px",lineHeight:"1.5",margin:0,border:"1px solid #e0e0e0",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(0,l.jsx)("code",{children:O})}):(0,l.jsx)("div",{style:{padding:"8px",textAlign:"center",color:"#888",fontSize:"12px"},children:"Unable to load category content"})]}),t.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(I.Table,{dataSource:t,columns:F,pagination:!1,size:"small",rowKey:"id"}),(0,l.jsx)("div",{style:{marginTop:16},children:(0,l.jsx)($.Collapse,{activeKey:S,onChange:e=>{let t=Array.isArray(e)?e:e?[e]:[],a=new Set(S);t.forEach(e=>{a.has(e)||_[e]||B(e)}),k(t)},ghost:!0,items:t.map(e=>{let t=(v[e.category]||"yaml").toUpperCase();return{key:e.category,label:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,l.jsx)(E.FileTextOutlined,{}),(0,l.jsxs)("span",{children:["View ",t," for ",e.display_name]})]}),children:N[e.category]?(0,l.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"Loading content..."}):_[e.category]?(0,l.jsx)("pre",{style:{background:"#f5f5f5",padding:"16px",borderRadius:"4px",overflow:"auto",maxHeight:"400px",fontSize:"12px",lineHeight:"1.5",margin:0},children:(0,l.jsx)("code",{children:_[e.category]})}):(0,l.jsx)("div",{style:{padding:"16px",textAlign:"center",color:"#888"},children:"Content will load when expanded"})}})})})]}):(0,l.jsx)("div",{style:{textAlign:"center",padding:"24px",color:"#888",border:"1px dashed #d9d9d9",borderRadius:"4px"},children:"No blocked topics selected. Add topics to detect and block harmful content."})]})};var D=e.i(790848),K=e.i(28651);let{Title:H,Text:q}=d.Typography,{Option:J}=n.Select,U={competitor_intent_type:"airline",brand_self:[],locations:[],policy:{competitor_comparison:"refuse",possible_competitor_comparison:"reframe"},threshold_high:.7,threshold_medium:.45,threshold_low:.3},W=({enabled:e,config:t,onChange:a,accessToken:i})=>{let s=t??U,[o,d]=(0,m.useState)([]),[c,u]=(0,m.useState)(!1);(0,m.useEffect)(()=>{"airline"===s.competitor_intent_type&&i&&0===o.length&&(u(!0),(0,p.getMajorAirlines)(i).then(e=>d(e.airlines??[])).catch(()=>d([])).finally(()=>u(!1)))},[s.competitor_intent_type,i,o.length]);let x=e=>{a(e,e?{...U}:null)},f=(t,l)=>{a(e,{...s,[t]:l})},y=(t,l)=>{a(e,{...s,policy:{...s.policy,[t]:l}})},j=(t,l)=>{a(e,{...s,[t]:l.filter(Boolean)})};return e?(0,l.jsxs)(h.Card,{title:(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,l.jsx)(H,{level:5,style:{margin:0},children:"Competitor Intent Filter"}),(0,l.jsx)(D.Switch,{checked:e,onChange:x})]}),size:"small",children:[(0,l.jsx)(q,{type:"secondary",style:{display:"block",marginBottom:16},children:"Block or reframe competitor comparison questions. Airline type uses major airlines (excluding your brand); generic requires manual competitor list."}),(0,l.jsxs)(r.Form,{layout:"vertical",size:"small",children:[(0,l.jsx)(r.Form.Item,{label:"Type",children:(0,l.jsxs)(n.Select,{value:s.competitor_intent_type,onChange:e=>f("competitor_intent_type",e),style:{width:"100%"},children:[(0,l.jsx)(J,{value:"airline",children:"Airline (auto-load competitors from IATA)"}),(0,l.jsx)(J,{value:"generic",children:"Generic (specify competitors manually)"})]})}),(0,l.jsx)(r.Form.Item,{label:"Your Brand (brand_self)",required:!0,help:"airline"===s.competitor_intent_type?"Select your airline from the list (excluded from competitors) or type to add a custom term":"Names/codes users use for your brand",children:(0,l.jsx)(n.Select,{mode:"tags",style:{width:"100%"},placeholder:c?"Loading airlines...":"airline"===s.competitor_intent_type?"Search or select airline, or type to add custom":"Type and press Enter to add",value:s.brand_self,onChange:t=>"airline"===s.competitor_intent_type&&o.length>0?(t=>{let l=t.filter(Boolean),r=[],i=new Set;for(let e of l){let t=o.find(t=>t.match.split("|")[0]?.trim().toLowerCase()===e.toLowerCase());if(t)for(let e of t.match.split("|").map(e=>e.trim().toLowerCase()).filter(Boolean))i.has(e)||(i.add(e),r.push(e));else i.has(e.toLowerCase())||(i.add(e.toLowerCase()),r.push(e))}a(e,{...s,brand_self:r})})(t??[]):j("brand_self",t??[]),tokenSeparators:[","],loading:c,showSearch:!0,filterOption:(e,t)=>(t?.label?.toString().toLowerCase()??"").includes(e.toLowerCase()),optionFilterProp:"label",options:"airline"===s.competitor_intent_type&&o.length>0?o.map(e=>{let t=e.match.split("|")[0]?.trim()??e.id,a=e.match.split("|").map(e=>e.trim().toLowerCase()).filter(Boolean);return{value:t.toLowerCase(),label:`${t}${a.length>1?` (${a.slice(1).join(", ")})`:""}`}}):void 0})}),"airline"===s.competitor_intent_type&&(0,l.jsx)(r.Form.Item,{label:"Locations (optional)",help:"Countries, cities, airports for disambiguation (e.g. qatar, doha)",children:(0,l.jsx)(n.Select,{mode:"tags",style:{width:"100%"},placeholder:"Type and press Enter to add",value:s.locations??[],onChange:e=>j("locations",e??[]),tokenSeparators:[","]})}),"generic"===s.competitor_intent_type&&(0,l.jsx)(r.Form.Item,{label:"Competitors",required:!0,help:"Competitor names to detect (required for generic type)",children:(0,l.jsx)(n.Select,{mode:"tags",style:{width:"100%"},placeholder:"Type and press Enter to add",value:s.competitors??[],onChange:e=>j("competitors",e??[]),tokenSeparators:[","]})}),(0,l.jsx)(r.Form.Item,{label:"Policy: Competitor comparison",children:(0,l.jsxs)(n.Select,{value:s.policy?.competitor_comparison??"refuse",onChange:e=>y("competitor_comparison",e),style:{width:"100%"},children:[(0,l.jsx)(J,{value:"refuse",children:"Refuse (block request)"}),(0,l.jsx)(J,{value:"reframe",children:"Reframe (suggest alternative)"})]})}),(0,l.jsx)(r.Form.Item,{label:"Policy: Possible competitor comparison",children:(0,l.jsxs)(n.Select,{value:s.policy?.possible_competitor_comparison??"reframe",onChange:e=>y("possible_competitor_comparison",e),style:{width:"100%"},children:[(0,l.jsx)(J,{value:"refuse",children:"Refuse (block request)"}),(0,l.jsx)(J,{value:"reframe",children:"Reframe (suggest alternative to backend LLM)"})]})}),(0,l.jsx)(r.Form.Item,{label:"Confidence thresholds",help:(0,l.jsxs)(l.Fragment,{children:["Classify competitor intent by confidence (0–1). Higher confidence → stronger intent.",(0,l.jsxs)("ul",{style:{marginBottom:0,marginTop:4,paddingLeft:20},children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("strong",{children:"High (≥)"}),': Treat as full competitor comparison → uses "Competitor comparison" policy']}),(0,l.jsxs)("li",{children:[(0,l.jsx)("strong",{children:"Medium (≥)"}),': Treat as possible comparison → uses "Possible competitor comparison" policy']}),(0,l.jsxs)("li",{children:[(0,l.jsx)("strong",{children:"Low (≥)"}),": Log only; allow request. Below Low → allow with no action"]})]}),"Raise thresholds to be more permissive; lower them to be stricter."]}),children:(0,l.jsxs)(g.Space,{wrap:!0,children:[(0,l.jsx)(r.Form.Item,{label:"High",style:{marginBottom:0},help:"e.g. 0.7",children:(0,l.jsx)(K.InputNumber,{min:0,max:1,step:.05,value:s.threshold_high??.7,onChange:e=>f("threshold_high",e??.7),style:{width:80}})}),(0,l.jsx)(r.Form.Item,{label:"Medium",style:{marginBottom:0},help:"e.g. 0.45",children:(0,l.jsx)(K.InputNumber,{min:0,max:1,step:.05,value:s.threshold_medium??.45,onChange:e=>f("threshold_medium",e??.45),style:{width:80}})}),(0,l.jsx)(r.Form.Item,{label:"Low",style:{marginBottom:0},help:"e.g. 0.3",children:(0,l.jsx)(K.InputNumber,{min:0,max:1,step:.05,value:s.threshold_low??.3,onChange:e=>f("threshold_low",e??.3),style:{width:80}})})]})})]})]}):(0,l.jsx)(h.Card,{title:(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,l.jsx)(H,{level:5,style:{margin:0},children:"Competitor Intent Filter"}),(0,l.jsx)(D.Switch,{checked:!1,onChange:x})]}),size:"small",children:(0,l.jsx)(q,{type:"secondary",children:"Block or reframe competitor comparison questions. When enabled, airline type auto-loads competitors from IATA; generic type requires manual competitor list."})})},{Title:V,Text:Y}=d.Typography,Q=({prebuiltPatterns:e,categories:t,selectedPatterns:a,blockedWords:r,onPatternAdd:i,onPatternRemove:s,onPatternActionChange:n,onBlockedWordAdd:o,onBlockedWordRemove:d,onBlockedWordUpdate:j,onFileUpload:_,accessToken:v,showStep:w,contentCategories:C=[],selectedContentCategories:S=[],onContentCategoryAdd:I,onContentCategoryRemove:A,onContentCategoryUpdate:O,pendingCategorySelection:T,onPendingCategorySelectionChange:L,competitorIntentEnabled:B=!1,competitorIntentConfig:$=null,onCompetitorIntentChange:E})=>{let[M,R]=(0,m.useState)(!1),[G,D]=(0,m.useState)(!1),[K,H]=(0,m.useState)(!1),[q,J]=(0,m.useState)(""),[U,Q]=(0,m.useState)("BLOCK"),[Z,X]=(0,m.useState)(""),[ee,et]=(0,m.useState)(""),[ea,el]=(0,m.useState)("BLOCK"),[er,ei]=(0,m.useState)(""),[es,en]=(0,m.useState)("BLOCK"),[eo,ed]=(0,m.useState)(""),[ec,em]=(0,m.useState)(!1),eu=async e=>{em(!0);try{let t=await e.text();if(v){let e=await (0,p.validateBlockedWordsFile)(v,t);if(e.valid)_&&_(t),u.default.success(e.message||"File uploaded successfully");else{let t=e.error||e.errors&&e.errors.join(", ")||"Invalid file";u.default.error(`Validation failed: ${t}`)}}}catch(e){u.default.error(`Failed to upload file: ${e}`)}finally{em(!1)}return!1};return(0,l.jsxs)("div",{className:"space-y-6",children:[!w&&(0,l.jsx)("div",{children:(0,l.jsx)(Y,{type:"secondary",children:"Configure patterns, keywords, and content categories to detect and filter sensitive information in requests and responses."})}),(!w||"patterns"===w)&&(0,l.jsxs)(h.Card,{title:(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,l.jsx)(V,{level:5,style:{margin:0},children:"Pattern Detection"}),(0,l.jsx)(Y,{type:"secondary",style:{fontSize:14,fontWeight:400},children:"Detect sensitive information using regex patterns (SSN, credit cards, API keys, etc.)"})]}),size:"small",children:[(0,l.jsx)("div",{style:{marginBottom:16},children:(0,l.jsxs)(g.Space,{children:[(0,l.jsx)(c.Button,{type:"primary",onClick:()=>R(!0),icon:(0,l.jsx)(f.PlusOutlined,{}),children:"Add prebuilt pattern"}),(0,l.jsx)(c.Button,{onClick:()=>H(!0),icon:(0,l.jsx)(f.PlusOutlined,{}),children:"Add custom regex"})]})}),(0,l.jsx)(P,{patterns:a,onActionChange:n,onRemove:s})]}),(!w||"keywords"===w)&&(0,l.jsxs)(h.Card,{title:(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,l.jsx)(V,{level:5,style:{margin:0},children:"Blocked Keywords"}),(0,l.jsx)(Y,{type:"secondary",style:{fontSize:14,fontWeight:400},children:"Block or mask specific sensitive terms and phrases"})]}),size:"small",children:[(0,l.jsx)("div",{style:{marginBottom:16},children:(0,l.jsxs)(g.Space,{children:[(0,l.jsx)(c.Button,{type:"primary",onClick:()=>D(!0),icon:(0,l.jsx)(f.PlusOutlined,{}),children:"Add keyword"}),(0,l.jsx)(x.Upload,{beforeUpload:eu,accept:".yaml,.yml",showUploadList:!1,children:(0,l.jsx)(c.Button,{icon:(0,l.jsx)(y.UploadOutlined,{}),loading:ec,children:"Upload YAML file"})})]})}),(0,l.jsx)(F,{keywords:r,onActionChange:j,onRemove:d})]}),(!w||"competitor_intent"===w||"categories"===w)&&E&&(0,l.jsx)(W,{enabled:B,config:$,onChange:E,accessToken:v}),(!w||"categories"===w)&&C.length>0&&I&&A&&O&&(0,l.jsx)(z,{availableCategories:C,selectedCategories:S,onCategoryAdd:I,onCategoryRemove:A,onCategoryUpdate:O,accessToken:v,pendingSelection:T,onPendingSelectionChange:L}),(0,l.jsx)(b,{visible:M,prebuiltPatterns:e,categories:t,selectedPatternName:q,patternAction:U,onPatternNameChange:J,onActionChange:e=>Q(e),onAdd:()=>{if(!q)return void u.default.error("Please select a pattern");let t=e.find(e=>e.name===q);i({id:`pattern-${Date.now()}`,type:"prebuilt",name:q,display_name:t?.display_name,action:U}),R(!1),J(""),Q("BLOCK")},onCancel:()=>{R(!1),J(""),Q("BLOCK")}}),(0,l.jsx)(N,{visible:K,patternName:Z,patternRegex:ee,patternAction:ea,onNameChange:X,onRegexChange:et,onActionChange:e=>el(e),onAdd:()=>{Z&&ee?(i({id:`custom-${Date.now()}`,type:"custom",name:Z,pattern:ee,action:ea}),H(!1),X(""),et(""),el("BLOCK")):u.default.error("Please provide pattern name and regex")},onCancel:()=>{H(!1),X(""),et(""),el("BLOCK")}}),(0,l.jsx)(k,{visible:G,keyword:er,action:es,description:eo,onKeywordChange:ei,onActionChange:e=>en(e),onDescriptionChange:ed,onAdd:()=>{er?(o({id:`word-${Date.now()}`,keyword:er,action:es,description:eo||void 0}),D(!1),ei(""),ed(""),en("BLOCK")):u.default.error("Please enter a keyword")},onCancel:()=>{D(!1),ei(""),ed(""),en("BLOCK")}})]})};var Z=((t={}).PresidioPII="Presidio PII",t.Bedrock="Bedrock Guardrail",t.Lakera="Lakera",t);let X={},ee=e=>{let t={};return t.PresidioPII="Presidio PII",t.Bedrock="Bedrock Guardrail",t.Lakera="Lakera",t.LlmAsAJudge="LiteLLM LLM as a Judge",Object.entries(e).forEach(([e,a])=>{a&&"object"==typeof a&&"ui_friendly_name"in a&&(t[e.split("_").map((e,t)=>e.charAt(0).toUpperCase()+e.slice(1)).join("")]=a.ui_friendly_name)}),X=t,t},et=()=>Object.keys(X).length>0?X:Z,ea={PresidioPII:"presidio",Bedrock:"bedrock",Lakera:"lakera_v2",LitellmContentFilter:"litellm_content_filter",ToolPermission:"tool_permission",BlockCodeExecution:"block_code_execution",Promptguard:"promptguard",LlmAsAJudge:"llm_as_a_judge"},el=e=>{Object.entries(e).forEach(([e,t])=>{t&&"object"==typeof t&&"ui_friendly_name"in t&&(ea[e.split("_").map((e,t)=>e.charAt(0).toUpperCase()+e.slice(1)).join("")]=e)})},er=e=>!!e&&"Presidio PII"===et()[e],ei=e=>!!e&&"LiteLLM Content Filter"===et()[e],es=e=>!!e&&"llm_as_a_judge"===ea[e],en="../ui/assets/logos/",eo={"Zscaler AI Guard":`${en}zscaler.svg`,"Presidio PII":`${en}microsoft_azure.svg`,"Bedrock Guardrail":`${en}bedrock.svg`,Lakera:`${en}lakeraai.jpeg`,"Azure Content Safety Prompt Shield":`${en}microsoft_azure.svg`,"Azure Content Safety Text Moderation":`${en}microsoft_azure.svg`,"Aporia AI":`${en}aporia.png`,"PANW Prisma AIRS":`${en}palo_alto_networks.jpeg`,"Noma Security":`${en}noma_security.png`,"Javelin Guardrails":`${en}javelin.png`,"Pillar Guardrail":`${en}pillar.jpeg`,"Google Cloud Model Armor":`${en}google.svg`,"Guardrails AI":`${en}guardrails_ai.jpeg`,"Lasso Guardrail":`${en}lasso.png`,"Pangea Guardrail":`${en}pangea.png`,"AIM Guardrail":`${en}aim_security.jpeg`,"OpenAI Moderation":`${en}openai_small.svg`,EnkryptAI:`${en}enkrypt_ai.avif`,"Prompt Security":`${en}prompt_security.png`,PromptGuard:`${en}promptguard.svg`,"LiteLLM Content Filter":`${en}litellm_logo.jpg`,"LiteLLM LLM as a Judge":`${en}litellm_logo.jpg`,Akto:`${en}akto.svg`},ed=e=>{if(!e)return{logo:"",displayName:"-"};let t=Object.keys(ea).find(t=>ea[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let a=et()[t];return{logo:eo[a]||"",displayName:a||e}};function ec(e){return!0===e?"yes":!1===e?"no":"inherit"}function em(e){return"yes"===e||"no"!==e&&void 0}e.s(["choiceToSkipSystemForCreate",()=>em,"getGuardrailLogoAndName",0,ed,"getGuardrailProviders",0,et,"guardrailLogoMap",0,eo,"guardrail_provider_map",0,ea,"populateGuardrailProviderMap",0,el,"populateGuardrailProviders",0,ee,"shouldRenderContentFilterConfigSettings",0,ei,"shouldRenderLLMJudgeFields",0,es,"shouldRenderPIIConfigSettings",0,er,"skipSystemMessageToChoice",()=>ec],180766);var eu=e.i(435451);let{Title:ep}=d.Typography,eg=({field:e,fieldKey:t,fullFieldKey:a,value:s})=>{let[o,d]=m.default.useState([]),[u,p]=m.default.useState(e.dict_key_options||[]);return m.default.useEffect(()=>{if(s&&"object"==typeof s){let t=Object.keys(s);d(t.map(e=>({key:e,id:`${e}_${Date.now()}_${Math.random()}`}))),p((e.dict_key_options||[]).filter(e=>!t.includes(e)))}},[s,e.dict_key_options]),(0,l.jsxs)("div",{className:"space-y-3",children:[o.map(t=>(0,l.jsxs)("div",{className:"flex items-center space-x-3 p-3 border rounded-lg",children:[(0,l.jsx)("div",{className:"w-24 font-medium text-sm",children:t.key}),(0,l.jsx)("div",{className:"flex-1",children:(0,l.jsx)(r.Form.Item,{name:Array.isArray(a)?[...a,t.key]:[a,t.key],style:{marginBottom:0},initialValue:s&&"object"==typeof s?s[t.key]:void 0,normalize:"number"===e.dict_value_type?e=>{if(null==e||""===e)return;let t=Number(e);return isNaN(t)?e:t}:void 0,children:"number"===e.dict_value_type?(0,l.jsx)(eu.default,{step:1,width:200,placeholder:`Enter ${t.key} value`}):"boolean"===e.dict_value_type?(0,l.jsxs)(n.Select,{placeholder:`Select ${t.key} value`,children:[(0,l.jsx)(n.Select.Option,{value:!0,children:"True"}),(0,l.jsx)(n.Select.Option,{value:!1,children:"False"})]}):(0,l.jsx)(i.Input,{placeholder:`Enter ${t.key} value`})})}),(0,l.jsx)(c.Button,{type:"text",danger:!0,size:"small",onClick:()=>{var e,a;return e=t.id,a=t.key,void(d(o.filter(t=>t.id!==e)),p([...u,a].sort()))},children:"Remove"})]},t.id)),u.length>0&&(0,l.jsxs)("div",{className:"flex items-center space-x-3 mt-2",children:[(0,l.jsx)(n.Select,{placeholder:"Select category to configure",style:{width:200},onSelect:e=>e&&void(!e||(d([...o,{key:e,id:`${e}_${Date.now()}`}]),p(u.filter(t=>t!==e)))),value:void 0,children:u.map(e=>(0,l.jsx)(n.Select.Option,{value:e,children:e},e))}),(0,l.jsx)("span",{className:"text-sm text-gray-500",children:"Select a category to add threshold configuration"})]})]})},ex=({optionalParams:e,parentFieldKey:t,values:a})=>e.fields&&0!==Object.keys(e.fields).length?(0,l.jsxs)("div",{className:"guardrail-optional-params",children:[(0,l.jsxs)("div",{className:"mb-8 pb-4 border-b border-gray-100",children:[(0,l.jsx)(ep,{level:3,className:"mb-2 font-semibold text-gray-900",children:"Optional Parameters"}),(0,l.jsx)("p",{className:"text-gray-600 text-sm",children:e.description||"Configure additional settings for this guardrail provider"})]}),(0,l.jsx)("div",{className:"space-y-8",children:Object.entries(e.fields).map(([e,s])=>{let o,d;return o=`${t}.${e}`,(console.log("value",d=a?.[e]),"dict"===s.type&&s.dict_key_options)?(0,l.jsxs)("div",{className:"mb-8 p-6 bg-gray-50 rounded-lg border border-gray-200",children:[(0,l.jsx)("div",{className:"mb-4 font-medium text-gray-900 text-base",children:e}),(0,l.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:s.description}),(0,l.jsx)(eg,{field:s,fieldKey:e,fullFieldKey:[t,e],value:d})]},o):(0,l.jsx)("div",{className:"mb-8 p-6 bg-white rounded-lg border border-gray-200 shadow-sm",children:(0,l.jsx)(r.Form.Item,{name:[t,e],label:(0,l.jsxs)("div",{className:"mb-2",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 text-base",children:e}),(0,l.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:s.description})]}),rules:s.required?[{required:!0,message:`${e} is required`}]:void 0,className:"mb-0",initialValue:void 0!==d?d:s.default_value,normalize:"number"===s.type?e=>{if(null==e||""===e)return;let t=Number(e);return isNaN(t)?e:t}:void 0,children:"select"===s.type&&s.options?(0,l.jsx)(n.Select,{placeholder:s.description,children:s.options.map(e=>(0,l.jsx)(n.Select.Option,{value:e,children:e},e))}):"multiselect"===s.type&&s.options?(0,l.jsx)(n.Select,{mode:"multiple",placeholder:s.description,children:s.options.map(e=>(0,l.jsx)(n.Select.Option,{value:e,children:e},e))}):"bool"===s.type||"boolean"===s.type?(0,l.jsxs)(n.Select,{placeholder:s.description,children:[(0,l.jsx)(n.Select.Option,{value:!0,children:"True"}),(0,l.jsx)(n.Select.Option,{value:!1,children:"False"})]}):"number"===s.type?(0,l.jsx)(eu.default,{step:1,width:400,placeholder:s.description}):e.includes("password")||e.includes("secret")||e.includes("key")?(0,l.jsx)(i.Input.Password,{placeholder:s.description}):(0,l.jsx)(i.Input,{placeholder:s.description})})},o)})})]}):null;var eh=e.i(482725),ef=e.i(850627);let ey=({selectedProvider:e,accessToken:t,providerParams:a=null,value:s=null})=>{let[o,d]=(0,m.useState)(!1),[c,u]=(0,m.useState)(a),[g,x]=(0,m.useState)(null);if((0,m.useEffect)(()=>{if(a)return void u(a);let e=async()=>{if(t){d(!0),x(null);try{let e=await (0,p.getGuardrailProviderSpecificParams)(t);console.log("Provider params API response:",e),u(e),ee(e),el(e)}catch(e){console.error("Error fetching provider params:",e),x("Failed to load provider parameters")}finally{d(!1)}}};a||e()},[t,a]),!e)return null;if(o)return(0,l.jsx)(eh.Spin,{tip:"Loading provider parameters..."});if(g)return(0,l.jsx)("div",{className:"text-red-500",children:g});let h=ea[e]?.toLowerCase(),f=c&&c[h];if(console.log("Provider key:",h),console.log("Provider fields:",f),!f||0===Object.keys(f).length)return(0,l.jsx)("div",{children:"No configuration fields available for this provider."});console.log("Value:",s);let y=new Set(["patterns","blocked_words","blocked_words_file","categories","severity_threshold","pattern_redaction_format","keyword_redaction_tag"]),j=ei(e),_=(e,t="",a)=>Object.entries(e).map(([e,o])=>{let d=t?`${t}.${e}`:e,c=a?a[e]:s?.[e];if(console.log("Field value:",c),"ui_friendly_name"===e||"optional_params"===e&&"nested"===o.type&&o.fields||j&&y.has(e))return null;if("nested"===o.type&&o.fields)return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-2 font-medium",children:e}),(0,l.jsx)("div",{className:"ml-4 border-l-2 border-gray-200 pl-4",children:_(o.fields,d,c)})]},d);let m=void 0!==c?c:o.default_value??("percentage"===o.type?.5:void 0);return(0,l.jsx)(r.Form.Item,{name:d,label:e,tooltip:o.description,rules:o.required?[{required:!0,message:`${e} is required`}]:void 0,initialValue:m,children:"select"===o.type&&o.options?(0,l.jsx)(n.Select,{placeholder:o.description,defaultValue:c||o.default_value,children:o.options.map(e=>(0,l.jsx)(n.Select.Option,{value:e,children:e},e))}):"multiselect"===o.type&&o.options?(0,l.jsx)(n.Select,{mode:"multiple",placeholder:o.description,defaultValue:c||o.default_value,children:o.options.map(e=>(0,l.jsx)(n.Select.Option,{value:e,children:e},e))}):"bool"===o.type||"boolean"===o.type?(0,l.jsxs)(n.Select,{placeholder:o.description,children:[(0,l.jsx)(n.Select.Option,{value:!0,children:"True"}),(0,l.jsx)(n.Select.Option,{value:!1,children:"False"})]}):"percentage"===o.type&&null!=o.min&&null!=o.max?(0,l.jsx)(ef.Slider,{min:o.min,max:o.max,step:o.step??.1,marks:{[o.min]:"0%",[(o.min+o.max)/2]:"50%",[o.max]:"100%"}}):"number"===o.type?(0,l.jsx)(eu.default,{step:1,width:400,placeholder:o.description,defaultValue:void 0!==c?Number(c):void 0}):e.includes("password")||e.includes("secret")||e.includes("key")?(0,l.jsx)(i.Input.Password,{placeholder:o.description,defaultValue:c||""}):(0,l.jsx)(i.Input,{placeholder:o.description,defaultValue:c||""})},d)});return(0,l.jsx)(l.Fragment,{children:_(f)})};var ej=e.i(592968),e_=e.i(750113);let eb=({availableModels:e,form:t})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{style:{background:"#f6ffed",border:"1px solid #b7eb8f",borderRadius:6,padding:"10px 14px",marginBottom:16,fontSize:13,color:"#389e0d"},children:["After each LLM response, the ",(0,l.jsx)("strong",{children:"Judge Model"})," scores it 0–100 against your criteria. If the weighted average falls below the threshold, the response is blocked (or logged)."]}),(0,l.jsx)(r.Form.Item,{name:"judge_model",label:(0,l.jsxs)("span",{children:["Judge Model ",(0,l.jsx)(ej.Tooltip,{title:"The LLM that reads each response and grades it. Pick a capable model — it never sees end-user data beyond what the LLM returned.",children:(0,l.jsx)(e_.QuestionCircleOutlined,{style:{color:"#8c8c8c"}})})]}),rules:[{required:!0,message:"Select a judge model"}],children:(0,l.jsx)(n.Select,{showSearch:!0,placeholder:"Select a model",options:e.map(e=>({label:e,value:e}))})}),(0,l.jsx)(r.Form.Item,{name:"overall_threshold",label:(0,l.jsxs)("span",{children:["Minimum Score to Pass ",(0,l.jsx)(ej.Tooltip,{title:"0–100. If the weighted average of criterion scores falls below this, the guardrail triggers. 80 is a good default.",children:(0,l.jsx)(e_.QuestionCircleOutlined,{style:{color:"#8c8c8c"}})})]}),initialValue:80,children:(0,l.jsx)(K.InputNumber,{min:0,max:100,addonAfter:"/ 100",style:{width:"100%"}})}),(0,l.jsx)(r.Form.Item,{name:"on_failure",label:(0,l.jsxs)("span",{children:["On Failure ",(0,l.jsx)(ej.Tooltip,{title:"Block: return HTTP 422 when the score is too low. Log: record the result but let the response through.",children:(0,l.jsx)(e_.QuestionCircleOutlined,{style:{color:"#8c8c8c"}})})]}),initialValue:"block",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(n.Select.Option,{value:"block",children:"Block (return 422)"}),(0,l.jsx)(n.Select.Option,{value:"log",children:"Log only"})]})}),(0,l.jsx)(r.Form.Item,{label:(0,l.jsxs)("span",{children:["Evaluation Criteria ",(0,l.jsx)(ej.Tooltip,{title:"Each criterion is something the judge checks. Weights must add up to 100%.",children:(0,l.jsx)(e_.QuestionCircleOutlined,{style:{color:"#8c8c8c"}})})]}),children:(0,l.jsx)(r.Form.List,{name:"criteria",initialValue:[{name:"",weight:100,description:""}],children:(e,{add:a,remove:s})=>(0,l.jsxs)(l.Fragment,{children:[e.map(({key:e,name:t,...a})=>(0,l.jsxs)("div",{style:{border:"1px solid #f0f0f0",borderRadius:6,padding:"12px 12px 0",marginBottom:8},children:[(0,l.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[(0,l.jsx)(r.Form.Item,{...a,name:[t,"name"],rules:[{required:!0,message:"Enter criterion name"}],style:{flex:2,marginBottom:8},children:(0,l.jsx)(i.Input,{placeholder:"Criterion name (e.g. Policy accuracy)"})}),(0,l.jsx)(r.Form.Item,{...a,name:[t,"weight"],label:(0,l.jsx)(ej.Tooltip,{title:"How much this criterion counts toward the final score. All weights must add up to 100%.",children:(0,l.jsxs)("span",{style:{fontSize:12,color:"#595959"},children:["Weight ",(0,l.jsx)(e_.QuestionCircleOutlined,{style:{color:"#bfbfbf"}})]})}),rules:[{required:!0,message:"Enter weight"}],style:{flex:1,marginBottom:8},children:(0,l.jsx)(K.InputNumber,{min:0,max:100,addonAfter:"%",style:{width:"100%"},placeholder:"e.g. 50"})}),(0,l.jsx)("div",{style:{marginBottom:8},children:(0,l.jsx)(c.Button,{type:"text",danger:!0,size:"small",onClick:()=>s(t),children:"×"})})]}),(0,l.jsx)(r.Form.Item,{...a,name:[t,"description"],rules:[{required:!0,message:"Describe what to check"}],style:{marginBottom:8},children:(0,l.jsx)(i.Input,{placeholder:"What should the judge check for this criterion?"})})]},e)),(0,l.jsx)(c.Button,{type:"dashed",block:!0,style:{marginTop:4},onClick:()=>a({name:"",weight:0,description:""}),icon:(0,l.jsx)(f.PlusOutlined,{}),children:"Add Criterion"}),e.length>0&&(0,l.jsx)(r.Form.Item,{shouldUpdate:!0,noStyle:!0,children:()=>{let e=(t.getFieldValue("criteria")||[]).reduce((e,t)=>e+(Number(t?.weight)||0),0),a=100===e;return(0,l.jsxs)("div",{style:{marginTop:6,fontSize:12,color:a?"#52c41a":"#faad14"},children:["Weights total: ",e,"%",a?" ✓":" — must add up to 100%"]})}})]})})})]});var ev=e.i(536916),ew=e.i(149192),eN=e.i(741585),eN=eN,eC=e.i(724154);e.i(247167);var eS=e.i(931067);let ek={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z"}}]},name:"filter",theme:"outlined"};var eI=e.i(9583),eA=m.forwardRef(function(e,t){return m.createElement(eI.default,(0,eS.default)({},e,{ref:t,icon:ek}))});let{Text:eO}=d.Typography,{Option:eT}=n.Select,eP=({categories:e,selectedCategories:t,onChange:a})=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center mb-2",children:[(0,l.jsx)(eA,{className:"text-gray-500 mr-1"}),(0,l.jsx)(eO,{className:"text-gray-500 font-medium",children:"Filter by category"})]}),(0,l.jsx)(n.Select,{mode:"multiple",placeholder:"Select categories to filter by",style:{width:"100%"},onChange:a,value:t,allowClear:!0,showSearch:!0,optionFilterProp:"children",className:"mb-4",tagRender:e=>(0,l.jsx)(o.Tag,{color:"blue",closable:e.closable,onClose:e.onClose,className:"mr-2 mb-2",children:e.label}),children:e.map(e=>(0,l.jsx)(eT,{value:e.category,children:e.category},e.category))})]}),eL=({onSelectAll:e,onUnselectAll:t,hasSelectedEntities:a})=>(0,l.jsxs)("div",{className:"bg-gray-50 p-5 rounded-lg mb-6 border border-gray-200 shadow-sm",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)(eO,{strong:!0,className:"text-gray-700 text-base",children:"Quick Actions"}),(0,l.jsx)(ej.Tooltip,{title:"Apply action to all PII types at once",children:(0,l.jsx)("div",{className:"ml-2 text-gray-400 cursor-help text-xs",children:"ⓘ"})})]}),(0,l.jsx)(c.Button,{color:"danger",variant:"outlined",onClick:t,disabled:!a,icon:(0,l.jsx)(ew.CloseOutlined,{}),children:"Unselect All"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsx)(c.Button,{color:"primary",variant:"outlined",onClick:()=>e("MASK"),className:"h-10",block:!0,icon:(0,l.jsx)(eN.default,{}),children:"Select All & Mask"}),(0,l.jsx)(c.Button,{color:"danger",variant:"outlined",onClick:()=>e("BLOCK"),className:"h-10 hover:bg-red-100",block:!0,icon:(0,l.jsx)(eC.StopOutlined,{}),children:"Select All & Block"})]})]}),eB=({entities:e,selectedEntities:t,selectedActions:a,actions:r,onEntitySelect:i,onActionSelect:s,entityToCategoryMap:d})=>(0,l.jsxs)("div",{className:"border rounded-lg overflow-hidden shadow-sm",children:[(0,l.jsxs)("div",{className:"bg-gray-50 px-5 py-3 border-b flex",children:[(0,l.jsx)(eO,{strong:!0,className:"flex-1 text-gray-700",children:"PII Type"}),(0,l.jsx)(eO,{strong:!0,className:"w-32 text-right text-gray-700",children:"Action"})]}),(0,l.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:0===e.length?(0,l.jsx)("div",{className:"py-10 text-center text-gray-500",children:"No PII types match your filter criteria"}):e.map(e=>(0,l.jsxs)("div",{className:`px-5 py-3 flex items-center justify-between hover:bg-gray-50 border-b ${t.includes(e)?"bg-blue-50":""}`,children:[(0,l.jsxs)("div",{className:"flex items-center flex-1",children:[(0,l.jsx)(ev.Checkbox,{checked:t.includes(e),onChange:()=>i(e),className:"mr-3"}),(0,l.jsx)(eO,{className:t.includes(e)?"font-medium text-gray-900":"text-gray-700",children:e.replace(/_/g," ")}),d.get(e)&&(0,l.jsx)(o.Tag,{className:"ml-2 text-xs",color:"blue",children:d.get(e)})]}),(0,l.jsx)("div",{className:"w-32",children:(0,l.jsx)(n.Select,{value:t.includes(e)&&a[e]||"MASK",onChange:t=>s(e,t),style:{width:120},disabled:!t.includes(e),className:`${!t.includes(e)?"opacity-50":""}`,dropdownMatchSelectWidth:!1,children:r.map(e=>(0,l.jsx)(eT,{value:e,children:(0,l.jsxs)("div",{className:"flex items-center",children:[(e=>{switch(e){case"MASK":return(0,l.jsx)(eN.default,{style:{marginRight:4}});case"BLOCK":return(0,l.jsx)(eC.StopOutlined,{style:{marginRight:4}});default:return null}})(e),e]})},e))})})]},e))})]}),{Title:eF,Text:e$}=d.Typography,eE=({entities:e,actions:t,selectedEntities:a,selectedActions:r,onEntitySelect:i,onActionSelect:s,entityCategories:n=[]})=>{let[o,d]=(0,m.useState)([]),c=new Map;n.forEach(e=>{e.entities.forEach(t=>{c.set(t,e.category)})});let u=e.filter(e=>0===o.length||o.includes(c.get(e)||""));return(0,l.jsxs)("div",{className:"pii-configuration",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-5",children:[(0,l.jsx)("div",{className:"flex items-center",children:(0,l.jsx)(eF,{level:4,className:"!m-0 font-semibold text-gray-800",children:"Configure PII Protection"})}),(0,l.jsxs)(e$,{className:"text-gray-500",children:[a.length," items selected"]})]}),(0,l.jsxs)("div",{className:"mb-6",children:[(0,l.jsx)(eP,{categories:n,selectedCategories:o,onChange:d}),(0,l.jsx)(eL,{onSelectAll:t=>{e.forEach(e=>{a.includes(e)||i(e),s(e,t)})},onUnselectAll:()=>{a.forEach(e=>{i(e)})},hasSelectedEntities:a.length>0})]}),(0,l.jsx)(eB,{entities:u,selectedEntities:a,selectedActions:r,actions:t,onEntitySelect:i,onActionSelect:s,entityToCategoryMap:c})]})};var eM=e.i(304967),eR=e.i(599724),eG=e.i(312361),ez=e.i(21548),eD=e.i(827252);let eK={rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""},eH=({value:e,onChange:t,disabled:a=!1})=>{let r={...eK,...e||{},rules:e?.rules?[...e.rules]:[]},s=e=>{let a={...r,...e};t?.(a)},o=(e,t)=>{s({rules:r.rules.map((a,l)=>l===e?{...a,...t}:a)})},d=(e,t)=>{let a=r.rules[e];if(!a)return;let l=Object.entries(a.allowed_param_patterns||{});t(l);let i={};l.forEach(([e,t])=>{i[e]=t}),o(e,{allowed_param_patterns:Object.keys(i).length>0?i:void 0})};return(0,l.jsxs)(eM.Card,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"text-lg font-semibold",children:"LiteLLM Tool Permission Guardrail"}),(0,l.jsx)(eR.Text,{className:"text-sm text-gray-500",children:"Provide regex patterns (e.g., ^mcp__github_.*$) for tool names or types and optionally constrain payload fields."})]}),!a&&(0,l.jsx)(c.Button,{icon:(0,l.jsx)(f.PlusOutlined,{}),type:"primary",onClick:()=>{s({rules:[...r.rules,{id:`rule_${Math.random().toString(36).slice(2,8)}`,decision:"allow",allowed_param_patterns:void 0}]})},className:"!bg-blue-600 !text-white hover:!bg-blue-500",children:"Add Rule"})]}),(0,l.jsx)(eG.Divider,{}),0===r.rules.length?(0,l.jsx)(ez.Empty,{description:"No tool rules added yet"}):(0,l.jsx)("div",{className:"space-y-4",children:r.rules.map((e,t)=>{let m;return(0,l.jsxs)(eM.Card,{className:"bg-gray-50",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,l.jsxs)(eR.Text,{className:"font-semibold",children:["Rule ",t+1]}),(0,l.jsx)(c.Button,{icon:(0,l.jsx)(A.DeleteOutlined,{}),danger:!0,type:"text",disabled:a,onClick:()=>{s({rules:r.rules.filter((e,a)=>a!==t)})},children:"Remove"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Rule ID"}),(0,l.jsx)(i.Input,{disabled:a,placeholder:"unique_rule_id",value:e.id,onChange:e=>o(t,{id:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Tool Name (optional)"}),(0,l.jsx)(i.Input,{disabled:a,placeholder:"^mcp__github_.*$",value:e.tool_name??"",onChange:e=>o(t,{tool_name:""===e.target.value.trim()?void 0:e.target.value})})]})]}),(0,l.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 mt-4",children:(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Tool Type (optional)"}),(0,l.jsx)(i.Input,{disabled:a,placeholder:"^function$",value:e.tool_type??"",onChange:e=>o(t,{tool_type:""===e.target.value.trim()?void 0:e.target.value})})]})}),(0,l.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Decision"}),(0,l.jsxs)(n.Select,{disabled:a,value:e.decision,style:{width:200},onChange:e=>o(t,{decision:e}),children:[(0,l.jsx)(n.Select.Option,{value:"allow",children:"Allow"}),(0,l.jsx)(n.Select.Option,{value:"deny",children:"Deny"})]})]}),(0,l.jsx)("div",{className:"mt-4",children:0===(m=Object.entries(e.allowed_param_patterns||{})).length?(0,l.jsx)(c.Button,{disabled:a,size:"small",onClick:()=>o(t,{allowed_param_patterns:{"":""}}),children:"+ Restrict tool arguments (optional)"}):(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(eR.Text,{className:"text-sm text-gray-600",children:"Argument constraints (dot or array paths)"}),m.map(([r,s],n)=>(0,l.jsxs)(g.Space,{align:"start",children:[(0,l.jsx)(i.Input,{disabled:a,placeholder:"messages[0].content",value:r,onChange:e=>{var a;return a=e.target.value,void d(t,e=>{if(!e[n])return;let[,t]=e[n];e[n]=[a,t]})}}),(0,l.jsx)(i.Input,{disabled:a,placeholder:"^email@.*$",value:s,onChange:e=>{var a;return a=e.target.value,void d(t,e=>{if(!e[n])return;let[t]=e[n];e[n]=[t,a]})}}),(0,l.jsx)(c.Button,{disabled:a,icon:(0,l.jsx)(A.DeleteOutlined,{}),danger:!0,onClick:()=>d(t,e=>{e.splice(n,1)})})]},`${e.id||t}-${n}`)),(0,l.jsx)(c.Button,{disabled:a,size:"small",onClick:()=>o(t,{allowed_param_patterns:{...e.allowed_param_patterns||{},"":""}}),children:"+ Add another constraint"})]})})]},e.id||t)})}),(0,l.jsx)(eG.Divider,{}),(0,l.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Default action"}),(0,l.jsxs)(n.Select,{disabled:a,value:r.default_action,onChange:e=>s({default_action:e}),children:[(0,l.jsx)(n.Select.Option,{value:"allow",children:"Allow"}),(0,l.jsx)(n.Select.Option,{value:"deny",children:"Deny"})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(eR.Text,{className:"text-sm font-medium flex items-center gap-1",children:["On disallowed action",(0,l.jsx)(ej.Tooltip,{title:"Block returns an error when a forbidden tool is invoked. Rewrite strips the tool call but lets the rest of the response continue.",children:(0,l.jsx)(eD.InfoCircleOutlined,{})})]}),(0,l.jsxs)(n.Select,{disabled:a,value:r.on_disallowed_action,onChange:e=>s({on_disallowed_action:e}),children:[(0,l.jsx)(n.Select.Option,{value:"block",children:"Block"}),(0,l.jsx)(n.Select.Option,{value:"rewrite",children:"Rewrite"})]})]})]}),(0,l.jsxs)("div",{className:"mt-4",children:[(0,l.jsx)(eR.Text,{className:"text-sm font-medium",children:"Violation message (optional)"}),(0,l.jsx)(i.Input.TextArea,{disabled:a,rows:3,placeholder:"This violates our org policy...",value:r.violation_message_template,onChange:e=>s({violation_message_template:e.target.value})})]})]})},{Title:eq,Text:eJ,Link:eU}=d.Typography,{Option:eW}=n.Select,eV={pre_call:"Before LLM Call - Runs before the LLM call and checks the input (Recommended)",during_call:"During LLM Call - Runs in parallel with the LLM call, with response held until check completes",post_call:"After LLM Call - Runs after the LLM call and checks only the output",logging_only:"Logging Only - Only runs on logging callbacks without affecting the LLM call",pre_mcp_call:"Before MCP Tool Call - Runs before MCP tool execution and validates tool calls",during_mcp_call:"During MCP Tool Call - Runs in parallel with MCP tool execution for monitoring"};e.s(["default",0,({visible:e,onClose:t,accessToken:a,onSuccess:d,preset:g})=>{let[x]=r.Form.useForm(),[h,f]=(0,m.useState)(!1),[y,j]=(0,m.useState)(null),[_,b]=(0,m.useState)(null),[v,w]=(0,m.useState)([]),[N,C]=(0,m.useState)({}),[S,k]=(0,m.useState)(0),[I,A]=(0,m.useState)(null),[O,T]=(0,m.useState)([]),[P,L]=(0,m.useState)(2),[B,F]=(0,m.useState)({}),[$,E]=(0,m.useState)([]),[M,R]=(0,m.useState)([]),[G,z]=(0,m.useState)([]),[D,K]=(0,m.useState)(""),[H,q]=(0,m.useState)(!1),[J,U]=(0,m.useState)(null),[W,V]=(0,m.useState)(""),[Y,Z]=(0,m.useState)(void 0),[X,en]=(0,m.useState)("warn"),[ed,ec]=(0,m.useState)(""),[eu,ep]=(0,m.useState)(!1),[eg,eh]=(0,m.useState)([]),[ef,ej]=(0,m.useState)({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""}),e_=(0,m.useMemo)(()=>!!y&&"tool_permission"===(ea[y]||"").toLowerCase(),[y]);(0,m.useEffect)(()=>{a&&(async()=>{try{let[e,t,l]=await Promise.all([(0,p.getGuardrailUISettings)(a),(0,p.getGuardrailProviderSpecificParams)(a),(0,p.modelAvailableCall)(a,"","").catch(()=>null)]);b(e),A(t),l?.data&&eh(l.data.map(e=>e.id)),ee(t),el(t)}catch(e){console.error("Error fetching guardrail data:",e),u.default.fromBackend("Failed to load guardrail configuration")}})()},[a]),(0,m.useEffect)(()=>{if(!g||!e||!_)return;j(g.provider);let t={provider:g.provider,guardrail_name:g.guardrailNameSuggestion,mode:g.mode,default_on:g.defaultOn,skip_system_message_choice:"inherit"};if("BlockCodeExecution"===g.provider&&(t.confidence_threshold=.5),x.setFieldsValue(t),g.categoryName&&_.content_filter_settings?.content_categories){let e=_.content_filter_settings.content_categories.find(e=>e.name===g.categoryName);e&&z([{id:`category-${Date.now()}`,category:e.name,display_name:e.display_name,action:e.default_action,severity_threshold:"medium"}])}},[g,e,_]);let ev=e=>{j(e);let t={config:void 0,presidio_analyzer_api_base:void 0,presidio_anonymizer_api_base:void 0};"BlockCodeExecution"===e&&(t.confidence_threshold=.5),x.setFieldsValue(t),w([]),C({}),T([]),L(2),F({}),E([]),R([]),z([]),K(""),q(!1),U(null),ej({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""}),"LlmAsAJudge"===e&&x.setFieldsValue({mode:"post_call"})},ew=e=>{w(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},eN=(e,t)=>{C(a=>({...a,[e]:t}))},eC=async()=>{try{if(0===S&&(await x.validateFields(["guardrail_name","provider","mode","default_on"]),y)){let e=["guardrail_name","provider","mode","default_on"];"PresidioPII"===y&&e.push("presidio_analyzer_api_base","presidio_anonymizer_api_base"),await x.validateFields(e)}if(1===S&&er(y)&&0===v.length)return void u.default.fromBackend("Please select at least one PII entity to continue");k(S+1)}catch(e){console.error("Form validation failed:",e)}},eS=()=>{x.resetFields(),j(null),w([]),C({}),T([]),L(2),F({}),E([]),R([]),z([]),K(""),ej({rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""}),V(""),Z(void 0),en("warn"),ec(""),ep(!1),k(0)},ek=()=>{eS(),t()},eI=async()=>{try{f(!0),await x.validateFields();let e=x.getFieldsValue(!0),l=ea[e.provider],r={guardrail_name:e.guardrail_name,litellm_params:{guardrail:l,mode:e.mode,default_on:e.default_on},guardrail_info:{}},i=em(e.skip_system_message_choice);if(void 0!==i&&(r.litellm_params.skip_system_message_in_guardrail=i),"PresidioPII"===e.provider&&v.length>0){let t={};v.forEach(e=>{t[e]=N[e]||"MASK"}),r.litellm_params.pii_entities_config=t,e.presidio_analyzer_api_base&&(r.litellm_params.presidio_analyzer_api_base=e.presidio_analyzer_api_base),e.presidio_anonymizer_api_base&&(r.litellm_params.presidio_anonymizer_api_base=e.presidio_anonymizer_api_base)}if(ei(e.provider)){let e=H&&J?.brand_self?.length>0;if(0===$.length&&0===M.length&&0===G.length&&!e){u.default.fromBackend("Please configure at least one content filter setting (category, pattern, keyword, or competitor intent)"),f(!1);return}$.length>0&&(r.litellm_params.patterns=$.map(e=>({pattern_type:"prebuilt"===e.type?"prebuilt":"regex",pattern_name:"prebuilt"===e.type?e.name:void 0,pattern:"custom"===e.type?e.pattern:void 0,name:e.name,action:e.action}))),M.length>0&&(r.litellm_params.blocked_words=M.map(e=>({keyword:e.keyword,action:e.action,description:e.description}))),G.length>0&&(r.litellm_params.categories=G.map(e=>({category:e.category,enabled:!0,action:e.action,severity_threshold:e.severity_threshold||"medium"}))),H&&J?.brand_self?.length>0&&(r.litellm_params.competitor_intent_config={competitor_intent_type:J.competitor_intent_type??"airline",brand_self:J.brand_self,locations:J.locations?.length>0?J.locations:void 0,competitors:"generic"===J.competitor_intent_type&&J.competitors?.length>0?J.competitors:void 0,policy:J.policy,threshold_high:J.threshold_high,threshold_medium:J.threshold_medium,threshold_low:J.threshold_low})}else if(e.config)try{r.guardrail_info=JSON.parse(e.config)}catch(e){u.default.fromBackend("Invalid JSON in configuration"),f(!1);return}if("llm_as_a_judge"===l){let t=e.criteria||[];if(0===t.length){u.default.fromBackend("Add at least one evaluation criterion"),f(!1);return}let a=t.reduce((e,t)=>e+(Number(t?.weight)||0),0);if(100!==a){u.default.fromBackend(`Criterion weights must sum to 100% (currently ${a}%)`),f(!1);return}r.litellm_params.judge_model=e.judge_model,r.litellm_params.overall_threshold=e.overall_threshold??80,r.litellm_params.on_failure=e.on_failure??"block",r.litellm_params.criteria=t.map(e=>({name:e.name,weight:Number(e.weight),description:e.description||""}))}if("tool_permission"===l){if(0===ef.rules.length){u.default.fromBackend("Add at least one tool permission rule"),f(!1);return}r.litellm_params.rules=ef.rules,r.litellm_params.default_action=ef.default_action,r.litellm_params.on_disallowed_action=ef.on_disallowed_action,ef.violation_message_template&&(r.litellm_params.violation_message_template=ef.violation_message_template)}if(ei(e.provider)&&(void 0!==Y&&Y>0&&(r.litellm_params.end_session_after_n_fails=Y),X&&"realtime"===W&&(r.litellm_params.on_violation=X),ed.trim()&&(r.litellm_params.realtime_violation_message=ed.trim())),console.log("values: ",JSON.stringify(e)),I&&y&&"llm_as_a_judge"!==l){let t=ea[y]?.toLowerCase();console.log("providerKey: ",t);let a=I[t]||{},l=new Set;console.log("providerSpecificParams: ",JSON.stringify(a)),Object.keys(a).forEach(e=>{"optional_params"!==e&&l.add(e)}),a.optional_params&&a.optional_params.fields&&Object.keys(a.optional_params.fields).forEach(e=>{l.add(e)}),console.log("allowedParams: ",l),l.forEach(t=>{let a=e[t];(null==a||""===a)&&(a=e.optional_params?.[t]),null!=a&&""!==a&&(r.litellm_params[t]=a)})}if(!a)throw Error("No access token available");console.log("Sending guardrail data:",JSON.stringify(r)),await (0,p.createGuardrailCall)(a,r),u.default.success("Guardrail created successfully"),eS(),d(),t()}catch(e){console.error("Failed to create guardrail:",e),u.default.fromBackend("Failed to create guardrail: "+(e instanceof Error?e.message:String(e)))}finally{f(!1)}},eA=e=>{if(!_||!ei(y))return null;let t=_.content_filter_settings;return t?(0,l.jsx)(Q,{prebuiltPatterns:t.prebuilt_patterns||[],categories:t.pattern_categories||[],selectedPatterns:$,blockedWords:M,onPatternAdd:e=>E([...$,e]),onPatternRemove:e=>E($.filter(t=>t.id!==e)),onPatternActionChange:(e,t)=>{E($.map(a=>a.id===e?{...a,action:t}:a))},onBlockedWordAdd:e=>R([...M,e]),onBlockedWordRemove:e=>R(M.filter(t=>t.id!==e)),onBlockedWordUpdate:(e,t,a)=>{R(M.map(l=>l.id===e?{...l,[t]:a}:l))},contentCategories:t.content_categories||[],selectedContentCategories:G,onContentCategoryAdd:e=>z([...G,e]),onContentCategoryRemove:e=>z(G.filter(t=>t.id!==e)),onContentCategoryUpdate:(e,t,a)=>{z(G.map(l=>l.id===e?{...l,[t]:a}:l))},pendingCategorySelection:D,onPendingCategorySelectionChange:K,accessToken:a,showStep:e,competitorIntentEnabled:H,competitorIntentConfig:J,onCompetitorIntentChange:(e,t)=>{q(e),U(t)}}):null},eO=ei(y)?[{title:"Basic Info",optional:!1},{title:"Topics",optional:!1},{title:"Patterns",optional:!1},{title:"Keywords",optional:!1},{title:"Endpoint Settings (Optional)",optional:!0}]:er(y)?[{title:"Basic Info",optional:!1},{title:"PII Configuration",optional:!1}]:[{title:"Basic Info",optional:!1},{title:"Provider Configuration",optional:!1}];return(0,l.jsx)(s.Modal,{title:null,open:e,onCancel:ek,footer:null,width:1e3,closable:!1,className:"top-8",styles:{body:{padding:0}},children:(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200",children:[(0,l.jsx)("h3",{className:"text-base font-semibold text-gray-900 m-0",children:"Create guardrail"}),(0,l.jsx)("button",{onClick:ek,className:"text-gray-400 hover:text-gray-600 bg-transparent border-none cursor-pointer text-base leading-none p-1",children:"✕"})]}),(0,l.jsx)("div",{className:"overflow-auto px-6 py-4",style:{maxHeight:"calc(80vh - 120px)"},children:(0,l.jsx)(r.Form,{form:x,layout:"vertical",initialValues:{mode:"pre_call",default_on:!1,skip_system_message_choice:"inherit"},children:eO.map((e,t)=>{let s=t{s&&k(t)},style:{minHeight:24},children:[(0,l.jsx)("span",{className:"text-sm",style:{fontWeight:d?600:500,color:d?"#1e293b":s?"#4f46e5":"#94a3b8"},children:e.title}),e.optional&&!d&&(0,l.jsx)("span",{className:"text-[11px] text-slate-400",children:"optional"}),s&&(0,l.jsx)("span",{className:"text-[11px] text-indigo-500 hover:underline",children:"Edit"})]}),d&&(0,l.jsx)("div",{className:"mt-3",children:(()=>{switch(S){case 0:return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r.Form.Item,{name:"guardrail_name",label:"Guardrail Name",rules:[{required:!0,message:"Please enter a guardrail name"}],children:(0,l.jsx)(i.Input,{placeholder:"Enter a name for this guardrail"})}),(0,l.jsx)(r.Form.Item,{name:"provider",label:"Guardrail Provider",rules:[{required:!0,message:"Please select a provider"}],children:(0,l.jsx)(n.Select,{placeholder:"Select a guardrail provider",onChange:ev,labelInValue:!1,optionLabelProp:"label",dropdownRender:e=>e,showSearch:!0,children:Object.entries(et()).map(([e,t])=>(0,l.jsx)(eW,{value:e,label:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[eo[t]&&(0,l.jsx)("img",{src:eo[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,l.jsx)("span",{children:t})]}),children:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[eo[t]&&(0,l.jsx)("img",{src:eo[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,l.jsx)("span",{children:t})]})},e))})}),(0,l.jsx)(r.Form.Item,{name:"mode",label:"Mode",tooltip:"How the guardrail should be applied",rules:[{required:!0,message:"Please select a mode"}],children:(0,l.jsx)(n.Select,{optionLabelProp:"label",mode:"multiple",children:_?.supported_modes?.map(e=>(0,l.jsx)(eW,{value:e,label:e,children:(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:e}),"pre_call"===e&&(0,l.jsx)(o.Tag,{color:"green",style:{marginLeft:"8px"},children:"Recommended"})]}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eV[e]})]})},e))||(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eW,{value:"pre_call",label:"pre_call",children:(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"pre_call"})," ",(0,l.jsx)(o.Tag,{color:"green",children:"Recommended"})]}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eV.pre_call})]})}),(0,l.jsx)(eW,{value:"during_call",label:"during_call",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{children:(0,l.jsx)("strong",{children:"during_call"})}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eV.during_call})]})}),(0,l.jsx)(eW,{value:"post_call",label:"post_call",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{children:(0,l.jsx)("strong",{children:"post_call"})}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eV.post_call})]})}),(0,l.jsx)(eW,{value:"logging_only",label:"logging_only",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{children:(0,l.jsx)("strong",{children:"logging_only"})}),(0,l.jsx)("div",{style:{fontSize:"12px",color:"#888"},children:eV.logging_only})]})})]})})}),(0,l.jsx)(r.Form.Item,{name:"default_on",label:"Always On",tooltip:"If enabled, this guardrail will be applied to all requests by default.",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(n.Select.Option,{value:!0,children:"Yes"}),(0,l.jsx)(n.Select.Option,{value:!1,children:"No"})]})}),(0,l.jsx)(r.Form.Item,{name:"skip_system_message_choice",label:"Skip system messages in guardrail",tooltip:"Unified guardrails only: omit role: system from guardrail evaluation input (OpenAI chat + Anthropic messages). The model still receives full messages. Use global default follows litellm_settings.skip_system_message_in_guardrail.",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(n.Select.Option,{value:"inherit",children:"Use global default"}),(0,l.jsx)(n.Select.Option,{value:"yes",children:"Yes — exclude from guardrail scan"}),(0,l.jsx)(n.Select.Option,{value:"no",children:"No — always include in scan"})]})}),!e_&&!ei(y)&&!es(y)&&(0,l.jsx)(ey,{selectedProvider:y,accessToken:a,providerParams:I})]});case 1:if(er(y))return _&&"PresidioPII"===y?(0,l.jsx)(eE,{entities:_.supported_entities,actions:_.supported_actions,selectedEntities:v,selectedActions:N,onEntitySelect:ew,onActionSelect:eN,entityCategories:_.pii_entity_categories}):null;if(ei(y))return eA("categories");if(es(y))return(0,l.jsx)(eb,{availableModels:eg,form:x});if(!y)return null;if(e_)return(0,l.jsx)(eH,{value:ef,onChange:ej});if(!I)return null;console.log("guardrail_provider_map: ",ea),console.log("selectedProvider: ",y);let e=ea[y]?.toLowerCase(),t=I&&I[e];return t&&t.optional_params?(0,l.jsx)(ex,{optionalParams:t.optional_params,parentFieldKey:"optional_params"}):null;case 2:if(ei(y))return eA("patterns");return null;case 3:if(ei(y))return eA("keywords");return null;case 4:return(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsx)("div",{children:(0,l.jsxs)("p",{className:"text-sm text-gray-500",children:["Configure settings for a specific call type. Most guardrails don't need this — skip it unless you're using a specific endpoint like ",(0,l.jsx)("code",{children:"/v1/realtime"}),"."]})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Call type"}),(0,l.jsx)(n.Select,{placeholder:"Select a call type",value:W||void 0,onChange:e=>{V(e),ep(!1)},style:{width:260},allowClear:!0,options:[{value:"realtime",label:"/v1/realtime"}]}),(0,l.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:"More call types coming soon."})]}),"realtime"===W&&(0,l.jsxs)("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>ep(e=>!e),className:"w-full flex items-center justify-between px-4 py-3 bg-gray-50 hover:bg-gray-100 text-sm font-medium text-gray-700",children:[(0,l.jsx)("span",{children:"/v1/realtime settings"}),(0,l.jsx)("svg",{className:`w-4 h-4 text-gray-500 transition-transform ${eu?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),eu&&(0,l.jsxs)("div",{className:"space-y-5 px-4 py-4 border-t border-gray-200",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"End session after X violations"}),(0,l.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"Automatically close the session after this many guardrail violations. Leave empty to never auto-close."}),(0,l.jsx)("input",{type:"number",min:1,placeholder:"e.g. 3",value:Y??"",onChange:e=>Z(e.target.value?parseInt(e.target.value,10):void 0),className:"border border-gray-300 rounded px-3 py-1.5 text-sm w-32"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"On violation"}),(0,l.jsx)("div",{className:"space-y-2",children:["warn","end_session"].map(e=>(0,l.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,l.jsx)("input",{type:"radio",name:"on_violation",value:e,checked:X===e,onChange:()=>en(e),className:"mt-0.5"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"text-sm font-medium text-gray-800",children:"warn"===e?"Warn":"End session"}),(0,l.jsx)("p",{className:"text-xs text-gray-400 m-0",children:"warn"===e?"Bot speaks the message, session continues":"Bot speaks the message, connection closes immediately"})]})]},e))})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Message the user hears"}),(0,l.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"What the bot says aloud when this guardrail fires. Falls back to the default violation message if empty."}),(0,l.jsx)("textarea",{rows:3,placeholder:"e.g. I'm not able to continue this conversation. Please contact us at 1-800-774-2678.",value:ed,onChange:e=>ec(e.target.value),className:"border border-gray-300 rounded px-3 py-2 text-sm w-full resize-none"})]})]})]})]});default:return null}})()})]})]},t)})})}),(0,l.jsxs)("div",{className:"flex items-center justify-end space-x-3 px-6 py-3 border-t border-gray-200",children:[(0,l.jsx)(c.Button,{onClick:ek,children:"Cancel"}),S>0&&(0,l.jsx)(c.Button,{onClick:()=>{k(S-1)},children:"Previous"}),S{let[x]=r.Form.useForm(),[h,f]=(0,m.useState)(!1),[y,j]=(0,m.useState)(g?.provider||null),[_,b]=(0,m.useState)(null),[v,w]=(0,m.useState)([]),[N,C]=(0,m.useState)({});(0,m.useEffect)(()=>{(async()=>{try{if(!a)return;let e=await (0,p.getGuardrailUISettings)(a);b(e)}catch(e){console.error("Error fetching guardrail settings:",e),u.default.fromBackend("Failed to load guardrail settings")}})()},[a]),(0,m.useEffect)(()=>{g?.pii_entities_config&&Object.keys(g.pii_entities_config).length>0&&(w(Object.keys(g.pii_entities_config)),C(g.pii_entities_config))},[g]);let S=e=>{w(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},k=(e,t)=>{C(a=>({...a,[e]:t}))},I=async()=>{try{f(!0);let e=await x.validateFields(),l=ea[e.provider],r=c&&"object"==typeof c?{...c}:{};r.guardrail=l,r.mode=e.mode,r.default_on=e.default_on;let i=e.skip_system_message_choice;"yes"===i?r.skip_system_message_in_guardrail=!0:"no"===i?r.skip_system_message_in_guardrail=!1:delete r.skip_system_message_in_guardrail;let s={};if("PresidioPII"===e.provider&&v.length>0){let e={};v.forEach(t=>{e[t]=N[t]||"MASK"}),r.pii_entities_config=e}else if(e.config)try{let t=JSON.parse(e.config);"Bedrock"===e.provider&&t?(t.guardrail_id&&(r.guardrailIdentifier=t.guardrail_id),t.guardrail_version&&(r.guardrailVersion=t.guardrail_version)):s=t}catch(e){u.default.fromBackend("Invalid JSON in configuration"),f(!1);return}let n={guardrail_id:d,guardrail:{guardrail_name:e.guardrail_name,litellm_params:r,guardrail_info:s}};if(!a)throw Error("No access token available");console.log("Sending guardrail update data:",JSON.stringify(n));let m=`/guardrails/${d}`,g=await fetch(m,{method:"PUT",headers:{[(0,p.getGlobalLitellmHeaderName)()]:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify(n)});if(!g.ok){let e=await g.text();throw Error(e||"Failed to update guardrail")}u.default.success("Guardrail updated successfully"),o(),t()}catch(e){console.error("Failed to update guardrail:",e),u.default.fromBackend("Failed to update guardrail: "+(e instanceof Error?e.message:String(e)))}finally{f(!1)}};return(0,l.jsx)(s.Modal,{title:"Edit Guardrail",open:e,onCancel:t,footer:null,width:700,children:(0,l.jsxs)(r.Form,{form:x,layout:"vertical",initialValues:g,children:[(0,l.jsx)(r.Form.Item,{name:"guardrail_name",label:"Guardrail Name",rules:[{required:!0,message:"Please enter a guardrail name"}],children:(0,l.jsx)(tt.TextInput,{placeholder:"Enter a name for this guardrail"})}),(0,l.jsx)(r.Form.Item,{name:"provider",label:"Guardrail Provider",rules:[{required:!0,message:"Please select a provider"}],children:(0,l.jsx)(n.Select,{placeholder:"Select a guardrail provider",onChange:e=>{j(e),x.setFieldsValue({config:void 0}),w([]),C({})},disabled:!0,optionLabelProp:"label",children:Object.entries(et()).map(([e,t])=>(0,l.jsx)(tr,{value:e,label:t,children:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[eo[t]&&(0,l.jsx)("img",{src:eo[t],alt:"",style:{height:"20px",width:"20px",marginRight:"8px",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),(0,l.jsx)("span",{children:t})]})},e))})}),(0,l.jsx)(r.Form.Item,{name:"mode",label:"Mode",tooltip:"How the guardrail should be applied",rules:[{required:!0,message:"Please select a mode"}],children:(0,l.jsx)(n.Select,{children:_?.supported_modes?.map(e=>(0,l.jsx)(tr,{value:e,children:e},e))||(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tr,{value:"pre_call",children:"pre_call"}),(0,l.jsx)(tr,{value:"post_call",children:"post_call"})]})})}),(0,l.jsx)(r.Form.Item,{name:"default_on",label:"Always On",tooltip:"If enabled, this guardrail will be applied to all requests by default",valuePropName:"checked",children:(0,l.jsx)(D.Switch,{})}),(0,l.jsx)(r.Form.Item,{name:"skip_system_message_choice",label:"Skip system messages in guardrail",tooltip:"Unified guardrails only: whether role: system content is omitted from guardrail input (LLM still receives full messages). Use global default follows litellm_settings.skip_system_message_in_guardrail.",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(tr,{value:"inherit",children:"Use global default"}),(0,l.jsx)(tr,{value:"yes",children:"Yes — exclude from guardrail scan"}),(0,l.jsx)(tr,{value:"no",children:"No — always include in scan"})]})}),(()=>{if(!y)return null;if("PresidioPII"===y)return _&&y&&"PresidioPII"===y?(0,l.jsx)(eE,{entities:_.supported_entities,actions:_.supported_actions,selectedEntities:v,selectedActions:N,onEntitySelect:S,onActionSelect:k,entityCategories:_.pii_entity_categories}):null;switch(y){case"Aporia":return(0,l.jsx)(r.Form.Item,{label:"Aporia Configuration",name:"config",tooltip:"JSON configuration for Aporia",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "api_key": "your_aporia_api_key", - "project_name": "your_project_name" -}`})});case"AimSecurity":return(0,l.jsx)(r.Form.Item,{label:"Aim Security Configuration",name:"config",tooltip:"JSON configuration for Aim Security",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "api_key": "your_aim_api_key" -}`})});case"Bedrock":return(0,l.jsx)(r.Form.Item,{label:"Amazon Bedrock Configuration",name:"config",tooltip:"JSON configuration for Amazon Bedrock guardrails",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "guardrail_id": "your_guardrail_id", - "guardrail_version": "your_guardrail_version" -}`})});case"GuardrailsAI":return(0,l.jsx)(r.Form.Item,{label:"Guardrails.ai Configuration",name:"config",tooltip:"JSON configuration for Guardrails.ai",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "api_key": "your_guardrails_api_key", - "guardrail_id": "your_guardrail_id" -}`})});case"LakeraAI":return(0,l.jsx)(r.Form.Item,{label:"Lakera AI Configuration",name:"config",tooltip:"JSON configuration for Lakera AI",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "api_key": "your_lakera_api_key" -}`})});case"PromptInjection":return(0,l.jsx)(r.Form.Item,{label:"Prompt Injection Configuration",name:"config",tooltip:"JSON configuration for prompt injection detection",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "threshold": 0.8 -}`})});default:return(0,l.jsx)(r.Form.Item,{label:"Custom Configuration",name:"config",tooltip:"JSON configuration for your custom guardrail",children:(0,l.jsx)(i.Input.TextArea,{rows:4,placeholder:`{ - "key1": "value1", - "key2": "value2" -}`})})}})(),(0,l.jsxs)("div",{className:"flex justify-end space-x-2 mt-4",children:[(0,l.jsx)(e4.Button,{variant:"secondary",onClick:t,children:"Cancel"}),(0,l.jsx)(e4.Button,{onClick:I,loading:h,children:"Update Guardrail"})]})]})})};var ts=((a={}).DB="db",a.CONFIG="config",a);e.s(["default",0,({guardrailsList:e,isLoading:t,onDeleteClick:a,accessToken:r,onGuardrailUpdated:i,isAdmin:s=!1,onGuardrailClick:n})=>{let[o,d]=(0,m.useState)([{id:"created_at",desc:!0}]),[c,u]=(0,m.useState)(!1),[p,g]=(0,m.useState)(null),x=e=>e?new Date(e).toLocaleString():"-",h=[{header:"Guardrail ID",accessorKey:"guardrail_id",cell:e=>(0,l.jsx)(ej.Tooltip,{title:String(e.getValue()||""),children:(0,l.jsx)(e4.Button,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate max-w-[200px]",onClick:()=>e.getValue()&&n(e.getValue()),children:e.getValue()?`${String(e.getValue()).slice(0,7)}...`:""})})},{header:"Name",accessorKey:"guardrail_name",cell:({row:e})=>{let t=e.original;return(0,l.jsx)(ej.Tooltip,{title:t.guardrail_name,children:(0,l.jsx)("span",{className:"text-xs font-medium",children:t.guardrail_name||"-"})})}},{header:"Provider",accessorKey:"litellm_params.guardrail",cell:({row:e})=>{let{logo:t,displayName:a}=ed(e.original.litellm_params.guardrail);return(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[t&&(0,l.jsx)("img",{src:t,alt:`${a} logo`,className:"w-4 h-4",onError:e=>{e.target.style.display="none"}}),(0,l.jsx)("span",{className:"text-xs",children:a})]})}},{header:"Mode",accessorKey:"litellm_params.mode",cell:({row:e})=>{let t=e.original;return(0,l.jsx)("span",{className:"text-xs",children:t.litellm_params.mode})}},{header:"Default On",accessorKey:"litellm_params.default_on",cell:({row:e})=>{let t=e.original;return(0,l.jsx)(e7.Badge,{color:t.litellm_params?.default_on?"green":"gray",className:"text-xs font-normal",size:"xs",children:t.litellm_params?.default_on?"Default On":"Default Off"})}},{header:"Created At",accessorKey:"created_at",cell:({row:e})=>{let t=e.original;return(0,l.jsx)(ej.Tooltip,{title:t.created_at,children:(0,l.jsx)("span",{className:"text-xs",children:x(t.created_at)})})}},{header:"Updated At",accessorKey:"updated_at",cell:({row:e})=>{let t=e.original;return(0,l.jsx)(ej.Tooltip,{title:t.updated_at,children:(0,l.jsx)("span",{className:"text-xs",children:x(t.updated_at)})})}},{id:"actions",header:"Actions",cell:({row:e})=>{let t=e.original,r=t.guardrail_definition_location===ts.CONFIG;return(0,l.jsx)("div",{className:"flex space-x-2",children:r?(0,l.jsx)(ej.Tooltip,{title:"Config guardrail cannot be deleted on the dashboard. Please delete it from the config file.",children:(0,l.jsx)(e2.Icon,{"data-testid":"config-delete-icon",icon:e5.TrashIcon,size:"sm",className:"cursor-not-allowed text-gray-400",title:"Config guardrail cannot be deleted on the dashboard. Please delete it from the config file.","aria-label":"Delete guardrail (config)"})}):(0,l.jsx)(ej.Tooltip,{title:"Delete guardrail",children:(0,l.jsx)(e2.Icon,{icon:e5.TrashIcon,size:"sm",onClick:()=>t.guardrail_id&&a(t.guardrail_id,t.guardrail_name||"Unnamed Guardrail"),className:"cursor-pointer hover:text-red-500"})})})}}],f=(0,e9.useReactTable)({data:e,columns:h,state:{sorting:o},onSortingChange:d,getCoreRowModel:(0,te.getCoreRowModel)(),getSortedRowModel:(0,te.getSortedRowModel)(),enableSorting:!0});return(0,l.jsxs)("div",{className:"rounded-lg custom-border relative",children:[(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)(eY.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",children:[(0,l.jsx)(eX.TableHead,{children:f.getHeaderGroups().map(e=>(0,l.jsx)(e1.TableRow,{children:e.headers.map(e=>(0,l.jsx)(e0.TableHeaderCell,{className:`py-1 h-8 ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,onClick:e.column.getToggleSortingHandler(),children:(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,l.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,e9.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&(0,l.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,l.jsx)(e8.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,l.jsx)(e3.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,l.jsx)(e6.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]})},e.id))},e.id))}),(0,l.jsx)(eQ.TableBody,{children:t?(0,l.jsx)(e1.TableRow,{children:(0,l.jsx)(eZ.TableCell,{colSpan:h.length,className:"h-8 text-center",children:(0,l.jsx)("div",{className:"text-center text-gray-500",children:(0,l.jsx)("p",{children:"Loading..."})})})}):e.length>0?f.getRowModel().rows.map(e=>(0,l.jsx)(e1.TableRow,{className:"h-8",children:e.getVisibleCells().map(e=>(0,l.jsx)(eZ.TableCell,{className:`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,children:(0,e9.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,l.jsx)(e1.TableRow,{children:(0,l.jsx)(eZ.TableCell,{colSpan:h.length,className:"h-8 text-center",children:(0,l.jsx)("div",{className:"text-center text-gray-500",children:(0,l.jsx)("p",{children:"No guardrails found"})})})})})]})}),p&&(0,l.jsx)(ti,{visible:c,onClose:()=>u(!1),accessToken:r,onSuccess:()=>{u(!1),g(null),i()},guardrailId:p.guardrail_id||"",fullLitellmParams:p.litellm_params,initialValues:{guardrail_name:p.guardrail_name||"",provider:Object.keys(ea).find(e=>ea[e]===p?.litellm_params.guardrail)||"",mode:p.litellm_params.mode,default_on:p.litellm_params.default_on,pii_entities_config:p.litellm_params.pii_entities_config,skip_system_message_choice:ec(p.litellm_params?.skip_system_message_in_guardrail),...p.guardrail_info}})]})}],782719);var tn=e.i(500330),to=e.i(245094),eN=eN,td=e.i(530212),tc=e.i(350967),tm=e.i(197647),tu=e.i(653824),tp=e.i(881073),tg=e.i(404206),tx=e.i(723731),th=e.i(629569),tf=e.i(678784),ty=e.i(118366),tj=e.i(560445);let{Text:t_}=d.Typography,{Option:tb}=n.Select,tv=({categories:e,onActionChange:t,onSeverityChange:a,onRemove:r,readOnly:i=!1})=>{let s=[{title:"Category",dataIndex:"display_name",key:"display_name",render:(e,t)=>(0,l.jsxs)("div",{children:[(0,l.jsx)(t_,{strong:!0,children:e}),e!==t.category&&(0,l.jsx)("div",{children:(0,l.jsx)(t_,{type:"secondary",style:{fontSize:12},children:t.category})})]})},{title:"Severity Threshold",dataIndex:"severity_threshold",key:"severity_threshold",width:180,render:(e,t)=>i?(0,l.jsx)(o.Tag,{color:{high:"red",medium:"orange",low:"yellow"}[e],children:e.toUpperCase()}):(0,l.jsxs)(n.Select,{value:e,onChange:e=>a?.(t.id,e),style:{width:150},size:"small",children:[(0,l.jsx)(tb,{value:"high",children:"High"}),(0,l.jsx)(tb,{value:"medium",children:"Medium"}),(0,l.jsx)(tb,{value:"low",children:"Low"})]})},{title:"Action",dataIndex:"action",key:"action",width:150,render:(e,a)=>i?(0,l.jsx)(o.Tag,{color:"BLOCK"===e?"red":"blue",children:e}):(0,l.jsxs)(n.Select,{value:e,onChange:e=>t?.(a.id,e),style:{width:120},size:"small",children:[(0,l.jsx)(tb,{value:"BLOCK",children:"Block"}),(0,l.jsx)(tb,{value:"MASK",children:"Mask"})]})}];return(i||s.push({title:"",key:"actions",width:100,render:(e,t)=>(0,l.jsx)(c.Button,{type:"text",danger:!0,size:"small",icon:(0,l.jsx)(A.DeleteOutlined,{}),onClick:()=>r?.(t.id),children:"Delete"})}),0===e.length)?(0,l.jsx)("div",{style:{textAlign:"center",padding:"40px 0",color:"#999"},children:"No categories configured."}):(0,l.jsx)(I.Table,{dataSource:e,columns:s,rowKey:"id",pagination:!1,size:"small"})},tw=({patterns:e,blockedWords:t,categories:a=[],readOnly:r=!0,onPatternActionChange:i,onPatternRemove:s,onBlockedWordUpdate:n,onBlockedWordRemove:o,onCategoryActionChange:d,onCategorySeverityChange:c,onCategoryRemove:m})=>{if(0===e.length&&0===t.length&&0===a.length)return null;let u=()=>{};return(0,l.jsxs)(l.Fragment,{children:[a.length>0&&(0,l.jsxs)(eM.Card,{className:"mt-6",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,l.jsx)(eR.Text,{className:"text-lg font-semibold",children:"Content Categories"}),(0,l.jsxs)(e7.Badge,{color:"blue",children:[a.length," categories configured"]})]}),(0,l.jsx)(tv,{categories:a,onActionChange:r?void 0:d,onSeverityChange:r?void 0:c,onRemove:r?void 0:m,readOnly:r})]}),e.length>0&&(0,l.jsxs)(eM.Card,{className:"mt-6",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,l.jsx)(eR.Text,{className:"text-lg font-semibold",children:"Pattern Detection"}),(0,l.jsxs)(e7.Badge,{color:"blue",children:[e.length," patterns configured"]})]}),(0,l.jsx)(P,{patterns:e,onActionChange:r?u:i||u,onRemove:r?u:s||u})]}),t.length>0&&(0,l.jsxs)(eM.Card,{className:"mt-6",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,l.jsx)(eR.Text,{className:"text-lg font-semibold",children:"Blocked Keywords"}),(0,l.jsxs)(e7.Badge,{color:"blue",children:[t.length," keywords configured"]})]}),(0,l.jsx)(F,{keywords:t,onActionChange:r?u:n||u,onRemove:r?u:o||u})]})]})},{Text:tN}=d.Typography,tC=({guardrailData:e,guardrailSettings:t,isEditing:a,accessToken:r,onDataChange:i,onUnsavedChanges:s})=>{let[n,o]=(0,m.useState)([]),[d,c]=(0,m.useState)([]),[u,p]=(0,m.useState)([]),[g,x]=(0,m.useState)([]),[h,f]=(0,m.useState)([]),[y,j]=(0,m.useState)([]),[_,b]=(0,m.useState)(!1),[v,w]=(0,m.useState)(null),[N,C]=(0,m.useState)(!1),[S,k]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(e?.litellm_params?.patterns){let t=e.litellm_params.patterns.map((e,t)=>({id:`pattern-${t}`,type:"prebuilt"===e.pattern_type?"prebuilt":"custom",name:e.pattern_name||e.name,display_name:e.display_name,pattern:e.pattern,action:e.action||"BLOCK"}));o(t),x(t)}else o([]),x([]);if(e?.litellm_params?.blocked_words){let t=e.litellm_params.blocked_words.map((e,t)=>({id:`word-${t}`,keyword:e.keyword,action:e.action||"BLOCK",description:e.description}));c(t),f(t)}else c([]),f([]);if(e?.litellm_params?.categories?.length>0){let a=t?.content_filter_settings?.content_categories?Object.fromEntries(t.content_filter_settings.content_categories.map(e=>[e.name,e])):{},l=e.litellm_params.categories.map((e,t)=>{let l=a[e.category];return{id:`category-${t}`,category:e.category,display_name:l?.display_name??e.category,action:e.action||"BLOCK",severity_threshold:e.severity_threshold||"medium"}});p(l),j(l)}else p([]),j([]);let a=e?.litellm_params?.competitor_intent_config;if(a&&"object"==typeof a){let e=!!(a.brand_self&&Array.isArray(a.brand_self)&&a.brand_self.length>0),t={competitor_intent_type:a.competitor_intent_type??"airline",brand_self:Array.isArray(a.brand_self)?a.brand_self:[],locations:Array.isArray(a.locations)?a.locations:[],competitors:Array.isArray(a.competitors)?a.competitors:[],policy:a.policy??{competitor_comparison:"refuse",possible_competitor_comparison:"reframe"},threshold_high:"number"==typeof a.threshold_high?a.threshold_high:.7,threshold_medium:"number"==typeof a.threshold_medium?a.threshold_medium:.45,threshold_low:"number"==typeof a.threshold_low?a.threshold_low:.3};b(e),w(t),C(e),k(t)}else b(!1),w(null),C(!1),k(null)},[e,t?.content_filter_settings?.content_categories]),(0,m.useEffect)(()=>{i&&i(n,d,u,_,v)},[n,d,u,_,v,i]);let I=m.default.useMemo(()=>{let e=JSON.stringify(n)!==JSON.stringify(g),t=JSON.stringify(d)!==JSON.stringify(h),a=JSON.stringify(u)!==JSON.stringify(y),l=_!==N||JSON.stringify(v)!==JSON.stringify(S);return e||t||a||l},[n,d,u,_,v,g,h,y,N,S]);return((0,m.useEffect)(()=>{a&&s&&s(I)},[I,a,s]),e?.litellm_params?.guardrail!=="litellm_content_filter")?null:a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eG.Divider,{orientation:"left",children:"Content Filter Configuration"}),I&&(0,l.jsx)(tj.Alert,{type:"warning",showIcon:!0,className:"mb-4",message:(0,l.jsx)(tN,{children:'You have unsaved changes to patterns or keywords. Remember to click "Save Changes" at the bottom.'})}),(0,l.jsx)("div",{className:"mb-6",children:t&&t.content_filter_settings&&(0,l.jsx)(Q,{prebuiltPatterns:t.content_filter_settings.prebuilt_patterns||[],categories:t.content_filter_settings.pattern_categories||[],selectedPatterns:n,blockedWords:d,onPatternAdd:e=>o([...n,e]),onPatternRemove:e=>o(n.filter(t=>t.id!==e)),onPatternActionChange:(e,t)=>o(n.map(a=>a.id===e?{...a,action:t}:a)),onBlockedWordAdd:e=>c([...d,e]),onBlockedWordRemove:e=>c(d.filter(t=>t.id!==e)),onBlockedWordUpdate:(e,t,a)=>c(d.map(l=>l.id===e?{...l,[t]:a}:l)),onFileUpload:e=>{console.log("File uploaded:",e)},accessToken:r,contentCategories:t.content_filter_settings.content_categories||[],selectedContentCategories:u,onContentCategoryAdd:e=>p([...u,e]),onContentCategoryRemove:e=>p(u.filter(t=>t.id!==e)),onContentCategoryUpdate:(e,t,a)=>p(u.map(l=>l.id===e?{...l,[t]:a}:l)),competitorIntentEnabled:_,competitorIntentConfig:v,onCompetitorIntentChange:(e,t)=>{b(e),w(t)}})})]}):(0,l.jsx)(tw,{patterns:n,blockedWords:d,categories:u,readOnly:!0})};var tS=e.i(788191),tk=e.i(245704),tI=e.i(518617);let tA={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M715.8 493.5L335 165.1c-14.2-12.2-35-1.2-35 18.5v656.8c0 19.7 20.8 30.7 35 18.5l380.8-328.4c10.9-9.4 10.9-27.6 0-37z"}}]},name:"caret-right",theme:"outlined"};var tO=m.forwardRef(function(e,t){return m.createElement(eI.default,(0,eS.default)({},e,{ref:t,icon:tA}))}),tT=e.i(987432);let tP={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M892 772h-80v-80c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v80h-80c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h80v80c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-80h80c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM373.5 498.4c-.9-8.7-1.4-17.5-1.4-26.4 0-15.9 1.5-31.4 4.3-46.5.7-3.6-1.2-7.3-4.5-8.8-13.6-6.1-26.1-14.5-36.9-25.1a127.54 127.54 0 01-38.7-95.4c.9-32.1 13.8-62.6 36.3-85.6 24.7-25.3 57.9-39.1 93.2-38.7 31.9.3 62.7 12.6 86 34.4 7.9 7.4 14.7 15.6 20.4 24.4 2 3.1 5.9 4.4 9.3 3.2 17.6-6.1 36.2-10.4 55.3-12.4 5.6-.6 8.8-6.6 6.3-11.6-32.5-64.3-98.9-108.7-175.7-109.9-110.8-1.7-203.2 89.2-203.2 200 0 62.8 28.9 118.8 74.2 155.5-31.8 14.7-61.1 35-86.5 60.4-54.8 54.7-85.8 126.9-87.8 204a8 8 0 008 8.2h56.1c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5 29.4-29.4 65.4-49.8 104.7-59.7 3.8-1.1 6.4-4.8 5.9-8.8zM824 472c0-109.4-87.9-198.3-196.9-200C516.3 270.3 424 361.2 424 472c0 62.8 29 118.8 74.2 155.5a300.95 300.95 0 00-86.4 60.4C357 742.6 326 814.8 324 891.8a8 8 0 008 8.2h56c4.3 0 7.9-3.4 8-7.7 1.9-58 25.4-112.3 66.7-153.5C505.8 695.7 563 672 624 672c110.4 0 200-89.5 200-200zm-109.5 90.5C690.3 586.7 658.2 600 624 600s-66.3-13.3-90.5-37.5a127.26 127.26 0 01-37.5-91.8c.3-32.8 13.4-64.5 36.3-88 24-24.6 56.1-38.3 90.4-38.7 33.9-.3 66.8 12.9 91 36.6 24.8 24.3 38.4 56.8 38.4 91.4-.1 34.2-13.4 66.3-37.6 90.5z"}}]},name:"usergroup-add",theme:"outlined"};var tL=m.forwardRef(function(e,t){return m.createElement(eI.default,(0,eS.default)({},e,{ref:t,icon:tP}))}),tB=e.i(872934);let{Panel:tF}=$.Collapse,{TextArea:t$}=i.Input,tE={empty:{name:"Empty Template",code:`async def apply_guardrail(inputs, request_data, input_type): - # inputs: {texts, images, tools, tool_calls, structured_messages, model} - # request_data: {model, user_id, team_id, end_user_id, metadata} - # input_type: "request" or "response" - return allow()`},blockSSN:{name:"Block SSN",code:`def apply_guardrail(inputs, request_data, input_type): - for text in inputs["texts"]: - if regex_match(text, r"\\d{3}-\\d{2}-\\d{4}"): - return block("SSN detected") - return allow()`},redactEmail:{name:"Redact Emails",code:`def apply_guardrail(inputs, request_data, input_type): - pattern = r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}" - modified = [] - for text in inputs["texts"]: - modified.append(regex_replace(text, pattern, "[EMAIL REDACTED]")) - return modify(texts=modified)`},blockSQL:{name:"Block SQL Injection",code:`def apply_guardrail(inputs, request_data, input_type): - if input_type != "request": - return allow() - for text in inputs["texts"]: - if contains_code_language(text, ["sql"]): - return block("SQL code not allowed") - return allow()`},validateJSON:{name:"Validate JSON",code:`def apply_guardrail(inputs, request_data, input_type): - if input_type != "response": - return allow() - - schema = {"type": "object", "required": ["name", "value"]} - - for text in inputs["texts"]: - obj = json_parse(text) - if obj is None: - return block("Invalid JSON response") - if not json_schema_valid(obj, schema): - return block("Response missing required fields") - return allow()`},externalAPI:{name:"External API Check (async)",code:`async def apply_guardrail(inputs, request_data, input_type): - # Call an external moderation API (async for non-blocking) - for text in inputs["texts"]: - response = await http_post( - "https://api.example.com/moderate", - body={"text": text, "user_id": request_data["user_id"]}, - headers={"Authorization": "Bearer YOUR_API_KEY"}, - timeout=10 - ) - - if not response["success"]: - # API call failed, allow by default or block - return allow() - - if response["body"].get("flagged"): - return block(response["body"].get("reason", "Content flagged")) - - return allow()`}},tM={"Return Values":[{name:"allow()",desc:"Let request/response through"},{name:"block(reason)",desc:"Reject with message"},{name:"modify(texts=[], images=[], tool_calls=[])",desc:"Transform content"}],"HTTP Requests (async)":[{name:"await http_request(url, method, headers, body)",desc:"Make async HTTP request"},{name:"await http_get(url, headers)",desc:"Async GET request"},{name:"await http_post(url, body, headers)",desc:"Async POST request"}],"Regex Functions":[{name:"regex_match(text, pattern)",desc:"Returns True if pattern found"},{name:"regex_replace(text, pattern, replacement)",desc:"Replace all matches"},{name:"regex_find_all(text, pattern)",desc:"Return list of matches"}],"JSON Functions":[{name:"json_parse(text)",desc:"Parse JSON string, returns None on error"},{name:"json_stringify(obj)",desc:"Convert to JSON string"},{name:"json_schema_valid(obj, schema)",desc:"Validate against JSON schema"}],"URL Functions":[{name:"extract_urls(text)",desc:"Extract all URLs from text"},{name:"is_valid_url(url)",desc:"Check if URL is valid"},{name:"all_urls_valid(text)",desc:"Check all URLs in text are valid"}],"Code Detection":[{name:"detect_code(text)",desc:"Returns True if code detected"},{name:"detect_code_languages(text)",desc:"Returns list of detected languages"},{name:'contains_code_language(text, ["sql"])',desc:"Check for specific languages"}],"Text Utilities":[{name:"contains(text, substring)",desc:"Check if substring exists"},{name:"contains_any(text, [substr1, substr2])",desc:"Check if any substring exists"},{name:"word_count(text)",desc:"Count words"},{name:"char_count(text)",desc:"Count characters"},{name:"lower(text) / upper(text) / trim(text)",desc:"String transforms"}]},tR=[{value:"pre_call",label:"pre_call (Request)"},{value:"post_call",label:"post_call (Response)"},{value:"during_call",label:"during_call (Parallel)"},{value:"logging_only",label:"logging_only"},{value:"pre_mcp_call",label:"pre_mcp_call (Before MCP Tool Call)"},{value:"post_mcp_call",label:"post_mcp_call (After MCP Tool Call)"},{value:"during_mcp_call",label:"during_mcp_call (During MCP Tool Call)"}],tG=({visible:e,onClose:t,onSuccess:a,accessToken:r,editData:i})=>{let o=!!i,[d,c]=(0,m.useState)(""),[g,x]=(0,m.useState)(["pre_call"]),[h,f]=(0,m.useState)(!1),[y,j]=(0,m.useState)("empty"),[_,b]=(0,m.useState)(tE.empty.code),[v,w]=(0,m.useState)(!1),[N,C]=(0,m.useState)(!1),[S,k]=(0,m.useState)(!1),I={texts:["Hello, my SSN is 123-45-6789"],images:[],tools:[{type:"function",function:{name:"get_weather",description:"Get the current weather in a location",parameters:{type:"object",properties:{location:{type:"string",description:"City name"}},required:["location"]}}}],tool_calls:[],structured_messages:[{role:"system",content:"You are a helpful assistant."},{role:"user",content:"Hello, my SSN is 123-45-6789"}],model:"gpt-4"},A={texts:["The weather in San Francisco is 72°F and sunny."],images:[],tools:[],tool_calls:[{id:"call_abc123",type:"function",function:{name:"get_weather",arguments:'{"location": "San Francisco"}'}}],structured_messages:[],model:"gpt-4"},O={texts:['Tool: read_wiki_structure\nArguments: {"repoName": "BerriAI/litellm"}'],images:[],tools:[{type:"function",function:{name:"read_wiki_structure",description:"Read the structure of a GitHub repository (MCP tool passed as OpenAI tool)",parameters:{type:"object",properties:{repoName:{type:"string",description:"Repository name, e.g. BerriAI/litellm"}},required:["repoName"]}}}],tool_calls:[{id:"call_mcp_001",type:"function",function:{name:"read_wiki_structure",arguments:'{"repoName": "BerriAI/litellm"}'}}],structured_messages:[{role:"user",content:'Tool: read_wiki_structure\nArguments: {"repoName": "BerriAI/litellm"}'}],model:"mcp-tool-call"},[T,P]=(0,m.useState)(JSON.stringify(I,null,2)),[L,B]=(0,m.useState)(null),[F,E]=(0,m.useState)(null),M=(0,m.useRef)(null),R=e=>null==e?["pre_call"]:Array.isArray(e)?e.length?e:["pre_call"]:[e];(0,m.useEffect)(()=>{e&&(i?(c(i.guardrail_name||""),x(R(i.litellm_params?.mode)),f(i.litellm_params?.default_on||!1),b(i.litellm_params?.custom_code||tE.empty.code),j("")):(c(""),x(["pre_call"]),f(!1),j("empty"),b(tE.empty.code)),B(null),k(!1))},[e,i]);let G=async e=>{try{await navigator.clipboard.writeText(e),E(e),setTimeout(()=>E(null),2e3)}catch(e){console.error("Failed to copy:",e)}},z=async()=>{if(!d.trim())return void u.default.fromBackend("Please enter a guardrail name");if(!_.trim())return void u.default.fromBackend("Please enter custom code");if(!r)return void u.default.fromBackend("No access token available");w(!0);try{if(o&&i){let e={litellm_params:{custom_code:_}};d!==i.guardrail_name&&(e.guardrail_name=d);let t=R(i.litellm_params?.mode);(g.length!==t.length||g.some((e,a)=>e!==t[a]))&&(e.litellm_params.mode=g),h!==i.litellm_params?.default_on&&(e.litellm_params.default_on=h),await (0,p.updateGuardrailCall)(r,i.guardrail_id,e),u.default.success("Custom code guardrail updated successfully")}else await (0,p.createGuardrailCall)(r,{guardrail_name:d,litellm_params:{guardrail:"custom_code",mode:g,default_on:h,custom_code:_},guardrail_info:{}}),u.default.success("Custom code guardrail created successfully");a(),t()}catch(e){console.error("Failed to save guardrail:",e),u.default.fromBackend(`Failed to ${o?"update":"create"} guardrail: `+(e instanceof Error?e.message:String(e)))}finally{w(!1)}},K=async()=>{if(!r)return void B({error:"No access token available"});C(!0),B(null);try{let e;try{e=JSON.parse(T)}catch(e){B({error:"Invalid test input JSON"}),C(!1);return}e.texts||(e.texts=[]);let t=["pre_call","pre_mcp_call"],a=["post_call","post_mcp_call"],l=g.some(e=>t.includes(e))?"request":g.some(e=>a.includes(e))?"response":"request",i=await (0,p.testCustomCodeGuardrail)(r,{custom_code:_,test_input:e,input_type:l,request_data:{model:"test-model",metadata:{}}});i.success&&i.result?B(i.result):i.error?B({error:i.error,error_type:i.error_type}):B({error:"Unknown error occurred"})}catch(e){console.error("Failed to test custom code:",e),B({error:e instanceof Error?e.message:"Failed to test custom code"})}finally{C(!1)}},H=_.split("\n").length;return(0,l.jsxs)(s.Modal,{open:e,onCancel:t,footer:null,width:1400,className:"custom-code-modal",closable:!0,destroyOnClose:!0,children:[(0,l.jsxs)("div",{className:"flex flex-col h-[80vh]",children:[(0,l.jsxs)("div",{className:"pb-4 border-b border-gray-200",children:[(0,l.jsx)("h2",{className:"text-xl font-semibold text-gray-900",children:o?"Edit Custom Guardrail":"Create Custom Guardrail"}),(0,l.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Define custom logic using Python-like syntax"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-4 py-4 border-b border-gray-100",children:[(0,l.jsxs)("div",{className:"flex-1 max-w-[200px]",children:[(0,l.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Guardrail Name"}),(0,l.jsx)(tt.TextInput,{value:d,onValueChange:c,placeholder:"e.g., block-pii-custom"})]}),(0,l.jsxs)("div",{className:"w-[280px]",children:[(0,l.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Mode (can select multiple)"}),(0,l.jsx)(n.Select,{mode:"multiple",value:g,onChange:x,options:tR,className:"w-full",size:"middle",placeholder:"Select modes"})]}),(0,l.jsxs)("div",{className:"w-[180px]",children:[(0,l.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Template"}),(0,l.jsx)(n.Select,{value:y,onChange:e=>{j(e),b(tE[e].code)},className:"w-full",size:"middle",dropdownRender:e=>(0,l.jsxs)(l.Fragment,{children:[e,(0,l.jsx)(eG.Divider,{style:{margin:"8px 0"}}),(0,l.jsxs)("div",{style:{padding:"8px 12px",cursor:"pointer",color:"#1890ff",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},onClick:e=>{e.preventDefault(),window.open("https://models.litellm.ai/guardrails","_blank")},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#f0f0f0"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[(0,l.jsx)(tL,{}),(0,l.jsx)("span",{children:"Browse Community templates"}),(0,l.jsx)(tB.ExportOutlined,{style:{fontSize:"10px"}})]})]}),children:(0,l.jsx)(n.Select.OptGroup,{label:"STANDARD",children:Object.entries(tE).map(([e,t])=>(0,l.jsx)(n.Select.Option,{value:e,children:t.name},e))})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 pt-5",children:[(0,l.jsx)("span",{className:"text-sm text-gray-600",children:"Default On"}),(0,l.jsx)(D.Switch,{checked:h,onChange:f})]})]}),(0,l.jsxs)("div",{className:"flex flex-1 overflow-hidden mt-4 gap-6",children:[(0,l.jsxs)("div",{className:"flex-[2] flex flex-col min-w-0 overflow-y-auto",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2 flex-shrink-0",children:[(0,l.jsx)("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Python Logic"}),(0,l.jsx)("span",{className:"text-xs text-gray-400",children:"Restricted environment (no imports)"})]}),(0,l.jsxs)("div",{className:"relative rounded-lg overflow-hidden border border-gray-700 bg-[#1e1e1e] flex-shrink-0",style:{minHeight:"300px",maxHeight:"400px"},children:[(0,l.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-12 bg-[#1e1e1e] border-r border-gray-700 text-right pr-3 pt-3 select-none overflow-hidden",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace",fontSize:"14px",lineHeight:"1.6"},children:Array.from({length:Math.max(H,20)},(e,t)=>(0,l.jsx)("div",{className:"text-gray-500 h-[22.4px]",children:t+1},t+1))}),(0,l.jsx)("textarea",{ref:M,value:_,onChange:e=>b(e.target.value),onKeyDown:e=>{if("Tab"===e.key){e.preventDefault();let t=e.currentTarget,a=t.selectionStart,l=t.selectionEnd;b(_.substring(0,a)+" "+_.substring(l)),setTimeout(()=>{t.selectionStart=t.selectionEnd=a+4},0)}},spellCheck:!1,className:"w-full h-full pl-14 pr-4 pt-3 pb-3 resize-none focus:outline-none bg-transparent text-gray-200",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace",fontSize:"14px",lineHeight:"1.6",tabSize:4}})]}),(0,l.jsx)($.Collapse,{activeKey:S?["test"]:[],onChange:e=>k(e.includes("test")),className:"mt-3 bg-white border border-gray-200 rounded-lg flex-shrink-0",expandIcon:({isActive:e})=>(0,l.jsx)(tO,{rotate:90*!!e}),children:(0,l.jsx)(tF,{header:(0,l.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,l.jsx)(tS.PlayCircleOutlined,{className:"text-blue-500"}),"Test Your Guardrail"]}),children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("label",{className:"block text-xs font-medium text-gray-600",children:"Test Input (JSON)"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-xs text-gray-500",children:"Load example:"}),(0,l.jsx)("button",{type:"button",onClick:()=>P(JSON.stringify(I,null,2)),className:"px-2 py-1 text-xs rounded border border-orange-200 bg-orange-50 text-orange-700 hover:bg-orange-100 transition-colors",children:"Pre-call"}),(0,l.jsx)("button",{type:"button",onClick:()=>P(JSON.stringify(O,null,2)),className:"px-2 py-1 text-xs rounded border border-purple-200 bg-purple-50 text-purple-700 hover:bg-purple-100 transition-colors",children:"Pre MCP"}),(0,l.jsx)("button",{type:"button",onClick:()=>P(JSON.stringify(A,null,2)),className:"px-2 py-1 text-xs rounded border border-green-200 bg-green-50 text-green-700 hover:bg-green-100 transition-colors",children:"Post-call"})]})]}),(0,l.jsx)("div",{className:"mb-2 p-2 bg-gray-50 rounded text-xs text-gray-600 border border-gray-200",children:(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"texts"}),": Message content (always)"]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"images"}),": Base64 images (vision)"]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"tools"}),": Tool definitions ",(0,l.jsx)("span",{className:"text-orange-600",children:"(pre_call)"}),", MCP as OpenAI tool ",(0,l.jsx)("span",{className:"text-purple-600",children:"(pre_mcp_call)"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"tool_calls"}),": LLM tool calls ",(0,l.jsx)("span",{className:"text-green-600",children:"(post_call)"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"structured_messages"}),": Full messages ",(0,l.jsx)("span",{className:"text-orange-600",children:"(pre_call)"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"model"}),": Model name (always)"]})]})}),(0,l.jsx)(t$,{value:T,onChange:e=>P(e.target.value),rows:8,className:"font-mono text-xs",placeholder:'{"texts": ["test message"], ...}'})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(e4.Button,{size:"xs",onClick:K,disabled:N,icon:tS.PlayCircleOutlined,children:N?"Running...":"Run Test"}),L&&(0,l.jsx)("div",{className:`flex items-center gap-2 text-sm ${L.error?"text-red-600":"allow"===L.action?"text-green-600":"block"===L.action?"text-orange-600":"text-blue-600"}`,children:L.error?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tI.CloseCircleOutlined,{}),(0,l.jsxs)("span",{children:[L.error_type&&(0,l.jsxs)("span",{className:"font-medium",children:["[",L.error_type,"] "]}),L.error]})]}):"allow"===L.action?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tk.CheckCircleOutlined,{})," Allowed"]}):"block"===L.action?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tI.CloseCircleOutlined,{})," Blocked: ",L.reason]}):"modify"===L.action?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tk.CheckCircleOutlined,{})," Modified",L.texts&&L.texts.length>0&&(0,l.jsxs)("span",{className:"text-xs text-gray-500 ml-1",children:["→ ",L.texts[0].substring(0,50),L.texts[0].length>50?"...":""]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(tk.CheckCircleOutlined,{})," ",L.action||"Unknown"]})})]})]})},"test")}),(0,l.jsxs)("div",{className:"mt-3 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200 rounded-lg flex items-center justify-between flex-shrink-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"bg-blue-100 rounded-full p-2",children:(0,l.jsx)(tL,{className:"text-blue-600 text-lg"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-sm font-medium text-gray-900",children:"Built a useful guardrail?"}),(0,l.jsx)("div",{className:"text-xs text-gray-600",children:"Share it with the community and help others build faster"})]})]}),(0,l.jsx)(e4.Button,{size:"xs",onClick:()=>window.open("https://github.com/BerriAI/litellm-guardrails","_blank"),icon:tB.ExportOutlined,className:"bg-blue-600 hover:bg-blue-700 text-white border-0",children:"Contribute Template"})]})]}),(0,l.jsxs)("div",{className:"w-[300px] flex-shrink-0 overflow-auto border-l border-gray-200 pl-6",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,l.jsx)(to.CodeOutlined,{className:"text-blue-500"}),(0,l.jsx)("span",{className:"font-semibold text-gray-700",children:"Available Primitives"})]}),(0,l.jsx)("p",{className:"text-xs text-gray-500 mb-3",children:"Click to copy functions to clipboard"}),(0,l.jsx)($.Collapse,{defaultActiveKey:["Return Values"],className:"primitives-collapse bg-transparent border-0",expandIconPosition:"end",children:Object.entries(tM).map(([e,t])=>(0,l.jsx)(tF,{header:(0,l.jsx)("span",{className:"text-sm font-medium text-gray-700",children:e}),className:"bg-white mb-2 rounded-lg border border-gray-200",children:(0,l.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,l.jsx)("button",{onClick:()=>G(e.name),className:`w-full text-left px-2 py-2 rounded transition-colors ${F===e.name?"bg-green-100":"bg-gray-50 hover:bg-blue-50"}`,children:F===e.name?(0,l.jsxs)("span",{className:"flex items-center gap-1 text-xs font-mono text-green-700",children:[(0,l.jsx)(tk.CheckCircleOutlined,{})," Copied!"]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"text-xs font-mono text-gray-800",children:e.name}),(0,l.jsx)("div",{className:"text-[10px] text-gray-500 mt-0.5",children:e.desc})]})},e.name))})},e))})]})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between pt-4 mt-4 border-t border-gray-200",children:[(0,l.jsx)("span",{className:"text-xs text-gray-400",children:"Changes are auto-saved to local draft"}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(e4.Button,{variant:"secondary",onClick:t,children:"Cancel"}),(0,l.jsx)(e4.Button,{onClick:z,loading:v,disabled:v||!d.trim(),icon:tT.SaveOutlined,children:o?"Update Guardrail":"Save Guardrail"})]})]})]}),(0,l.jsx)("style",{children:` - .custom-code-modal .ant-modal-content { - padding: 24px; - } - .custom-code-modal .ant-modal-close { - top: 20px; - right: 20px; - } - .primitives-collapse .ant-collapse-item { - border: none !important; - } - .primitives-collapse .ant-collapse-header { - padding: 8px 12px !important; - } - .primitives-collapse .ant-collapse-content-box { - padding: 8px 12px !important; - } - `})]})};e.s(["default",0,({guardrailId:e,onClose:t,accessToken:a,isAdmin:s})=>{let o,[d,g]=(0,m.useState)(null),[x,h]=(0,m.useState)(null),[f,y]=(0,m.useState)(!0),[j,_]=(0,m.useState)(!1),[b]=r.Form.useForm(),[v,w]=(0,m.useState)([]),[N,C]=(0,m.useState)({}),[S,k]=(0,m.useState)(null),[I,A]=(0,m.useState)({}),[O,T]=(0,m.useState)(!1),P={rules:[],default_action:"deny",on_disallowed_action:"block",violation_message_template:""},[L,B]=(0,m.useState)(P),[F,$]=(0,m.useState)(!1),[E,M]=(0,m.useState)(!1),R=m.default.useRef({patterns:[],blockedWords:[],categories:[]}),G=(0,m.useCallback)((e,t,a,l,r)=>{R.current={patterns:e,blockedWords:t,categories:a||[],competitorIntentEnabled:l,competitorIntentConfig:r}},[]),z=async()=>{try{if(y(!0),!a)return;let t=await (0,p.getGuardrailInfo)(a,e);if(g(t),t.litellm_params?.pii_entities_config){let e=t.litellm_params.pii_entities_config;if(w([]),C({}),Object.keys(e).length>0){let t=[],a={};Object.entries(e).forEach(([e,l])=>{t.push(e),a[e]="string"==typeof l?l:"MASK"}),w(t),C(a)}}else w([]),C({})}catch(e){u.default.fromBackend("Failed to load guardrail information"),console.error("Error fetching guardrail info:",e)}finally{y(!1)}},D=async()=>{try{if(!a)return;let e=await (0,p.getGuardrailProviderSpecificParams)(a);h(e)}catch(e){console.error("Error fetching guardrail provider specific params:",e)}},K=async()=>{try{if(!a)return;let e=await (0,p.getGuardrailUISettings)(a);k(e)}catch(e){console.error("Error fetching guardrail UI settings:",e)}};(0,m.useEffect)(()=>{D()},[a]),(0,m.useEffect)(()=>{z(),K()},[e,a]),(0,m.useEffect)(()=>{if(d&&b){let e={...d.litellm_params||{}};delete e.skip_system_message_in_guardrail,b.setFieldsValue({guardrail_name:d.guardrail_name,...e,skip_system_message_choice:ec(d.litellm_params?.skip_system_message_in_guardrail),guardrail_info:d.guardrail_info?JSON.stringify(d.guardrail_info,null,2):"",...d.litellm_params?.optional_params&&{optional_params:d.litellm_params.optional_params}})}},[d,x,b]);let H=(0,m.useCallback)(()=>{d?.litellm_params?.guardrail==="tool_permission"?B({rules:d.litellm_params?.rules||[],default_action:(d.litellm_params?.default_action||"deny").toLowerCase(),on_disallowed_action:(d.litellm_params?.on_disallowed_action||"block").toLowerCase(),violation_message_template:d.litellm_params?.violation_message_template||""}):B(P),$(!1)},[d]);(0,m.useEffect)(()=>{H()},[H]);let q=async t=>{try{if(!a)return;let o={litellm_params:{}};t.guardrail_name!==d.guardrail_name&&(o.guardrail_name=t.guardrail_name),t.default_on!==d.litellm_params?.default_on&&(o.litellm_params.default_on=t.default_on);let c=ec(d.litellm_params?.skip_system_message_in_guardrail),m=t.skip_system_message_choice;void 0!==m&&m!==c&&("inherit"===m?o.litellm_params.skip_system_message_in_guardrail=null:"yes"===m?o.litellm_params.skip_system_message_in_guardrail=!0:o.litellm_params.skip_system_message_in_guardrail=!1);let g=d.guardrail_info,h=t.guardrail_info?JSON.parse(t.guardrail_info):void 0;JSON.stringify(g)!==JSON.stringify(h)&&(o.guardrail_info=h);let f=d.litellm_params?.pii_entities_config||{},y={};if(v.forEach(e=>{y[e]=N[e]||"MASK"}),JSON.stringify(f)!==JSON.stringify(y)&&(o.litellm_params.pii_entities_config=y),d.litellm_params?.guardrail==="litellm_content_filter"&&O){var l,r,i,s,n;let e,t=(l=R.current.patterns||[],r=R.current.blockedWords||[],i=R.current.categories||[],s=R.current.competitorIntentEnabled,n=R.current.competitorIntentConfig,e={patterns:l.map(e=>({pattern_type:"prebuilt"===e.type?"prebuilt":"regex",pattern_name:"prebuilt"===e.type?e.name:void 0,pattern:"custom"===e.type?e.pattern:void 0,name:e.name,action:e.action})),blocked_words:r.map(e=>({keyword:e.keyword,action:e.action,description:e.description}))},void 0!==i&&(e.categories=i.map(e=>({category:e.category,enabled:!0,action:e.action,severity_threshold:e.severity_threshold||"medium"}))),s&&n&&n.brand_self.length>0&&(e.competitor_intent_config={competitor_intent_type:n.competitor_intent_type,brand_self:n.brand_self,locations:n.locations?.length?n.locations:void 0,competitors:"generic"===n.competitor_intent_type&&n.competitors?.length?n.competitors:void 0,policy:n.policy,threshold_high:n.threshold_high,threshold_medium:n.threshold_medium,threshold_low:n.threshold_low}),e);o.litellm_params.patterns=t.patterns,o.litellm_params.blocked_words=t.blocked_words,o.litellm_params.categories=t.categories,o.litellm_params.competitor_intent_config=t.competitor_intent_config??null}if(d.litellm_params?.guardrail==="tool_permission"){let e=d.litellm_params?.rules||[],t=L.rules||[],a=JSON.stringify(e)!==JSON.stringify(t),l=(d.litellm_params?.default_action||"deny").toLowerCase(),r=(L.default_action||"deny").toLowerCase(),i=l!==r,s=(d.litellm_params?.on_disallowed_action||"block").toLowerCase(),n=(L.on_disallowed_action||"block").toLowerCase(),c=s!==n,m=d.litellm_params?.violation_message_template||"",u=L.violation_message_template||"",p=m!==u;(F||a||i||c||p)&&(o.litellm_params.rules=t,o.litellm_params.default_action=r,o.litellm_params.on_disallowed_action=n,o.litellm_params.violation_message_template=u||null)}let j=Object.keys(ea).find(e=>ea[e]===d.litellm_params?.guardrail);console.log("values: ",JSON.stringify(t)),console.log("currentProvider: ",j);let b=d.litellm_params?.guardrail==="tool_permission";if(x&&j&&!b){let e=x[ea[j]?.toLowerCase()]||{},a=new Set;console.log("providerSpecificParams: ",JSON.stringify(e)),Object.keys(e).forEach(e=>{"optional_params"!==e&&a.add(e)}),e.optional_params&&e.optional_params.fields&&Object.keys(e.optional_params.fields).forEach(e=>{a.add(e)}),console.log("allowedParams: ",a),a.forEach(e=>{if("patterns"===e||"blocked_words"===e||"categories"===e)return;let a=t[e];(null==a||""===a)&&(a=t.optional_params?.[e]);let l=d.litellm_params?.[e];JSON.stringify(a)!==JSON.stringify(l)&&(null!=a&&""!==a?o.litellm_params[e]=a:null!=l&&""!==l&&(o.litellm_params[e]=null))})}if(0===Object.keys(o.litellm_params).length&&delete o.litellm_params,0===Object.keys(o).length){u.default.info("No changes detected"),_(!1);return}await (0,p.updateGuardrailCall)(a,e,o),u.default.success("Guardrail updated successfully"),T(!1),z(),_(!1)}catch(e){console.error("Error updating guardrail:",e),u.default.fromBackend("Failed to update guardrail")}};if(f)return(0,l.jsx)("div",{className:"p-4",children:"Loading..."});if(!d)return(0,l.jsx)("div",{className:"p-4",children:"Guardrail not found"});let J=e=>e?new Date(e).toLocaleString():"-",{logo:U,displayName:W}=ed(d.litellm_params?.guardrail||""),V=async(e,t)=>{await (0,tn.copyToClipboard)(e)&&(A(e=>({...e,[t]:!0})),setTimeout(()=>{A(e=>({...e,[t]:!1}))},2e3))},Y="config"===d.guardrail_definition_location;return(0,l.jsxs)("div",{className:"p-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(c.Button,{type:"text",icon:(0,l.jsx)(td.ArrowLeftIcon,{className:"w-4 h-4"}),onClick:t,className:"mb-4",children:"Back to Guardrails"}),(0,l.jsx)(th.Title,{children:d.guardrail_name||"Unnamed Guardrail"}),(0,l.jsxs)("div",{className:"flex items-center cursor-pointer",children:[(0,l.jsx)(eR.Text,{className:"text-gray-500 font-mono",children:d.guardrail_id}),(0,l.jsx)(c.Button,{type:"text",size:"small",icon:I["guardrail-id"]?(0,l.jsx)(tf.CheckIcon,{size:12}):(0,l.jsx)(ty.CopyIcon,{size:12}),onClick:()=>V(d.guardrail_id,"guardrail-id"),className:`left-2 z-10 transition-all duration-200 ${I["guardrail-id"]?"text-green-600 bg-green-50 border-green-200":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`})]})]}),(0,l.jsxs)(tu.TabGroup,{children:[(0,l.jsxs)(tp.TabList,{className:"mb-4",children:[(0,l.jsx)(tm.Tab,{children:"Overview"},"overview"),s?(0,l.jsx)(tm.Tab,{children:"Settings"},"settings"):(0,l.jsx)(l.Fragment,{})]}),(0,l.jsxs)(tx.TabPanels,{children:[(0,l.jsxs)(tg.TabPanel,{children:[(0,l.jsxs)(tc.Grid,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,l.jsxs)(eM.Card,{children:[(0,l.jsx)(eR.Text,{children:"Provider"}),(0,l.jsxs)("div",{className:"mt-2 flex items-center space-x-2",children:[U&&(0,l.jsx)("img",{src:U,alt:`${W} logo`,className:"w-6 h-6",onError:e=>{e.target.style.display="none"}}),(0,l.jsx)(th.Title,{children:W})]})]}),(0,l.jsxs)(eM.Card,{children:[(0,l.jsx)(eR.Text,{children:"Mode"}),(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsx)(th.Title,{children:d.litellm_params?.mode||"-"}),(0,l.jsx)(e7.Badge,{color:d.litellm_params?.default_on?"green":"gray",children:d.litellm_params?.default_on?"Default On":"Default Off"})]})]}),(0,l.jsxs)(eM.Card,{children:[(0,l.jsx)(eR.Text,{children:"Created At"}),(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsx)(th.Title,{children:J(d.created_at)}),(0,l.jsxs)(eR.Text,{children:["Last Updated: ",J(d.updated_at)]})]})]})]}),d.litellm_params?.pii_entities_config&&Object.keys(d.litellm_params.pii_entities_config).length>0&&(0,l.jsx)(eM.Card,{className:"mt-6",children:(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"PII Protection"}),(0,l.jsxs)(e7.Badge,{color:"blue",children:[Object.keys(d.litellm_params.pii_entities_config).length," PII entities configured"]})]})}),d.litellm_params?.pii_entities_config&&Object.keys(d.litellm_params.pii_entities_config).length>0&&(0,l.jsxs)(eM.Card,{className:"mt-6",children:[(0,l.jsx)(eR.Text,{className:"mb-4 text-lg font-semibold",children:"PII Entity Configuration"}),(0,l.jsxs)("div",{className:"border rounded-lg overflow-hidden shadow-sm",children:[(0,l.jsxs)("div",{className:"bg-gray-50 px-5 py-3 border-b flex",children:[(0,l.jsx)(eR.Text,{className:"flex-1 font-semibold text-gray-700",children:"Entity Type"}),(0,l.jsx)(eR.Text,{className:"flex-1 font-semibold text-gray-700",children:"Configuration"})]}),(0,l.jsx)("div",{className:"max-h-[400px] overflow-y-auto",children:Object.entries(d.litellm_params?.pii_entities_config).map(([e,t])=>(0,l.jsxs)("div",{className:"px-5 py-3 flex border-b hover:bg-gray-50 transition-colors",children:[(0,l.jsx)(eR.Text,{className:"flex-1 font-medium text-gray-900",children:e}),(0,l.jsx)(eR.Text,{className:"flex-1",children:(0,l.jsxs)("span",{className:`inline-flex items-center gap-1.5 ${"MASK"===t?"text-blue-600":"text-red-600"}`,children:["MASK"===t?(0,l.jsx)(eN.default,{}):(0,l.jsx)(eC.StopOutlined,{}),String(t)]})})]},e))})]})]}),d.litellm_params?.guardrail==="tool_permission"&&(0,l.jsx)(eM.Card,{className:"mt-6",children:(0,l.jsx)(eH,{value:L,disabled:!0})}),d.litellm_params?.guardrail==="custom_code"&&d.litellm_params?.custom_code&&(0,l.jsxs)(eM.Card,{className:"mt-6",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(to.CodeOutlined,{className:"text-blue-500"}),(0,l.jsx)(eR.Text,{className:"font-medium text-lg",children:"Custom Code"})]}),s&&!Y&&(0,l.jsx)(c.Button,{size:"small",icon:(0,l.jsx)(to.CodeOutlined,{}),onClick:()=>M(!0),children:"Edit Code"})]}),(0,l.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-gray-700 bg-[#1e1e1e]",children:(0,l.jsx)("pre",{className:"p-4 text-sm text-gray-200 overflow-x-auto",style:{fontFamily:"'Fira Code', 'Monaco', 'Consolas', monospace"},children:(0,l.jsx)("code",{children:d.litellm_params.custom_code})})})]}),(0,l.jsx)(tC,{guardrailData:d,guardrailSettings:S,isEditing:!1,accessToken:a})]}),s&&(0,l.jsx)(tg.TabPanel,{children:(0,l.jsxs)(eM.Card,{children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,l.jsx)(th.Title,{children:"Guardrail Settings"}),Y&&(0,l.jsx)(ej.Tooltip,{title:"Guardrail is defined in the config file and cannot be edited.",children:(0,l.jsx)(eD.InfoCircleOutlined,{})}),!j&&!Y&&(d.litellm_params?.guardrail==="custom_code"?(0,l.jsx)(c.Button,{icon:(0,l.jsx)(to.CodeOutlined,{}),onClick:()=>M(!0),children:"Edit Code"}):(0,l.jsx)(c.Button,{onClick:()=>_(!0),children:"Edit Settings"}))]}),j?(0,l.jsxs)(r.Form,{form:b,onFinish:q,initialValues:{guardrail_name:d.guardrail_name,...(o={...d.litellm_params||{}},delete o.skip_system_message_in_guardrail,o),skip_system_message_choice:ec(d.litellm_params?.skip_system_message_in_guardrail),guardrail_info:d.guardrail_info?JSON.stringify(d.guardrail_info,null,2):"",...d.litellm_params?.optional_params&&{optional_params:d.litellm_params.optional_params}},layout:"vertical",children:[(0,l.jsx)(r.Form.Item,{label:"Guardrail Name",name:"guardrail_name",rules:[{required:!0,message:"Please input a guardrail name"}],children:(0,l.jsx)(i.Input,{placeholder:"Enter guardrail name"})}),(0,l.jsx)(r.Form.Item,{label:"Default On",name:"default_on",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(n.Select.Option,{value:!0,children:"Yes"}),(0,l.jsx)(n.Select.Option,{value:!1,children:"No"})]})}),(0,l.jsx)(r.Form.Item,{label:"Skip system messages in guardrail",name:"skip_system_message_choice",tooltip:"Unified guardrails: omit role: system from guardrail input (LLM still gets full messages). Use global default follows litellm_settings.skip_system_message_in_guardrail.",children:(0,l.jsxs)(n.Select,{children:[(0,l.jsx)(n.Select.Option,{value:"inherit",children:"Use global default"}),(0,l.jsx)(n.Select.Option,{value:"yes",children:"Yes — exclude from guardrail scan"}),(0,l.jsx)(n.Select.Option,{value:"no",children:"No — always include in scan"})]})}),d.litellm_params?.guardrail==="presidio"&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eG.Divider,{orientation:"left",children:"PII Protection"}),(0,l.jsx)("div",{className:"mb-6",children:S&&(0,l.jsx)(eE,{entities:S.supported_entities,actions:S.supported_actions,selectedEntities:v,selectedActions:N,onEntitySelect:e=>{w(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},onActionSelect:(e,t)=>{C(a=>({...a,[e]:t}))},entityCategories:S.pii_entity_categories})})]}),(0,l.jsx)(tC,{guardrailData:d,guardrailSettings:S,isEditing:!0,accessToken:a,onDataChange:G,onUnsavedChanges:T}),(d.litellm_params?.guardrail==="tool_permission"||x)&&(0,l.jsx)(eG.Divider,{orientation:"left",children:"Provider Settings"}),d.litellm_params?.guardrail==="tool_permission"?(0,l.jsx)(eH,{value:L,onChange:B}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(ey,{selectedProvider:Object.keys(ea).find(e=>ea[e]===d.litellm_params?.guardrail)||null,accessToken:a,providerParams:x,value:d.litellm_params}),x&&(()=>{let e=Object.keys(ea).find(e=>ea[e]===d.litellm_params?.guardrail);if(!e)return null;let t=x[ea[e]?.toLowerCase()];return t&&t.optional_params?(0,l.jsx)(ex,{optionalParams:t.optional_params,parentFieldKey:"optional_params",values:d.litellm_params}):null})()]}),(0,l.jsx)(eG.Divider,{orientation:"left",children:"Advanced Settings"}),(0,l.jsx)(r.Form.Item,{label:"Guardrail Information",name:"guardrail_info",children:(0,l.jsx)(i.Input.TextArea,{rows:5})}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,l.jsx)(c.Button,{onClick:()=>{_(!1),T(!1),H()},children:"Cancel"}),(0,l.jsx)(c.Button,{type:"primary",htmlType:"submit",children:"Save Changes"})]})]}):(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Guardrail ID"}),(0,l.jsx)("div",{className:"font-mono",children:d.guardrail_id})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Guardrail Name"}),(0,l.jsx)("div",{children:d.guardrail_name||"Unnamed Guardrail"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Provider"}),(0,l.jsx)("div",{children:W})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Mode"}),(0,l.jsx)("div",{children:d.litellm_params?.mode||"-"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Default On"}),(0,l.jsx)(e7.Badge,{color:d.litellm_params?.default_on?"green":"gray",children:d.litellm_params?.default_on?"Yes":"No"})]}),d.litellm_params?.pii_entities_config&&Object.keys(d.litellm_params.pii_entities_config).length>0&&(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"PII Protection"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsxs)(e7.Badge,{color:"blue",children:[Object.keys(d.litellm_params.pii_entities_config).length," PII entities configured"]})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Created At"}),(0,l.jsx)("div",{children:J(d.created_at)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(eR.Text,{className:"font-medium",children:"Last Updated"}),(0,l.jsx)("div",{children:J(d.updated_at)})]}),d.litellm_params?.guardrail==="tool_permission"&&(0,l.jsx)(eH,{value:L,disabled:!0})]})]})})]})]}),(0,l.jsx)(tG,{visible:E,onClose:()=>M(!1),onSuccess:()=>{M(!1),z()},accessToken:a,editData:d?{guardrail_id:d.guardrail_id,guardrail_name:d.guardrail_name,litellm_params:d.litellm_params}:null})]})}],969641);var tz=e.i(573421),tD=e.i(19732),tK=e.i(928685),tH=e.i(166406),tq=e.i(637235),tJ=e.i(755151),tU=e.i(240647);let{Text:tW}=d.Typography,tV=function({results:e,errors:t}){let[a,r]=(0,m.useState)(new Set),i=e=>{let t=new Set(a);t.has(e)?t.delete(e):t.add(e),r(t)},s=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let a=document.execCommand("copy");if(document.body.removeChild(t),!a)throw Error("execCommand failed");return!0}}catch(e){return console.error("Copy failed:",e),!1}};return e||t?(0,l.jsxs)("div",{className:"space-y-3 pt-4 border-t border-gray-200",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold text-gray-900",children:"Results"}),e&&e.map(e=>{let t=a.has(e.guardrailName);return(0,l.jsx)(eM.Card,{className:"bg-green-50 border-green-200",children:(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-2 cursor-pointer flex-1",onClick:()=>i(e.guardrailName),children:[t?(0,l.jsx)(tU.RightOutlined,{className:"text-gray-500 text-xs"}):(0,l.jsx)(tJ.DownOutlined,{className:"text-gray-500 text-xs"}),(0,l.jsx)(tk.CheckCircleOutlined,{className:"text-green-600 text-lg"}),(0,l.jsx)("span",{className:"text-sm font-medium text-green-800",children:e.guardrailName})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-1 text-xs text-gray-600",children:[(0,l.jsx)(tq.ClockCircleOutlined,{}),(0,l.jsxs)("span",{className:"font-medium",children:[e.latency,"ms"]})]}),!t&&(0,l.jsx)(e4.Button,{size:"xs",variant:"secondary",icon:tH.CopyOutlined,onClick:async()=>{await s(e.response_text)?u.default.success("Result copied to clipboard"):u.default.fromBackend("Failed to copy result")},children:"Copy"})]})]}),!t&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"bg-white border border-green-200 rounded p-3",children:[(0,l.jsx)("label",{className:"text-xs font-medium text-gray-600 mb-2 block",children:"Output Text"}),(0,l.jsx)("div",{className:"font-mono text-sm text-gray-900 whitespace-pre-wrap break-words",children:e.response_text})]}),(0,l.jsxs)("div",{className:"text-xs text-gray-600",children:[(0,l.jsx)("span",{className:"font-medium",children:"Characters:"})," ",e.response_text.length]})]})]})},e.guardrailName)}),t&&t.map(e=>{let t=a.has(e.guardrailName);return(0,l.jsx)(eM.Card,{className:"bg-red-50 border-red-200",children:(0,l.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,l.jsx)("div",{className:"cursor-pointer mt-0.5",onClick:()=>i(e.guardrailName),children:t?(0,l.jsx)(tU.RightOutlined,{className:"text-gray-500 text-xs"}):(0,l.jsx)(tJ.DownOutlined,{className:"text-gray-500 text-xs"})}),(0,l.jsx)("div",{className:"text-red-600 mt-0.5",children:(0,l.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,l.jsxs)("p",{className:"text-sm font-medium text-red-800 cursor-pointer",onClick:()=>i(e.guardrailName),children:[e.guardrailName," - Error"]}),(0,l.jsxs)("div",{className:"flex items-center space-x-1 text-xs text-gray-600",children:[(0,l.jsx)(tq.ClockCircleOutlined,{}),(0,l.jsxs)("span",{className:"font-medium",children:[e.latency,"ms"]})]})]}),!t&&(0,l.jsx)("p",{className:"text-sm text-red-700 mt-1",children:e.error.message})]})]})},e.guardrailName)})]}):null},{TextArea:tY}=i.Input,{Text:tQ}=d.Typography,tZ=function({guardrailNames:e,onSubmit:t,isLoading:a,results:r,errors:i,onClose:s}){let[n,o]=(0,m.useState)(""),d=()=>{n.trim()?t(n):u.default.fromBackend("Please enter text to test")},c=async e=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0;{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let a=document.execCommand("copy");if(document.body.removeChild(t),!a)throw Error("execCommand failed");return!0}}catch(e){return console.error("Copy failed:",e),!1}},p=async()=>{await c(n)?u.default.success("Input copied to clipboard"):u.default.fromBackend("Failed to copy input")};return(0,l.jsxs)("div",{className:"space-y-4 h-full flex flex-col",children:[(0,l.jsx)("div",{className:"flex items-center justify-between pb-3 border-b border-gray-200",children:(0,l.jsx)("div",{className:"flex items-center space-x-3",children:(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Test Guardrails:"}),(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,l.jsx)("div",{className:"inline-flex items-center space-x-1 bg-blue-50 px-3 py-1 rounded-md border border-blue-200",children:(0,l.jsx)("span",{className:"font-mono text-blue-700 font-medium text-sm",children:e})},e))})]}),(0,l.jsxs)("p",{className:"text-sm text-gray-500",children:["Test ",e.length>1?"guardrails":"guardrail"," and compare results"]})]})})}),(0,l.jsxs)("div",{className:"flex-1 overflow-auto space-y-4",children:[(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Input Text"}),(0,l.jsx)(ej.Tooltip,{title:"Press Enter to submit. Use Shift+Enter for new line.",children:(0,l.jsx)(eD.InfoCircleOutlined,{className:"text-gray-400 cursor-help"})})]}),n&&(0,l.jsx)(e4.Button,{size:"xs",variant:"secondary",icon:tH.CopyOutlined,onClick:p,children:"Copy Input"})]}),(0,l.jsx)(tY,{value:n,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||(e.preventDefault(),d())},placeholder:"Enter text to test with guardrails...",rows:8,className:"font-mono text-sm"}),(0,l.jsxs)("div",{className:"flex justify-between items-center mt-1",children:[(0,l.jsxs)(tQ,{className:"text-xs text-gray-500",children:["Press ",(0,l.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 border border-gray-300 rounded text-xs",children:"Enter"})," to submit • ",(0,l.jsx)("kbd",{className:"px-1 py-0.5 bg-gray-100 border border-gray-300 rounded text-xs",children:"Shift+Enter"})," for new line"]}),(0,l.jsxs)(tQ,{className:"text-xs text-gray-500",children:["Characters: ",n.length]})]})]}),(0,l.jsx)("div",{className:"pt-2",children:(0,l.jsx)(e4.Button,{onClick:d,loading:a,disabled:!n.trim(),className:"w-full",children:a?`Testing ${e.length} guardrail${e.length>1?"s":""}...`:`Test ${e.length} guardrail${e.length>1?"s":""}`})})]}),(0,l.jsx)(tV,{results:r,errors:i})]})]})};e.s(["default",0,({guardrailsList:e,isLoading:t,accessToken:a,onClose:r})=>{let[s,n]=(0,m.useState)(new Set),[o,c]=(0,m.useState)(""),[g,x]=(0,m.useState)([]),[f,y]=(0,m.useState)([]),[j,_]=(0,m.useState)(!1),b=e.filter(e=>e.guardrail_name?.toLowerCase().includes(o.toLowerCase())),v=async e=>{if(0===s.size||!a)return;_(!0),x([]),y([]);let t=[],l=[];await Promise.all(Array.from(s).map(async r=>{let i=Date.now();try{let l=await (0,p.applyGuardrail)(a,r,e,null,null),s=Date.now()-i;t.push({guardrailName:r,response_text:l.response_text,latency:s})}catch(t){let e=Date.now()-i;console.error(`Error testing guardrail ${r}:`,t),l.push({guardrailName:r,error:t,latency:e})}})),x(t),y(l),_(!1),t.length>0&&u.default.success(`${t.length} guardrail${t.length>1?"s":""} applied successfully`),l.length>0&&u.default.fromBackend(`${l.length} guardrail${l.length>1?"s":""} failed`)};return(0,l.jsx)("div",{className:"w-full h-[calc(100vh-200px)]",children:(0,l.jsx)(h.Card,{className:"h-full",styles:{body:{padding:0,height:"100%"}},children:(0,l.jsxs)("div",{className:"flex h-full",children:[(0,l.jsxs)("div",{className:"w-1/4 border-r border-gray-200 flex flex-col overflow-hidden",children:[(0,l.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,l.jsxs)("div",{className:"mb-3",children:[(0,l.jsx)("h3",{className:"text-lg font-semibold mb-3",children:"Guardrails"}),(0,l.jsx)(i.Input,{prefix:(0,l.jsx)(tK.SearchOutlined,{}),placeholder:"Search guardrails...",value:o,onChange:e=>c(e.target.value)})]})}),(0,l.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,l.jsx)("div",{className:"flex items-center justify-center h-32",children:(0,l.jsx)(eh.Spin,{})}):0===b.length?(0,l.jsx)("div",{className:"p-4",children:(0,l.jsx)(ez.Empty,{description:o?"No guardrails match your search":"No guardrails available"})}):(0,l.jsx)(tz.List,{dataSource:b,renderItem:e=>(0,l.jsx)(tz.List.Item,{onClick:()=>{var t;let a;e.guardrail_name&&(t=e.guardrail_name,(a=new Set(s)).has(t)?a.delete(t):a.add(t),n(a))},style:{paddingLeft:24,paddingRight:16},className:`cursor-pointer hover:bg-gray-50 transition-colors ${s.has(e.guardrail_name||"")?"bg-blue-50 border-l-4 border-l-blue-500":"border-l-4 border-l-transparent"}`,children:(0,l.jsx)(tz.List.Item.Meta,{title:(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(tD.ExperimentOutlined,{className:"text-gray-400"}),(0,l.jsx)("span",{className:"font-medium text-gray-900",children:e.guardrail_name})]}),description:(0,l.jsxs)("div",{className:"text-xs space-y-1 mt-1",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"font-medium",children:"Type: "}),(0,l.jsx)("span",{className:"text-gray-600",children:e.litellm_params.guardrail})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"font-medium",children:"Mode: "}),(0,l.jsx)("span",{className:"text-gray-600",children:e.litellm_params.mode})]})]})})})})}),(0,l.jsx)("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:(0,l.jsxs)(d.Typography.Text,{className:"text-xs text-gray-600",children:[s.size," of ",b.length," selected"]})})]}),(0,l.jsxs)("div",{className:"w-3/4 flex flex-col bg-white",children:[(0,l.jsx)("div",{className:"p-4 border-b border-gray-200 flex justify-between items-center",children:(0,l.jsx)(d.Typography.Title,{level:2,className:"text-xl font-semibold mb-0",children:"Guardrail Testing Playground"})}),(0,l.jsx)("div",{className:"flex-1 overflow-auto p-4",children:0===s.size?(0,l.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-gray-400",children:[(0,l.jsx)(tD.ExperimentOutlined,{style:{fontSize:"48px",marginBottom:"16px"}}),(0,l.jsx)(d.Typography.Paragraph,{className:"text-lg font-medium text-gray-600 mb-2",children:"Select Guardrails to Test"}),(0,l.jsx)(d.Typography.Paragraph,{className:"text-center text-gray-500 max-w-md",children:"Choose one or more guardrails from the left sidebar to start testing and comparing results."})]}):(0,l.jsx)("div",{className:"h-full",children:(0,l.jsx)(tZ,{guardrailNames:Array.from(s),onSubmit:v,results:g.length>0?g:null,errors:f.length>0?f:null,isLoading:j,onClose:()=>n(new Set)})})})]})]})})})}],476993),e.s([],824296),e.s(["CustomCodeModal",0,tG],64352);let tX="../ui/assets/logos/",t0=[{id:"cf_denied_financial",name:"Denied Financial Advice",description:"Detects requests for personalized financial advice, investment recommendations, or financial planning.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Topic Blocker"],eval:{f1:100,precision:100,recall:100,testCases:207,latency:"<0.1ms"}},{id:"cf_denied_insults",name:"Insults & Personal Attacks",description:"Detects insults, name-calling, and personal attacks directed at the chatbot, staff, or other people.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Topic Blocker"],eval:{f1:100,precision:100,recall:100,testCases:299,latency:"<0.1ms"}},{id:"cf_denied_legal",name:"Denied Legal Advice",description:"Detects requests for unauthorized legal advice, case analysis, or legal recommendations.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Topic Blocker"]},{id:"cf_denied_medical",name:"Denied Medical Advice",description:"Detects requests for medical diagnosis, treatment recommendations, or health advice.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Topic Blocker"]},{id:"cf_harmful_violence",name:"Harmful Violence",description:"Detects content related to violence, criminal planning, attacks, and violent threats.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Safety"]},{id:"cf_harmful_self_harm",name:"Harmful Self-Harm",description:"Detects content related to self-harm, suicide, and dangerous self-destructive behavior.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Safety"]},{id:"cf_harmful_child_safety",name:"Harmful Child Safety",description:"Detects content that could endanger child safety or exploit minors.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Safety"]},{id:"cf_harmful_illegal_weapons",name:"Harmful Illegal Weapons",description:"Detects content related to illegal weapons manufacturing, distribution, or acquisition.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Safety"]},{id:"cf_bias_gender",name:"Bias: Gender",description:"Detects gender-based discrimination, stereotypes, and biased language.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Bias"]},{id:"cf_bias_racial",name:"Bias: Racial",description:"Detects racial discrimination, stereotypes, and racially biased content.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Bias"]},{id:"cf_bias_religious",name:"Bias: Religious",description:"Detects religious discrimination, intolerance, and religiously biased content.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Bias"]},{id:"cf_bias_sexual_orientation",name:"Bias: Sexual Orientation",description:"Detects discrimination based on sexual orientation and related biased content.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Bias"]},{id:"cf_prompt_injection_jailbreak",name:"Prompt Injection: Jailbreak",description:"Detects jailbreak attempts designed to bypass AI safety guidelines and restrictions.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Prompt Injection"]},{id:"cf_prompt_injection_data_exfil",name:"Prompt Injection: Data Exfiltration",description:"Detects attempts to extract sensitive data through prompt manipulation.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Prompt Injection"]},{id:"cf_prompt_injection_sql",name:"Prompt Injection: SQL",description:"Detects SQL injection attempts embedded in prompts.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Prompt Injection"]},{id:"cf_prompt_injection_malicious_code",name:"Prompt Injection: Malicious Code",description:"Detects attempts to inject malicious code through prompts.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Prompt Injection"]},{id:"cf_prompt_injection_system_prompt",name:"Prompt Injection: System Prompt",description:"Detects attempts to extract or override system prompts.",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Prompt Injection"]},{id:"cf_toxic_abuse",name:"Toxic & Abusive Language",description:"Detects toxic, abusive, and hateful language across multiple languages (EN, AU, DE, ES, FR).",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Toxicity"]},{id:"cf_patterns",name:"Pattern Matching",description:"Detect and block sensitive data patterns like SSNs, credit card numbers, API keys, and custom regex patterns.",category:"litellm",subcategory:"Patterns",logo:`${tX}litellm_logo.jpg`,tags:["PII","Regex","Data Protection"]},{id:"cf_keywords",name:"Keyword Blocking",description:"Block or mask content containing specific keywords or phrases. Upload custom word lists or add individual terms.",category:"litellm",subcategory:"Keywords",logo:`${tX}litellm_logo.jpg`,tags:["Keywords","Blocklist"]},{id:"block_code_execution",name:"Block Code Execution",description:"Detects markdown fenced code blocks in requests and responses. Block or mask executable code (e.g. Python, JavaScript, Bash) by language with configurable confidence.",category:"litellm",subcategory:"Code Safety",logo:`${tX}litellm_logo.jpg`,tags:["Code","Safety","Prompt Injection"]},{id:"cf_competitor_intent",name:"Competitor Name Blocking",description:"Block or reframe competitor comparison and ranking intent. Detect when users ask to compare or recommend competitors (airline or generic competitor lists).",category:"litellm",subcategory:"Content Category",logo:`${tX}litellm_logo.jpg`,tags:["Content Category","Competitor","Topic Blocker"]},{id:"presidio",name:"Presidio PII",description:"Microsoft Presidio for PII detection and anonymization. Supports 30+ entity types with configurable actions.",category:"partner",logo:`${tX}microsoft_azure.svg`,tags:["PII","Microsoft"],providerKey:"PresidioPII"},{id:"bedrock",name:"Bedrock Guardrail",description:"AWS Bedrock Guardrails for content filtering, topic avoidance, and sensitive information detection.",category:"partner",logo:`${tX}bedrock.svg`,tags:["AWS","Content Safety"],providerKey:"Bedrock"},{id:"lakera",name:"Lakera",description:"AI security platform protecting against prompt injections, data leakage, and harmful content.",category:"partner",logo:`${tX}lakeraai.jpeg`,tags:["Security","Prompt Injection"],providerKey:"Lakera"},{id:"openai_moderation",name:"OpenAI Moderation",description:"OpenAI's content moderation API for detecting harmful content across multiple categories.",category:"partner",logo:`${tX}openai_small.svg`,tags:["Content Moderation","OpenAI"]},{id:"google_model_armor",name:"Google Cloud Model Armor",description:"Google Cloud's model protection service for safe and responsible AI deployments.",category:"partner",logo:`${tX}google.svg`,tags:["Google Cloud","Safety"]},{id:"guardrails_ai",name:"Guardrails AI",description:"Open-source framework for adding structural, type, and quality guarantees to LLM outputs.",category:"partner",logo:`${tX}guardrails_ai.jpeg`,tags:["Open Source","Validation"]},{id:"zscaler",name:"Zscaler AI Guard",description:"Enterprise AI security from Zscaler for monitoring and protecting AI/ML workloads.",category:"partner",logo:`${tX}zscaler.svg`,tags:["Enterprise","Security"]},{id:"panw",name:"PANW Prisma AIRS",description:"Palo Alto Networks Prisma AI Runtime Security for securing AI applications in production.",category:"partner",logo:`${tX}palo_alto_networks.jpeg`,tags:["Enterprise","Security"]},{id:"noma",name:"Noma Security",description:"AI security platform for detecting and preventing AI-specific threats and vulnerabilities.",category:"partner",logo:`${tX}noma_security.png`,tags:["Security","Threat Detection"]},{id:"aporia",name:"Aporia AI",description:"Real-time AI guardrails for hallucination detection, topic control, and policy enforcement.",category:"partner",logo:`${tX}aporia.png`,tags:["Hallucination","Policy"]},{id:"aim",name:"AIM Guardrail",description:"AIM Security guardrails for comprehensive AI threat detection and mitigation.",category:"partner",logo:`${tX}aim_security.jpeg`,tags:["Security","Threat Detection"]},{id:"prompt_security",name:"Prompt Security",description:"Protect against prompt injection attacks, data leakage, and other LLM security threats.",category:"partner",logo:`${tX}prompt_security.png`,tags:["Prompt Injection","Security"]},{id:"lasso",name:"Lasso Guardrail",description:"Content moderation and safety guardrails for responsible AI deployments.",category:"partner",logo:`${tX}lasso.png`,tags:["Content Moderation"]},{id:"pangea",name:"Pangea Guardrail",description:"Pangea's AI guardrails for secure, compliant, and trustworthy AI applications.",category:"partner",logo:`${tX}pangea.png`,tags:["Compliance","Security"]},{id:"enkryptai",name:"EnkryptAI",description:"AI security and governance platform for enterprise AI safety and compliance.",category:"partner",logo:`${tX}enkrypt_ai.avif`,tags:["Enterprise","Governance"]},{id:"javelin",name:"Javelin Guardrails",description:"AI gateway with built-in guardrails for secure and compliant AI operations.",category:"partner",logo:`${tX}javelin.png`,tags:["Gateway","Security"]},{id:"pillar",name:"Pillar Guardrail",description:"AI safety platform for monitoring, testing, and securing AI systems.",category:"partner",logo:`${tX}pillar.jpeg`,tags:["Monitoring","Safety"]},{id:"akto",name:"Akto Guardrail",description:"AI security platform from Akto.io with automatic monitoring and guardrails for AI/ML applications.",category:"partner",logo:`${tX}akto.svg`,tags:["Security","Safety","Monitoring"]},{id:"promptguard",name:"PromptGuard",description:"AI security gateway with prompt injection detection, PII redaction, topic filtering, entity blocklists, and hallucination detection. Self-hostable with drop-in proxy integration.",category:"partner",logo:`${tX}promptguard.svg`,tags:["Security","Prompt Injection","PII"],providerKey:"Promptguard",eval:{f1:94.9,precision:100,recall:90.4,testCases:5384,latency:"~150ms"}}];e.s(["ALL_CARDS",0,t0],230312)},826910,e=>{"use strict";var t=e.i(201072);e.s(["CheckCircleFilled",()=>t.default])},487304,168118,e=>{"use strict";var t=e.i(843476),a=e.i(271645),l=e.i(464571),r=e.i(326373),i=e.i(653496),s=e.i(755151),n=e.i(646563),o=e.i(245094),d=e.i(764205),c=e.i(185357),m=e.i(782719),u=e.i(708347),p=e.i(969641),g=e.i(476993),x=e.i(727749),h=e.i(127952),f=e.i(180766);e.i(824296);var y=e.i(64352),j=e.i(311451),_=e.i(928685),b=e.i(266537),v=e.i(230312),w=e.i(826910);let N=({src:e,name:l})=>{let[r,i]=(0,a.useState)(!1);return r||!e?(0,t.jsx)("div",{style:{width:28,height:28,borderRadius:6,backgroundColor:"#e5e7eb",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,color:"#6b7280",flexShrink:0},children:l?.charAt(0)||"?"}):(0,t.jsx)("img",{src:e,alt:"",style:{width:28,height:28,borderRadius:6,objectFit:"contain",flexShrink:0},onError:()=>i(!0)})},C=({card:e,onClick:l})=>{let[r,i]=(0,a.useState)(!1);return(0,t.jsxs)("div",{onClick:l,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:12,border:r?"1px solid #93c5fd":"1px solid #e5e7eb",backgroundColor:"#ffffff",padding:"20px 20px 16px 20px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",display:"flex",flexDirection:"column",minHeight:170,boxShadow:r?"0 1px 6px rgba(59,130,246,0.08)":"none"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,t.jsx)(N,{src:e.logo,name:e.name}),(0,t.jsx)("span",{style:{fontSize:14,fontWeight:600,color:"#111827",lineHeight:1.3},children:e.name})]}),(0,t.jsx)("p",{className:"line-clamp-3",style:{fontSize:12,color:"#6b7280",lineHeight:1.6,margin:0,flex:1},children:e.description}),e.eval&&(0,t.jsxs)("div",{style:{marginTop:10,display:"flex",alignItems:"center",gap:4},children:[(0,t.jsx)(w.CheckCircleFilled,{style:{color:"#16a34a",fontSize:12}}),(0,t.jsxs)("span",{style:{fontSize:11,color:"#16a34a",fontWeight:500},children:["F1: ",e.eval.f1,"% · ",e.eval.testCases," test cases"]})]})]})};var S=e.i(447566);let k={cf_denied_financial:{provider:"LitellmContentFilter",categoryName:"denied_financial_advice",guardrailNameSuggestion:"Denied Financial Advice",mode:"pre_call",defaultOn:!1},cf_denied_legal:{provider:"LitellmContentFilter",categoryName:"denied_legal_advice",guardrailNameSuggestion:"Denied Legal Advice",mode:"pre_call",defaultOn:!1},cf_denied_medical:{provider:"LitellmContentFilter",categoryName:"denied_medical_advice",guardrailNameSuggestion:"Denied Medical Advice",mode:"pre_call",defaultOn:!1},cf_denied_insults:{provider:"LitellmContentFilter",categoryName:"denied_insults",guardrailNameSuggestion:"Insults & Personal Attacks",mode:"pre_call",defaultOn:!1},cf_harmful_violence:{provider:"LitellmContentFilter",categoryName:"harmful_violence",guardrailNameSuggestion:"Harmful Violence",mode:"pre_call",defaultOn:!1},cf_harmful_self_harm:{provider:"LitellmContentFilter",categoryName:"harmful_self_harm",guardrailNameSuggestion:"Harmful Self-Harm",mode:"pre_call",defaultOn:!1},cf_harmful_child_safety:{provider:"LitellmContentFilter",categoryName:"harmful_child_safety",guardrailNameSuggestion:"Harmful Child Safety",mode:"pre_call",defaultOn:!1},cf_harmful_illegal_weapons:{provider:"LitellmContentFilter",categoryName:"harmful_illegal_weapons",guardrailNameSuggestion:"Harmful Illegal Weapons",mode:"pre_call",defaultOn:!1},cf_bias_gender:{provider:"LitellmContentFilter",categoryName:"bias_gender",guardrailNameSuggestion:"Bias: Gender",mode:"pre_call",defaultOn:!1},cf_bias_racial:{provider:"LitellmContentFilter",categoryName:"bias_racial",guardrailNameSuggestion:"Bias: Racial",mode:"pre_call",defaultOn:!1},cf_bias_religious:{provider:"LitellmContentFilter",categoryName:"bias_religious",guardrailNameSuggestion:"Bias: Religious",mode:"pre_call",defaultOn:!1},cf_bias_sexual_orientation:{provider:"LitellmContentFilter",categoryName:"bias_sexual_orientation",guardrailNameSuggestion:"Bias: Sexual Orientation",mode:"pre_call",defaultOn:!1},cf_prompt_injection_jailbreak:{provider:"LitellmContentFilter",categoryName:"prompt_injection_jailbreak",guardrailNameSuggestion:"Prompt Injection: Jailbreak",mode:"pre_call",defaultOn:!1},cf_prompt_injection_data_exfil:{provider:"LitellmContentFilter",categoryName:"prompt_injection_data_exfiltration",guardrailNameSuggestion:"Prompt Injection: Data Exfiltration",mode:"pre_call",defaultOn:!1},cf_prompt_injection_sql:{provider:"LitellmContentFilter",categoryName:"prompt_injection_sql",guardrailNameSuggestion:"Prompt Injection: SQL",mode:"pre_call",defaultOn:!1},cf_prompt_injection_malicious_code:{provider:"LitellmContentFilter",categoryName:"prompt_injection_malicious_code",guardrailNameSuggestion:"Prompt Injection: Malicious Code",mode:"pre_call",defaultOn:!1},cf_prompt_injection_system_prompt:{provider:"LitellmContentFilter",categoryName:"prompt_injection_system_prompt",guardrailNameSuggestion:"Prompt Injection: System Prompt",mode:"pre_call",defaultOn:!1},cf_toxic_abuse:{provider:"LitellmContentFilter",categoryName:"harm_toxic_abuse",guardrailNameSuggestion:"Toxic & Abusive Language",mode:"pre_call",defaultOn:!1},cf_patterns:{provider:"LitellmContentFilter",guardrailNameSuggestion:"Pattern Matching",mode:"pre_call",defaultOn:!1},cf_keywords:{provider:"LitellmContentFilter",guardrailNameSuggestion:"Keyword Blocking",mode:"pre_call",defaultOn:!1},block_code_execution:{provider:"BlockCodeExecution",guardrailNameSuggestion:"Block Code Execution",mode:"pre_call",defaultOn:!1},cf_competitor_intent:{provider:"LitellmContentFilter",guardrailNameSuggestion:"Competitor Name Blocking",mode:"pre_call",defaultOn:!1},presidio:{provider:"PresidioPII",guardrailNameSuggestion:"Presidio PII",mode:"pre_call",defaultOn:!1},bedrock:{provider:"Bedrock",guardrailNameSuggestion:"Bedrock Guardrail",mode:"pre_call",defaultOn:!1},lakera:{provider:"Lakera",guardrailNameSuggestion:"Lakera",mode:"pre_call",defaultOn:!1},openai_moderation:{provider:"OpenaiModeration",guardrailNameSuggestion:"OpenAI Moderation",mode:"pre_call",defaultOn:!1},google_model_armor:{provider:"ModelArmor",guardrailNameSuggestion:"Google Cloud Model Armor",mode:"pre_call",defaultOn:!1},guardrails_ai:{provider:"GuardrailsAi",guardrailNameSuggestion:"Guardrails AI",mode:"pre_call",defaultOn:!1},zscaler:{provider:"ZscalerAiGuard",guardrailNameSuggestion:"Zscaler AI Guard",mode:"pre_call",defaultOn:!1},panw:{provider:"PanwPrismaAirs",guardrailNameSuggestion:"PANW Prisma AIRS",mode:"pre_call",defaultOn:!1},noma:{provider:"Noma",guardrailNameSuggestion:"Noma Security",mode:"pre_call",defaultOn:!1},aporia:{provider:"AporiaAi",guardrailNameSuggestion:"Aporia AI",mode:"pre_call",defaultOn:!1},aim:{provider:"Aim",guardrailNameSuggestion:"AIM Guardrail",mode:"pre_call",defaultOn:!1},prompt_security:{provider:"PromptSecurity",guardrailNameSuggestion:"Prompt Security",mode:"pre_call",defaultOn:!1},lasso:{provider:"Lasso",guardrailNameSuggestion:"Lasso Guardrail",mode:"pre_call",defaultOn:!1},pangea:{provider:"Pangea",guardrailNameSuggestion:"Pangea Guardrail",mode:"pre_call",defaultOn:!1},enkryptai:{provider:"Enkryptai",guardrailNameSuggestion:"EnkryptAI",mode:"pre_call",defaultOn:!1},javelin:{provider:"Javelin",guardrailNameSuggestion:"Javelin Guardrails",mode:"pre_call",defaultOn:!1},pillar:{provider:"Pillar",guardrailNameSuggestion:"Pillar Guardrail",mode:"pre_call",defaultOn:!1},akto:{provider:"Akto",guardrailNameSuggestion:"Akto Guardrail",mode:"pre_call",defaultOn:!1},promptguard:{provider:"Promptguard",guardrailNameSuggestion:"PromptGuard",mode:"pre_call",defaultOn:!1}},I=({card:e,onBack:r,accessToken:i,onGuardrailCreated:s})=>{let[n,o]=(0,a.useState)(!1),[d,m]=(0,a.useState)("overview"),u=[{property:"Provider",value:"litellm"===e.category?"LiteLLM Content Filter":"Partner Guardrail"},...e.subcategory?[{property:"Subcategory",value:e.subcategory}]:[],..."litellm"===e.category?[{property:"Cost",value:"$0 / request"}]:[],..."litellm"===e.category?[{property:"External Dependencies",value:"None"}]:[],..."litellm"===e.category?[{property:"Latency",value:e.eval?.latency||"<1ms"}]:[]],p=e.eval?[{metric:"Precision",value:`${e.eval.precision}%`},{metric:"Recall",value:`${e.eval.recall}%`},{metric:"F1 Score",value:`${e.eval.f1}%`},{metric:"Test Cases",value:String(e.eval.testCases)},{metric:"False Positives",value:"0"},{metric:"False Negatives",value:"0"},{metric:"Latency (p50)",value:e.eval.latency}]:[],g=[{key:"overview",label:"Overview"},...e.eval?[{key:"eval",label:"Eval Results"}]:[]];return(0,t.jsxs)("div",{style:{maxWidth:960,margin:"0 auto"},children:[(0,t.jsxs)("div",{onClick:r,style:{display:"inline-flex",alignItems:"center",gap:6,color:"#5f6368",cursor:"pointer",fontSize:14,marginBottom:24},children:[(0,t.jsx)(S.ArrowLeftOutlined,{style:{fontSize:11}}),(0,t.jsx)("span",{children:e.name})]}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:8},children:[(0,t.jsx)("img",{src:e.logo,alt:"",style:{width:40,height:40,borderRadius:8,objectFit:"contain"},onError:e=>{e.target.style.display="none"}}),(0,t.jsx)("h1",{style:{fontSize:28,fontWeight:400,color:"#202124",margin:0,lineHeight:1.2},children:e.name})]}),(0,t.jsx)("p",{style:{fontSize:14,color:"#5f6368",margin:"0 0 20px 0",lineHeight:1.6},children:e.description}),(0,t.jsx)("div",{style:{display:"flex",gap:10,marginBottom:32},children:(0,t.jsx)(l.Button,{onClick:()=>o(!0),style:{borderRadius:20,padding:"4px 20px",height:36,borderColor:"#dadce0",color:"#1a73e8",fontWeight:500,fontSize:14},children:"Create Guardrail"})}),(0,t.jsx)("div",{style:{borderBottom:"1px solid #dadce0",marginBottom:28},children:(0,t.jsx)("div",{style:{display:"flex",gap:0},children:g.map(e=>(0,t.jsx)("div",{onClick:()=>m(e.key),style:{padding:"12px 20px",fontSize:14,color:d===e.key?"#1a73e8":"#5f6368",borderBottom:d===e.key?"3px solid #1a73e8":"3px solid transparent",cursor:"pointer",fontWeight:d===e.key?500:400,marginBottom:-1},children:e.label},e.key))})}),"overview"===d&&(0,t.jsxs)("div",{style:{display:"flex",gap:64},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 12px 0"},children:"Overview"}),(0,t.jsx)("p",{style:{fontSize:14,color:"#3c4043",lineHeight:1.7,margin:"0 0 32px 0"},children:e.description}),(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 4px 0"},children:"Guardrail Details"}),(0,t.jsx)("p",{style:{fontSize:13,color:"#5f6368",margin:"0 0 16px 0"},children:"Details are as follows"}),(0,t.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:14},children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500,width:200},children:"Property"}),(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500},children:e.name})]})}),(0,t.jsx)("tbody",{children:u.map((e,a)=>(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #f1f3f4"},children:[(0,t.jsx)("td",{style:{padding:"12px 0",color:"#3c4043"},children:e.property}),(0,t.jsx)("td",{style:{padding:"12px 0",color:"#202124"},children:e.value})]},a))})]})]}),(0,t.jsxs)("div",{style:{width:240,flexShrink:0},children:[(0,t.jsxs)("div",{style:{marginBottom:28},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Guardrail ID"}),(0,t.jsxs)("div",{style:{fontSize:13,color:"#202124",wordBreak:"break-all"},children:["litellm/",e.id]})]}),(0,t.jsxs)("div",{style:{marginBottom:28},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Type"}),(0,t.jsx)("div",{style:{fontSize:13,color:"#202124"},children:"litellm"===e.category?"Content Filter":"Partner"})]}),e.tags.length>0&&(0,t.jsxs)("div",{style:{marginBottom:28},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:8},children:"Tags"}),(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.tags.map(e=>(0,t.jsx)("span",{style:{fontSize:12,padding:"4px 12px",borderRadius:16,border:"1px solid #dadce0",color:"#3c4043",backgroundColor:"#fff"},children:e},e))})]})]})]}),"eval"===d&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 16px 0"},children:"Eval Results"}),(0,t.jsxs)("table",{style:{width:"100%",maxWidth:560,borderCollapse:"collapse",fontSize:14},children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{style:{backgroundColor:"#f8f9fa",borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 16px",color:"#5f6368",fontWeight:500},children:"Metric"}),(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 16px",color:"#5f6368",fontWeight:500},children:"Value"})]})}),(0,t.jsx)("tbody",{children:p.map((e,a)=>(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #f1f3f4"},children:[(0,t.jsx)("td",{style:{padding:"12px 16px",color:"#3c4043"},children:e.metric}),(0,t.jsx)("td",{style:{padding:"12px 16px",color:"#202124",fontWeight:500},children:e.value})]},a))})]})]}),(0,t.jsx)(c.default,{visible:n,onClose:()=>o(!1),accessToken:i,onSuccess:()=>{o(!1),s()},preset:k[e.id]})]})},A=({accessToken:e,onGuardrailCreated:l})=>{let[r,i]=(0,a.useState)(""),[s,n]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),c=v.ALL_CARDS.filter(e=>{if(!r)return!0;let t=r.toLowerCase();return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.tags.some(e=>e.toLowerCase().includes(t))}),m=c.filter(e=>"litellm"===e.category),u=c.filter(e=>"partner"===e.category);return s?(0,t.jsx)(I,{card:s,onBack:()=>n(null),accessToken:e,onGuardrailCreated:l}):(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{marginBottom:24},children:(0,t.jsx)(j.Input,{size:"large",placeholder:"Search guardrails",prefix:(0,t.jsx)(_.SearchOutlined,{style:{color:"#9ca3af"}}),value:r,onChange:e=>i(e.target.value),style:{borderRadius:8}})}),(0,t.jsxs)("div",{style:{marginBottom:40},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,t.jsx)("h2",{style:{fontSize:20,fontWeight:600,color:"#111827",margin:0},children:"LiteLLM Content Filter"}),(0,t.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:14,color:"#1a73e8",cursor:"pointer"},onClick:()=>d(!o),children:o?(0,t.jsx)(t.Fragment,{children:"Show less"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b.ArrowRightOutlined,{style:{fontSize:12}}),`Show all (${m.length})`]})})]}),(0,t.jsx)("p",{style:{fontSize:13,color:"#6b7280",margin:"4px 0 20px 0"},children:"Built-in guardrails powered by LiteLLM. Zero latency, no external dependencies, no additional cost."}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:16},children:(o?m:m.slice(0,10)).map(e=>(0,t.jsx)(C,{card:e,onClick:()=>n(e)},e.id))})]}),(0,t.jsxs)("div",{style:{marginBottom:40},children:[(0,t.jsx)("h2",{style:{fontSize:20,fontWeight:600,color:"#111827",margin:"0 0 4px 0"},children:"Partner Guardrails"}),(0,t.jsx)("p",{style:{fontSize:13,color:"#6b7280",margin:"4px 0 20px 0"},children:"Third-party guardrail integrations from leading AI security providers."}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:16},children:u.map(e=>(0,t.jsx)(C,{card:e,onClick:()=>n(e)},e.id))})]})]})};var O=e.i(988846),T=e.i(837007),P=e.i(409797),L=e.i(54131),B=e.i(995926),F=e.i(678784),$=e.i(634831),E=e.i(438100),M=e.i(302202),R=e.i(328196),G=e.i(879664);e.s(["InfoIcon",()=>G.default],168118);var G=G,z=e.i(212931),D=e.i(808613),K=e.i(199133),H=e.i(663435),q=e.i(954616),J=e.i(912598),U=e.i(135214),W=e.i(243652);let V=async(e,t)=>{let a=(0,d.getProxyBaseUrl)(),l=`${a}/guardrails/register`,r=await fetch(l,{method:"POST",headers:{[(0,d.getGlobalLitellmHeaderName)()]:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>({})),t=(0,d.deriveErrorMessage)(e);throw(0,d.handleError)(t),Error(t)}return r.json()},Y=(0,W.createQueryKeys)("guardrails");function Q(e){var t;let a=e.litellm_params??{},l=e.guardrail_info??{},r=a.headers,i=Array.isArray(r)?r.map(e=>({key:(e.key??e.name??"").toString(),value:String(e.value??"")})):"object"==typeof r&&null!==r?Object.entries(r).map(([e,t])=>({key:e,value:String(t??"")})):[],s=a.api_base??a.url??"",n=l.model??a.model??"—",o=a.forward_api_key??!0,d=Array.isArray(a.extra_headers)?a.extra_headers.filter(e=>"string"==typeof e):[];return{id:e.guardrail_id,team:e.team_id??"—",name:e.guardrail_name,endpoint:s,status:"pending_review"===(t=e.status)?"pending":"active"===t||"rejected"===t?t:"active",model:n,forwardKey:o,description:l.description??"",method:a.method??"POST",customHeaders:i,extraHeaders:d,submittedAt:function(e){if(!e)return"—";try{let t=new Date(e);return isNaN(t.getTime())?e:t.toISOString().slice(0,10)}catch{return e}}(e.submitted_at),submittedBy:e.submitted_by_email??e.submitted_by_user_id??"—",mode:a.mode,unreachable_fallback:a.unreachable_fallback,additionalProviderParams:a.additional_provider_specific_params,guardrailType:a.guardrail}}let Z={active:{label:"Active",bg:"bg-green-50",text:"text-green-700",dot:"bg-green-500"},pending:{label:"Pending Review",bg:"bg-yellow-50",text:"text-yellow-700",dot:"bg-yellow-500"},rejected:{label:"Rejected",bg:"bg-red-50",text:"text-red-700",dot:"bg-red-500"}},X={"ML Platform":"bg-purple-100 text-purple-700","Data Science":"bg-blue-100 text-blue-700",Security:"bg-red-100 text-red-700","Customer Success":"bg-orange-100 text-orange-700",Legal:"bg-gray-100 text-gray-700",Finance:"bg-green-100 text-green-700"};function ee({label:e,value:a,color:l}){return(0,t.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg px-4 py-3",children:[(0,t.jsx)("div",{className:`text-2xl font-bold ${l}`,children:a}),(0,t.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:e})]})}function et({enabled:e,onToggle:a}){return(0,t.jsx)("button",{type:"button",onClick:a,role:"switch","aria-checked":e,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 ${e?"bg-blue-500":"bg-gray-200"}`,children:(0,t.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow transition-transform ${e?"translate-x-4":"translate-x-0.5"}`})})}function ea({guardrail:e,isSelected:a,isHeadersExpanded:l,onSelect:r,onToggleForwardKey:i,onToggleHeaders:s,onApprove:n,onReject:o}){let d=Z[e.status],c=X[e.team]??"bg-gray-100 text-gray-700";return(0,t.jsxs)("div",{className:`bg-white border rounded-lg p-4 transition-all ${a?"border-blue-400 ring-1 ring-blue-200":"border-gray-200"}`,children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[(0,t.jsxs)("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${c}`,children:["Team: ",e.team]}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium px-2 py-0.5 rounded-full ${d.bg} ${d.text}`,children:[(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${d.dot}`}),d.label]})]}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-1",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mb-2 line-clamp-1",children:e.description}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,t.jsx)(M.ServerIcon,{className:"h-3.5 w-3.5 text-gray-400 flex-shrink-0"}),(0,t.jsx)("code",{className:"text-xs text-gray-500 font-mono truncate",children:e.endpoint})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[(0,t.jsxs)("span",{children:["Model: ",(0,t.jsx)("span",{className:"font-medium text-gray-700",children:e.model})]}),(0,t.jsxs)("span",{children:["Submitted:"," ",(0,t.jsx)("span",{className:"font-medium text-gray-700",children:e.submittedAt})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col items-end gap-2 flex-shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:"Forward API Key"}),(0,t.jsx)(et,{enabled:e.forwardKey,onToggle:i})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs border border-gray-300 text-gray-600 hover:bg-gray-50 px-3 py-1.5 rounded-md transition-colors font-medium",children:a?"Close":"Review"}),"pending"===e.status&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:n,className:"text-xs bg-green-500 hover:bg-green-600 text-white px-3 py-1.5 rounded-md transition-colors font-medium",children:"Approve"}),(0,t.jsx)("button",{type:"button",onClick:o,className:"text-xs border border-red-300 text-red-600 hover:bg-red-50 px-3 py-1.5 rounded-md transition-colors font-medium",children:"Reject"})]})]})]})]}),(0,t.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[(0,t.jsxs)("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-gray-700 transition-colors",children:[l?(0,t.jsx)(L.ChevronUpIcon,{className:"h-3.5 w-3.5"}):(0,t.jsx)(P.ChevronDownIcon,{className:"h-3.5 w-3.5"}),"Static headers",e.customHeaders.length>0&&(0,t.jsx)("span",{className:"ml-1 bg-gray-100 text-gray-600 rounded-full px-1.5 py-0.5 text-xs",children:e.customHeaders.length})]}),l&&(0,t.jsx)("div",{className:"mt-2",children:0===e.customHeaders.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 italic",children:"No static headers configured."}):(0,t.jsx)("div",{className:"space-y-1",children:e.customHeaders.map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs font-mono",children:[(0,t.jsx)("span",{className:"text-gray-500 bg-gray-50 border border-gray-200 rounded px-2 py-0.5",children:e.key}),(0,t.jsx)("span",{className:"text-gray-400",children:":"}),(0,t.jsx)("span",{className:"text-gray-700 bg-gray-50 border border-gray-200 rounded px-2 py-0.5",children:e.value})]},`${e.key}-${a}`))})})]})]})}function el({label:e,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-semibold text-gray-500 mb-1",children:e}),(0,t.jsx)("div",{children:a})]})}function er({guardrail:e,onClose:l,onApprove:r,onReject:i,onToggleForwardKey:s,onUpdateCustomHeaders:n,onUpdateExtraHeaders:o}){let[d,c]=(0,a.useState)(!1),[m,u]=(0,a.useState)(""),[p,g]=(0,a.useState)(""),[x,h]=(0,a.useState)(""),f=Z[e.status],y=X[e.team]??"bg-gray-100 text-gray-700";return(0,t.jsx)("div",{className:"w-96 flex-shrink-0 bg-white overflow-auto",children:(0,t.jsxs)("div",{className:"p-5",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsxs)("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${y}`,children:["Team: ",e.team]}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium px-2 py-0.5 rounded-full ${f.bg} ${f.text}`,children:[(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${f.dot}`}),f.label]})]}),(0,t.jsx)("h2",{className:"text-base font-semibold text-gray-900",children:e.name}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:["Submitted by ",e.submittedBy," on ",e.submittedAt]})]}),(0,t.jsx)("button",{type:"button",onClick:l,className:"text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Close detail panel",children:(0,t.jsx)(B.XIcon,{className:"h-4 w-4"})})]}),(0,t.jsx)("p",{className:"text-sm text-gray-600 mb-5",children:e.description}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(el,{label:"Endpoint",children:(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("code",{className:"text-xs font-mono text-gray-700 break-all",children:e.endpoint}),(0,t.jsx)("a",{href:e.endpoint,target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-blue-500 flex-shrink-0",children:(0,t.jsx)($.ExternalLinkIcon,{className:"h-3.5 w-3.5"})})]})}),(0,t.jsx)(el,{label:"Method",children:(0,t.jsx)("span",{className:"text-xs font-mono font-medium text-gray-700 bg-gray-100 px-2 py-0.5 rounded",children:e.method})}),(0,t.jsxs)("div",{className:"border border-blue-100 bg-blue-50 rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(E.KeyIcon,{className:"h-3.5 w-3.5 text-blue-500"}),(0,t.jsx)("span",{className:"text-xs font-semibold text-blue-800",children:"Forward LiteLLM API Key"})]}),(0,t.jsx)(et,{enabled:e.forwardKey,onToggle:s})]}),(0,t.jsxs)("p",{className:"text-xs text-blue-700 leading-relaxed",children:["When enabled, the caller's LiteLLM API key is forwarded as an"," ",(0,t.jsx)("code",{className:"font-mono bg-blue-100 px-1 rounded",children:"Authorization"})," ","header to your guardrail endpoint. This allows your guardrail to authenticate model calls using the original caller's credentials."]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-700",children:"Static headers"}),e.customHeaders.length>0&&(0,t.jsx)("span",{className:"bg-gray-100 text-gray-600 rounded-full px-1.5 py-0.5 text-xs",children:e.customHeaders.length})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"Sent with every request to the guardrail."}),0===e.customHeaders.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 italic mb-2",children:"No static headers configured."}):(0,t.jsx)("ul",{className:"list-none space-y-1 mb-2",children:e.customHeaders.map((a,l)=>(0,t.jsxs)("li",{className:"flex items-center justify-between gap-2 text-xs font-mono bg-gray-50 border border-gray-200 rounded px-2 py-1.5",children:[(0,t.jsxs)("span",{className:"text-gray-700 truncate",children:[a.key,": ",a.value]}),(0,t.jsx)("button",{type:"button",onClick:()=>n(e.customHeaders.filter((e,t)=>t!==l)),className:"text-gray-400 hover:text-red-600 flex-shrink-0","aria-label":`Remove ${a.key}`,children:(0,t.jsx)(B.XIcon,{className:"h-3.5 w-3.5"})})]},`${a.key}-${l}`))}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,t.jsx)("input",{type:"text",value:p,onChange:e=>g(e.target.value),placeholder:"Header name (e.g. X-API-Key)",className:"flex-1 min-w-0 text-xs font-mono border border-gray-200 rounded px-2 py-1.5 text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-500",onKeyDown:t=>{if("Enter"===t.key){t.preventDefault();let a=p.trim(),l=x.trim();a&&!e.customHeaders.some(e=>e.key.toLowerCase()===a.toLowerCase())&&(n([...e.customHeaders,{key:a,value:l}]),g(""),h(""))}}}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),placeholder:"Value",className:"flex-1 min-w-0 text-xs font-mono border border-gray-200 rounded px-2 py-1.5 text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-500",onKeyDown:t=>{if("Enter"===t.key){t.preventDefault();let a=p.trim(),l=x.trim();a&&!e.customHeaders.some(e=>e.key.toLowerCase()===a.toLowerCase())&&(n([...e.customHeaders,{key:a,value:l}]),g(""),h(""))}}}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t=p.trim(),a=x.trim();t&&!e.customHeaders.some(e=>e.key.toLowerCase()===t.toLowerCase())&&(n([...e.customHeaders,{key:t,value:a}]),g(""),h(""))},className:"text-xs font-medium text-blue-600 hover:text-blue-700 border border-blue-200 bg-blue-50 hover:bg-blue-100 px-2 py-1.5 rounded transition-colors flex-shrink-0",children:"Add"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-700",children:"Forward client headers"}),e.extraHeaders.length>0&&(0,t.jsx)("span",{className:"bg-gray-100 text-gray-600 rounded-full px-1.5 py-0.5 text-xs",children:e.extraHeaders.length})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"Allowed header names to forward from the client request to the guardrail (e.g. x-request-id)."}),0===e.extraHeaders.length?(0,t.jsx)("p",{className:"text-xs text-gray-400 italic mb-2",children:"No forward client headers configured."}):(0,t.jsx)("ul",{className:"list-none space-y-1 mb-2",children:e.extraHeaders.map((a,l)=>(0,t.jsxs)("li",{className:"flex items-center justify-between gap-2 text-xs font-mono bg-gray-50 border border-gray-200 rounded px-2 py-1.5",children:[(0,t.jsx)("span",{className:"text-gray-700 truncate",children:a}),(0,t.jsx)("button",{type:"button",onClick:()=>o(e.extraHeaders.filter((e,t)=>t!==l)),className:"text-gray-400 hover:text-red-600 flex-shrink-0","aria-label":`Remove ${a}`,children:(0,t.jsx)(B.XIcon,{className:"h-3.5 w-3.5"})})]},`${a}-${l}`))}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text",value:m,onChange:e=>u(e.target.value),placeholder:"e.g. x-request-id",className:"flex-1 min-w-0 text-xs font-mono border border-gray-200 rounded px-2 py-1.5 text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-500",onKeyDown:t=>{if("Enter"===t.key){t.preventDefault();let a=m.trim().toLowerCase();a&&!e.extraHeaders.map(e=>e.toLowerCase()).includes(a)&&(o([...e.extraHeaders,a]),u(""))}}}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t=m.trim().toLowerCase();t&&!e.extraHeaders.map(e=>e.toLowerCase()).includes(t)&&(o([...e.extraHeaders,t]),u(""))},className:"text-xs font-medium text-blue-600 hover:text-blue-700 border border-blue-200 bg-blue-50 hover:bg-blue-100 px-2 py-1.5 rounded transition-colors",children:"Add"})]})]}),(0,t.jsxs)("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>c(!d),className:"w-full flex items-center justify-between px-3 py-2 text-left text-xs font-semibold text-gray-700 bg-gray-50 hover:bg-gray-100 transition-colors",children:[(0,t.jsx)("span",{children:"Equivalent config"}),d?(0,t.jsx)(L.ChevronUpIcon,{className:"h-3.5 w-3.5 text-gray-500"}):(0,t.jsx)(P.ChevronDownIcon,{className:"h-3.5 w-3.5 text-gray-500"})]}),d&&(0,t.jsx)("pre",{className:"p-3 text-xs font-mono text-gray-700 bg-white border-t border-gray-200 overflow-x-auto whitespace-pre-wrap break-all",children:function(e){let t=["litellm_settings:"," guardrails:",` - guardrail_name: "${e.name.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`," litellm_params:",` guardrail: ${e.guardrailType??"generic_guardrail_api"}`,` mode: ${e.mode??"pre_call"} # or post_call, during_call`,` api_base: ${e.endpoint||"https://your-guardrail-api.com"}`," api_key: os.environ/YOUR_GUARDRAIL_API_KEY # optional",` unreachable_fallback: ${e.unreachable_fallback??"fail_closed"} # default: fail_closed. Set to fail_open to proceed if the guardrail endpoint is unreachable.`,` forward_api_key: ${e.forwardKey}`];if(e.model&&"—"!==e.model&&t.push(` model: "${e.model}" # LLM model name sent to the guardrail for context`),e.customHeaders.length>0)for(let a of(t.push(" headers: # static headers (sent with every request)"),e.customHeaders))t.push(` ${a.key}: "${String(a.value).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`);if(e.extraHeaders.length>0)for(let a of(t.push(" extra_headers: # forward these client request headers to the guardrail"),e.extraHeaders))t.push(` - ${a}`);if(e.additionalProviderParams&&Object.keys(e.additionalProviderParams).length>0)for(let[a,l]of(t.push(" additional_provider_specific_params:"),Object.entries(e.additionalProviderParams))){let e="string"==typeof l?`"${l}"`:String(l);t.push(` ${a}: ${e}`)}return t.join("\n")}(e)})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2 bg-gray-50 border border-gray-200 rounded-lg p-3",children:[(0,t.jsx)(G.default,{className:"h-3.5 w-3.5 text-gray-400 flex-shrink-0 mt-0.5"}),(0,t.jsxs)("p",{className:"text-xs text-gray-500 leading-relaxed",children:["This guardrail runs on a separate instance. It receives the user request and forwards the result to the next step in the pipeline. See"," ",(0,t.jsx)("a",{href:"https://docs.litellm.ai/docs/adding_provider/generic_guardrail_api",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:"LiteLLM Generic Guardrail API docs"})," ","for configuration details."]})]})]}),(0,t.jsxs)("div",{className:"mt-5 pt-4 border-t border-gray-100 space-y-2",children:[(0,t.jsxs)("button",{type:"button",className:"w-full flex items-center justify-center gap-2 border border-gray-300 text-gray-700 hover:bg-gray-50 text-sm font-medium py-2 rounded-md transition-colors",children:[(0,t.jsx)($.ExternalLinkIcon,{className:"h-4 w-4"}),"Test Endpoint"]}),"pending"===e.status&&(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:r,className:"flex-1 flex items-center justify-center gap-1.5 bg-green-500 hover:bg-green-600 text-white text-sm font-medium py-2 rounded-md transition-colors",children:[(0,t.jsx)(F.CheckIcon,{className:"h-4 w-4"}),"Approve"]}),(0,t.jsxs)("button",{type:"button",onClick:i,className:"flex-1 flex items-center justify-center gap-1.5 border border-red-300 text-red-600 hover:bg-red-50 text-sm font-medium py-2 rounded-md transition-colors",children:[(0,t.jsx)(B.XIcon,{className:"h-4 w-4"}),"Reject"]})]})]})]})})}function ei({action:e,guardrailName:a,onConfirm:l,onCancel:r}){let i="approve"===e;return(0,t.jsx)("div",{className:"fixed inset-0 bg-black/30 flex items-center justify-center z-50",children:(0,t.jsxs)("div",{className:"bg-white rounded-xl shadow-xl p-6 max-w-sm w-full mx-4",children:[(0,t.jsx)("div",{className:`w-10 h-10 rounded-full flex items-center justify-center mb-4 ${i?"bg-green-100":"bg-red-100"}`,children:i?(0,t.jsx)(F.CheckIcon,{className:"h-5 w-5 text-green-600"}):(0,t.jsx)(R.AlertCircleIcon,{className:"h-5 w-5 text-red-600"})}),(0,t.jsx)("h3",{className:"text-base font-semibold text-gray-900 mb-1",children:i?"Approve Guardrail":"Reject Guardrail"}),(0,t.jsxs)("p",{className:"text-sm text-gray-500 mb-5",children:["Are you sure you want to ",e," ",(0,t.jsxs)("span",{className:"font-medium text-gray-700",children:['"',a,'"']}),"?"," ",i?"This will make it active and available for use.":"This will mark it as rejected and notify the team."]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("button",{type:"button",onClick:r,className:"flex-1 border border-gray-300 text-gray-700 hover:bg-gray-50 text-sm font-medium py-2 rounded-md transition-colors",children:"Cancel"}),(0,t.jsx)("button",{type:"button",onClick:l,className:`flex-1 text-white text-sm font-medium py-2 rounded-md transition-colors ${i?"bg-green-500 hover:bg-green-600":"bg-red-500 hover:bg-red-600"}`,children:i?"Approve":"Reject"})]})]})})}function es({accessToken:e}){let[l,r]=(0,a.useState)([]),[i,s]=(0,a.useState)({total:0,pending_review:0,active:0,rejected:0}),[n,o]=(0,a.useState)(""),[c,m]=(0,a.useState)("all"),[u,p]=(0,a.useState)(null),[g,h]=(0,a.useState)(new Set),[f,y]=(0,a.useState)(null),[_,b]=(0,a.useState)(!0),[v,w]=(0,a.useState)(null),[N,C]=(0,a.useState)(""),[S,k]=(0,a.useState)(!1),[I]=D.Form.useForm(),A=(()=>{let{accessToken:e}=(0,U.default)(),t=(0,J.useQueryClient)();return(0,q.useMutation)({mutationFn:async t=>{if(!e)throw Error("Access token is required");return V(e,t)},onSuccess:()=>{t.invalidateQueries({queryKey:Y.all})}})})();(0,a.useEffect)(()=>{let e=setTimeout(()=>C(n),300);return()=>clearTimeout(e)},[n]);let P=(0,a.useCallback)(async()=>{if(!e)return void b(!1);b(!0),w(null);try{let t="all"===c?void 0:"pending"===c?"pending_review":c,a=await (0,d.listGuardrailSubmissions)(e,{status:t,search:N.trim()||void 0});r(a.submissions.map(Q)),s(a.summary)}catch(e){w(e instanceof Error?e.message:"Failed to load submissions"),r([])}finally{b(!1)}},[e,c,N]);(0,a.useEffect)(()=>{P()},[P]);let L=l.find(e=>e.id===u)??null,B=i.total,F=i.pending_review,$=i.active,E=i.rejected;async function M(t){if(!e)return;let a=l.find(e=>e.id===t);if(!a)return;let i=!a.forwardKey;try{await (0,d.updateGuardrailCall)(e,t,{litellm_params:{forward_api_key:i}}),r(e=>e.map(e=>e.id===t?{...e,forwardKey:i}:e)),x.default.success(i?"Forward API key enabled":"Forward API key disabled")}catch{x.default.fromBackend("Failed to update forward API key")}}async function R(t,a){if(!e)return;let l={};for(let{key:e,value:t}of a)e.trim()&&(l[e.trim()]=t);try{await (0,d.updateGuardrailCall)(e,t,{litellm_params:{headers:l}}),r(e=>e.map(e=>e.id===t?{...e,customHeaders:a.filter(e=>e.key.trim())}:e)),x.default.success("Static headers updated")}catch{x.default.fromBackend("Failed to update static headers")}}async function G(t,a){if(e)try{await (0,d.updateGuardrailCall)(e,t,{litellm_params:{extra_headers:a}}),r(e=>e.map(e=>e.id===t?{...e,extraHeaders:a}:e)),x.default.success("Forward client headers updated")}catch{x.default.fromBackend("Failed to update forward client headers")}}async function W(t){if(e)try{await (0,d.approveGuardrailSubmission)(e,t),y(null),u===t&&p(null),await P(),x.default.success("Guardrail approved")}catch{x.default.fromBackend("Failed to approve guardrail")}}async function Z(t){if(e)try{await (0,d.rejectGuardrailSubmission)(e,t),y(null),u===t&&p(null),await P(),x.default.success("Guardrail rejected")}catch{x.default.fromBackend("Failed to reject guardrail")}}return(0,t.jsxs)("div",{className:"flex h-full",children:[(0,t.jsxs)("div",{className:`flex-1 min-w-0 p-6 overflow-auto ${L?"border-r border-gray-200":""}`,children:[(0,t.jsxs)("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[(0,t.jsx)(ee,{label:"Total Submitted",value:B,color:"text-gray-900"}),(0,t.jsx)(ee,{label:"Pending Review",value:F,color:"text-yellow-600"}),(0,t.jsx)(ee,{label:"Active",value:$,color:"text-green-600"}),(0,t.jsx)(ee,{label:"Rejected",value:E,color:"text-red-600"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,t.jsx)(O.SearchIcon,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,t.jsx)("input",{type:"text",placeholder:"Search guardrails...",value:n,onChange:e=>o(e.target.value),className:"w-full pl-9 pr-4 py-2 border border-gray-200 rounded-md text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"})]}),(0,t.jsxs)("select",{value:c,onChange:e=>m(e.target.value),className:"border border-gray-200 rounded-md px-3 py-2 text-sm text-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 bg-white",children:[(0,t.jsx)("option",{value:"all",children:"All Status"}),(0,t.jsx)("option",{value:"pending",children:"Pending Review"}),(0,t.jsx)("option",{value:"active",children:"Active"}),(0,t.jsx)("option",{value:"rejected",children:"Rejected"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>k(!0),className:"ml-auto flex items-center gap-2 bg-blue-500 hover:bg-blue-600 text-white text-sm font-medium px-4 py-2 rounded-md transition-colors",children:[(0,t.jsx)(T.PlusIcon,{className:"h-4 w-4"}),"Add Guardrail"]})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[_&&(0,t.jsx)("div",{className:"text-center py-12 text-gray-500 text-sm",children:"Loading submissions…"}),v&&(0,t.jsx)("div",{className:"text-center py-12 text-red-600 text-sm",children:v}),!_&&!v&&0===l.length&&(0,t.jsx)("div",{className:"text-center py-12 text-gray-400 text-sm",children:"No guardrails match your filters."}),!_&&!v&&l.map(e=>(0,t.jsx)(ea,{guardrail:e,isSelected:u===e.id,isHeadersExpanded:g.has(e.id),onSelect:()=>p(u===e.id?null:e.id),onToggleForwardKey:()=>M(e.id),onToggleHeaders:()=>{var t;return t=e.id,void h(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a})},onApprove:()=>y({id:e.id,action:"approve"}),onReject:()=>y({id:e.id,action:"reject"})},e.id))]})]}),L&&(0,t.jsx)(er,{guardrail:L,onClose:()=>p(null),onApprove:()=>y({id:L.id,action:"approve"}),onReject:()=>y({id:L.id,action:"reject"}),onToggleForwardKey:()=>M(L.id),onUpdateCustomHeaders:e=>R(L.id,e),onUpdateExtraHeaders:e=>G(L.id,e)}),f&&(0,t.jsx)(ei,{action:f.action,guardrailName:l.find(e=>e.id===f.id)?.name??"",onConfirm:()=>"approve"===f.action?W(f.id):Z(f.id),onCancel:()=>y(null)}),(0,t.jsxs)(z.Modal,{title:"Submit Guardrail for Review",open:S,onCancel:()=>{k(!1),I.resetFields()},onOk:()=>I.submit(),okText:"Submit for Review",children:[(0,t.jsx)("div",{className:"rounded-md bg-blue-50 border border-blue-200 px-4 py-3 text-sm text-blue-800 mb-4",children:"Your guardrail will be sent for admin review before it becomes active."}),(0,t.jsxs)(D.Form,{form:I,layout:"vertical",initialValues:{mode:"pre_call"},onFinish:async e=>{let t={...e.extra_litellm_params?JSON.parse(e.extra_litellm_params):{},guardrail:"generic_guardrail_api",mode:e.mode,api_base:e.api_base};try{await A.mutateAsync({team_id:e.team_id,guardrail_name:e.guardrail_name,litellm_params:t,guardrail_info:e.guardrail_info?JSON.parse(e.guardrail_info):void 0}),x.default.success("Guardrail submitted for review"),k(!1),I.resetFields(),P()}catch{}},children:[(0,t.jsx)(D.Form.Item,{label:"Team",name:"team_id",rules:[{required:!0,message:"Select a team"}],children:(0,t.jsx)(H.default,{})}),(0,t.jsx)(D.Form.Item,{label:"Guardrail Name",name:"guardrail_name",rules:[{required:!0,message:"Enter a guardrail name"}],children:(0,t.jsx)(j.Input,{placeholder:"e.g. pii-detection"})}),(0,t.jsx)(D.Form.Item,{label:"Mode",name:"mode",rules:[{required:!0,message:"Select a mode"}],children:(0,t.jsxs)(K.Select,{children:[(0,t.jsx)(K.Select.Option,{value:"pre_call",children:"Pre Call"}),(0,t.jsx)(K.Select.Option,{value:"post_call",children:"Post Call"}),(0,t.jsx)(K.Select.Option,{value:"during_call",children:"During Call"})]})}),(0,t.jsx)(D.Form.Item,{label:"API Base URL",name:"api_base",rules:[{required:!0,message:"Enter the API base URL"},{type:"url",message:"Must be a valid URL"}],children:(0,t.jsx)(j.Input,{placeholder:"https://your-guardrail-api.com/v1/check",className:"font-mono"})}),(0,t.jsx)(D.Form.Item,{label:"Additional litellm_params (optional)",name:"extra_litellm_params",tooltip:"JSON object merged into litellm_params. e.g. forward_api_key, headers, model, unreachable_fallback",rules:[{validator:(e,t)=>{if(!t)return Promise.resolve();try{let e=JSON.parse(t);if("object"!=typeof e||Array.isArray(e))return Promise.reject("Must be a JSON object");return Promise.resolve()}catch{return Promise.reject("Invalid JSON")}}}],children:(0,t.jsx)(j.Input.TextArea,{rows:3,className:"font-mono text-xs",placeholder:'{"forward_api_key": true, "headers": {"X-Custom": "value"}}'})}),(0,t.jsx)(D.Form.Item,{label:"Guardrail Info (optional)",name:"guardrail_info",rules:[{validator:(e,t)=>{if(!t)return Promise.resolve();try{return JSON.parse(t),Promise.resolve()}catch{return Promise.reject("Invalid JSON")}}}],children:(0,t.jsx)(j.Input.TextArea,{rows:3,className:"font-mono text-xs",placeholder:'{"description": "Detects PII in requests"}'})})]})]})]})}e.s(["default",0,({accessToken:e,userRole:j})=>{let[_,b]=(0,a.useState)([]),[v,w]=(0,a.useState)(!1),[N,C]=(0,a.useState)(!1),[S,k]=(0,a.useState)(!1),[I,O]=(0,a.useState)(!1),[T,P]=(0,a.useState)(null),[L,B]=(0,a.useState)(!1),[F,$]=(0,a.useState)(null),E=!!j&&(0,u.isAdminRole)(j),M=async()=>{if(e){k(!0);try{let t=await (0,d.getGuardrailsList)(e);console.log(`guardrails: ${JSON.stringify(t)}`),b(t.guardrails)}catch(e){console.error("Error fetching guardrails:",e)}finally{k(!1)}}};(0,a.useEffect)(()=>{M()},[e]);let R=()=>{M()},G=async()=>{if(T&&e){O(!0);try{await (0,d.deleteGuardrailCall)(e,T.guardrail_id),x.default.success(`Guardrail "${T.guardrail_name}" deleted successfully`),await M()}catch(e){console.error("Error deleting guardrail:",e),x.default.fromBackend("Failed to delete guardrail")}finally{O(!1),B(!1),P(null)}}},z=T&&T.litellm_params?(0,f.getGuardrailLogoAndName)(T.litellm_params.guardrail).displayName:void 0;return(0,t.jsx)("div",{className:"w-full mx-auto flex-auto overflow-y-auto m-8 p-2",children:(0,t.jsx)(i.Tabs,{defaultActiveKey:"submitted",items:[...E?[{key:"garden",label:"Guardrail Garden",children:(0,t.jsx)(A,{accessToken:e,onGuardrailCreated:R})},{key:"guardrails",label:"Guardrails",children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex justify-between items-center mb-4",children:(0,t.jsx)(r.Dropdown,{menu:{items:[{key:"provider",icon:(0,t.jsx)(n.PlusOutlined,{}),label:"Add Provider Guardrail",onClick:()=>{F&&$(null),w(!0)}},{key:"custom_code",icon:(0,t.jsx)(o.CodeOutlined,{}),label:"Create Custom Code Guardrail",onClick:()=>{F&&$(null),C(!0)}}]},trigger:["click"],disabled:!e,children:(0,t.jsxs)(l.Button,{disabled:!e,children:["+ Add New Guardrail ",(0,t.jsx)(s.DownOutlined,{className:"ml-2"})]})})}),F?(0,t.jsx)(p.default,{guardrailId:F,onClose:()=>$(null),accessToken:e,isAdmin:E}):(0,t.jsx)(m.default,{guardrailsList:_,isLoading:S,onDeleteClick:(e,t)=>{P(_.find(t=>t.guardrail_id===e)||null),B(!0)},accessToken:e,onGuardrailUpdated:M,isAdmin:E,onGuardrailClick:e=>$(e)}),(0,t.jsx)(c.default,{visible:v,onClose:()=>{w(!1)},accessToken:e,onSuccess:R}),(0,t.jsx)(y.CustomCodeModal,{visible:N,onClose:()=>{C(!1)},accessToken:e,onSuccess:R}),(0,t.jsx)(h.default,{isOpen:L,title:"Delete Guardrail",message:`Are you sure you want to delete guardrail: ${T?.guardrail_name}? This action cannot be undone.`,resourceInformationTitle:"Guardrail Information",resourceInformation:[{label:"Name",value:T?.guardrail_name},{label:"ID",value:T?.guardrail_id,code:!0},{label:"Provider",value:z},{label:"Mode",value:T?.litellm_params.mode},{label:"Default On",value:T?.litellm_params.default_on?"Yes":"No"}],onCancel:()=>{B(!1),P(null)},onOk:G,confirmLoading:I})]})},{key:"playground",label:"Test Playground",disabled:!e,children:(0,t.jsx)(g.default,{guardrailsList:_,isLoading:S,accessToken:e,onClose:()=>{}})}]:[],{key:"submitted",label:"Submitted Guardrails",children:(0,t.jsx)(es,{accessToken:e})}]})})}],487304)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/03c715f5e0f1425c.js b/litellm/proxy/_experimental/out/_next/static/chunks/03c715f5e0f1425c.js new file mode 100644 index 0000000000..963ac87c93 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/03c715f5e0f1425c.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,56567,838932,471145,e=>{"use strict";var t=e.i(843476),l=e.i(135214),a=e.i(109799),s=e.i(912598),i=e.i(907308),r=e.i(764205),n=e.i(266027);let o=(0,e.i(243652).createQueryKeys)("guardrails"),d=()=>{let{accessToken:e,userId:t,userRole:a}=(0,l.default)();return(0,n.useQuery)({queryKey:o.list({}),queryFn:async()=>(0,r.getGuardrailsList)(e),enabled:!!(e&&t&&a),select:e=>{let t=e?.guardrails??[],l=new Set,a=new Set;for(let e of t)e.litellm_params?.default_on?l.add(e.guardrail_name):a.add(e.guardrail_name);return{guardrails:t,globalGuardrailNames:l,optionalGuardrailNames:a}}})};e.s(["useGuardrails",0,d],838932);var m=e.i(500330),c=e.i(11751),u=e.i(708347),g=e.i(751904),h=e.i(160818),p=e.i(827252),x=e.i(564897),_=e.i(646563),b=e.i(987432),y=e.i(530212),j=e.i(677667),f=e.i(130643),v=e.i(898667),T=e.i(389083),S=e.i(304967),w=e.i(350967),N=e.i(599724),C=e.i(779241),k=e.i(629569),I=e.i(464571),M=e.i(808613),z=e.i(311451),A=e.i(28651),F=e.i(199133),O=e.i(770914),P=e.i(790848),D=e.i(653496),L=e.i(262218),R=e.i(592968),B=e.i(888259),V=e.i(678784),U=e.i(118366),E=e.i(271645),$=e.i(9314),K=e.i(552130),G=e.i(127952);function W({className:e,value:l,onChange:a}){return(0,t.jsxs)(F.Select,{className:e,value:l,onChange:a,children:[(0,t.jsx)(F.Select.Option,{value:"24h",children:"Daily"}),(0,t.jsx)(F.Select.Option,{value:"7d",children:"Weekly"}),(0,t.jsx)(F.Select.Option,{value:"30d",children:"Monthly"})]})}var q=e.i(844565),H=e.i(355619);let J=function({globalGuardrailNames:e,teamGuardrails:l=[],optedOutGlobalGuardrails:a=[],killSwitchOn:s=!1,variant:i="card",className:r=""}){let n=new Set(a),o=Array.from(e).filter(e=>!n.has(e)),d=l.filter(t=>!e.has(t)),m=s||0!==o.length||0!==d.length?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"block text-sm font-medium text-gray-700 mb-2",children:[(0,t.jsx)(h.GlobalOutlined,{style:{marginInlineEnd:4},"aria-label":"Global guardrail"}),"Global"]}),s?(0,t.jsx)(L.Tag,{color:"gold",children:"Bypassed for this team"}):o.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,t.jsx)(L.Tag,{color:"blue",children:e},e))}):(0,t.jsx)("span",{className:"block text-sm text-gray-500",children:"None configured"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Team-specific"}),d.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:d.map(e=>(0,t.jsx)(L.Tag,{color:"blue",children:e},e))}):(0,t.jsx)("span",{className:"block text-sm text-gray-500",children:"None configured"})]})]}):(0,t.jsx)("span",{className:"block text-gray-500",children:"No guardrails configured"});return"card"===i?(0,t.jsxs)("div",{className:`bg-white border border-gray-200 rounded-lg p-6 ${r}`,children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-6",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"block font-semibold text-gray-900",children:"Guardrails Settings"}),(0,t.jsx)("span",{className:"block text-xs text-gray-500",children:"Global and team-specific guardrails applied to this team"})]})}),m]}):(0,t.jsxs)("div",{className:`${r}`,children:[(0,t.jsx)("span",{className:"block font-medium text-gray-900 mb-3",children:"Guardrails Settings"}),m]})};var Q=e.i(643449),Y=e.i(75921),X=e.i(390605),Z=e.i(162386),ee=e.i(727749),et=e.i(384767),el=e.i(435451),ea=e.i(916940);let es=({onChange:e,value:l,className:a,accessToken:s,placeholder:i="Select search tools (optional)",disabled:n=!1})=>{let[o,d]=(0,E.useState)([]),[m,c]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{(async()=>{if(s){c(!0);try{let e=await (0,r.fetchSearchTools)(s),t=Array.isArray(e?.search_tools)?e.search_tools:Array.isArray(e?.data)?e.data:[];d(t.map(e=>e?.search_tool_name).filter(e=>"string"==typeof e&&e.length>0).map(e=>({label:e,value:e})))}catch(e){console.error("Failed to load search tools:",e)}finally{c(!1)}}})()},[s]),(0,t.jsx)(F.Select,{mode:"multiple",allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:i,onChange:e,value:l,loading:m,className:a,options:o,style:{width:"100%"},disabled:n})};e.s(["default",0,es],471145);var ei=e.i(183588),er=e.i(460285),en=e.i(276173),eo=e.i(91979),ed=e.i(269200),em=e.i(942232),ec=e.i(977572),eu=e.i(427612),eg=e.i(64848),eh=e.i(496020),ep=e.i(536916),ex=e.i(21548);let e_={"/key/generate":"Member can generate a virtual key for this team","/key/service-account/generate":"Member can generate a service account key (not belonging to any user) for this team","/key/update":"Member can update a virtual key belonging to this team","/key/delete":"Member can delete a virtual key belonging to this team","/key/info":"Member can get info about a virtual key belonging to this team","/key/regenerate":"Member can regenerate a virtual key belonging to this team","/key/{key_id}/regenerate":"Member can regenerate a virtual key belonging to this team","/key/list":"Member can list virtual keys belonging to this team","/key/block":"Member can block a virtual key belonging to this team","/key/unblock":"Member can unblock a virtual key belonging to this team","/team/daily/activity":"Member can view all team usage data (not just their own)","/spend/logs":"Member can view spend logs for the entire team (not just their own)"},eb=({teamId:e,accessToken:l,canEditTeam:a})=>{let[s,i]=(0,E.useState)([]),[n,o]=(0,E.useState)([]),[d,m]=(0,E.useState)(!0),[c,u]=(0,E.useState)(!1),[g,h]=(0,E.useState)(!1),p=async()=>{try{if(m(!0),!l)return;let t=await (0,r.getTeamPermissionsCall)(l,e),a=t.all_available_permissions||[];i(a);let s=t.team_member_permissions||[];o(s),h(!1)}catch(e){ee.default.fromBackend("Failed to load permissions"),console.error("Error fetching permissions:",e)}finally{m(!1)}};(0,E.useEffect)(()=>{p()},[e,l]);let x=async()=>{try{if(!l)return;u(!0),await (0,r.teamPermissionsUpdateCall)(l,e,n),ee.default.success("Permissions updated successfully"),h(!1)}catch(e){ee.default.fromBackend("Failed to update permissions"),console.error("Error updating permissions:",e)}finally{u(!1)}};if(d)return(0,t.jsx)("div",{className:"p-6 text-center",children:"Loading permissions..."});let _=s.length>0;return(0,t.jsxs)(S.Card,{className:"bg-white shadow-md rounded-md p-6",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center border-b pb-4 mb-6",children:[(0,t.jsx)(k.Title,{className:"mb-2 sm:mb-0",children:"Member Permissions"}),a&&g&&(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)(I.Button,{icon:(0,t.jsx)(eo.ReloadOutlined,{}),onClick:()=>{p()},children:"Reset"}),(0,t.jsx)(I.Button,{onClick:x,loading:c,type:"primary",icon:(0,t.jsx)(b.SaveOutlined,{}),children:"Save Changes"})]})]}),(0,t.jsx)(N.Text,{className:"mb-6 text-gray-600",children:"Control what team members can do when they are not team admins."}),_?(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(ed.Table,{className:" min-w-full",children:[(0,t.jsx)(eu.TableHead,{children:(0,t.jsxs)(eh.TableRow,{children:[(0,t.jsx)(eg.TableHeaderCell,{children:"Method"}),(0,t.jsx)(eg.TableHeaderCell,{children:"Endpoint"}),(0,t.jsx)(eg.TableHeaderCell,{children:"Description"}),(0,t.jsx)(eg.TableHeaderCell,{className:"sticky right-0 bg-white shadow-[-4px_0_4px_-4px_rgba(0,0,0,0.1)] text-center",children:"Allow Access"})]})}),(0,t.jsx)(em.TableBody,{children:s.map(e=>{let l=(e=>{let t=e.includes("/info")||e.includes("/list")||e.includes("/activity")||"/spend/logs"===e?"GET":"POST",l=e_[e];if(!l){for(let[t,a]of Object.entries(e_))if(e.includes(t)){l=a;break}}return l||(l=`Access ${e}`),{method:t,endpoint:e,description:l,route:e}})(e);return(0,t.jsxs)(eh.TableRow,{className:"hover:bg-gray-50 transition-colors",children:[(0,t.jsx)(ec.TableCell,{children:(0,t.jsx)("span",{className:`px-2 py-1 rounded text-xs font-medium ${"GET"===l.method?"bg-blue-100 text-blue-800":"bg-green-100 text-green-800"}`,children:l.method})}),(0,t.jsx)(ec.TableCell,{children:(0,t.jsx)("span",{className:"font-mono text-sm text-gray-800",children:l.endpoint})}),(0,t.jsx)(ec.TableCell,{className:"text-gray-700",children:l.description}),(0,t.jsx)(ec.TableCell,{className:"sticky right-0 bg-white shadow-[-4px_0_4px_-4px_rgba(0,0,0,0.1)] text-center",children:(0,t.jsx)(ep.Checkbox,{checked:n.includes(e),onChange:t=>{o(t.target.checked?[...n,e]:n.filter(t=>t!==e)),h(!0)},disabled:!a})})]},e)})})]})}):(0,t.jsx)("div",{className:"py-12",children:(0,t.jsx)(ex.Empty,{description:"No permissions available"})})]})};var ey=e.i(822315);function ej(e){if(!e)return null;let t=(0,ey.default)(e);return t.isValid()?t.format("MMM D, YYYY"):null}var ef=e.i(175712),ev=e.i(178654),eT=e.i(621192),eS=e.i(898586);let ew=async(e,t)=>{let l=(0,r.getProxyBaseUrl)(),a=l?`${l}/team/${encodeURIComponent(t)}/members/me`:`/team/${encodeURIComponent(t)}/members/me`,s=await fetch(a,{method:"GET",headers:{[(0,r.getGlobalLitellmHeaderName)()]:`Bearer ${e}`,"Content-Type":"application/json"}});if(404===s.status)return null;if(!s.ok){let e=await s.json().catch(()=>({}));throw Error((0,r.deriveErrorMessage)(e))}return await s.json()},eN=(e,l)=>(0,t.jsxs)(O.Space,{size:4,children:[(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:e}),(0,t.jsx)(R.Tooltip,{title:l,children:(0,t.jsx)(p.InfoCircleOutlined,{style:{color:"#8c8c8c"}})})]}),eC=(e,t=4)=>null==e?"0":(0,m.formatNumberWithCommas)(e,t),ek=e=>null==e?"Unlimited":(0,m.formatNumberWithCommas)(e,0);function eI({teamId:e}){let{data:a,isLoading:s,error:i}=(e=>{let{accessToken:t}=(0,l.default)();return(0,n.useQuery)({queryKey:["team",e,"members","me"],queryFn:()=>ew(t,e),enabled:!!(t&&e)})})(e);if(s)return(0,t.jsx)(ef.Card,{children:(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"Loading your membership info…"})});if(i)return(0,t.jsx)(ef.Card,{children:(0,t.jsx)(eS.Typography.Text,{type:"danger",children:i instanceof Error?i.message:"Failed to load your membership info for this team."})});if(!a)return(0,t.jsx)(ef.Card,{children:(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"No membership info available for the current user in this team."})});let r=a.litellm_budget_table??null,o=r?.max_budget??null,d=a.spend??0,m=a.total_spend??0,c=r?.tpm_limit??null,u=r?.rpm_limit??null,g=ej(r?.budget_reset_at),h=r?.allowed_models??null;return(0,t.jsxs)(O.Space,{direction:"vertical",size:"middle",style:{width:"100%"},children:[(0,t.jsx)(ef.Card,{children:(0,t.jsxs)(eT.Row,{gutter:[24,16],children:[(0,t.jsxs)(ev.Col,{xs:24,sm:12,md:8,children:[(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"User"}),(0,t.jsx)("div",{style:{marginTop:4},children:(0,t.jsx)(eS.Typography.Text,{strong:!0,children:a.user_email||a.user_id})}),(0,t.jsx)(eS.Typography.Text,{type:"secondary",style:{fontSize:12,fontFamily:"monospace"},children:a.user_id})]}),(0,t.jsxs)(ev.Col,{xs:24,sm:12,md:8,children:[(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"Team Role"}),(0,t.jsx)("div",{style:{marginTop:4},children:(0,t.jsx)(L.Tag,{color:"admin"===a.role?"blue":"default",children:a.role||"user"})})]})]})}),(0,t.jsxs)(eT.Row,{gutter:[16,16],children:[(0,t.jsx)(ev.Col,{xs:24,md:12,children:(0,t.jsxs)(ef.Card,{children:[eN("Current Cycle Spend (USD)","Spend for the current budget cycle. Resets to $0 when the budget window rolls over."),(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsxs)(eS.Typography.Title,{level:3,style:{margin:0},children:["$",eC(d,4)]}),(0,t.jsxs)(eS.Typography.Text,{type:"secondary",children:["of ",null===o?"Unlimited":`$${eC(o,4)}`]})]}),g&&(0,t.jsx)("div",{style:{marginTop:4},children:(0,t.jsxs)(eS.Typography.Text,{type:"secondary",children:["Resets ",g]})})]})}),(0,t.jsx)(ev.Col,{xs:24,md:12,children:(0,t.jsxs)(ef.Card,{children:[eN("Rate Limits","Your per-member rate limits within this team."),(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsxs)(eS.Typography.Text,{children:["TPM: ",ek(c)]}),(0,t.jsx)("br",{}),(0,t.jsxs)(eS.Typography.Text,{children:["RPM: ",ek(u)]})]})]})}),(0,t.jsx)(ev.Col,{xs:24,md:12,children:(0,t.jsxs)(ef.Card,{children:[eN("Total Spend (USD)","Cumulative spend across all budget cycles within this team."),(0,t.jsx)("div",{style:{marginTop:8},children:(0,t.jsxs)(eS.Typography.Title,{level:4,style:{margin:0},children:["$",eC(m,4)]})})]})}),(0,t.jsx)(ev.Col,{xs:24,md:12,children:(0,t.jsxs)(ef.Card,{children:[eN("Model Scope","Models you can access within this team."),(0,t.jsx)("div",{style:{marginTop:8},children:h&&h.length>0?(0,t.jsx)(O.Space,{wrap:!0,children:h.map(e=>(0,t.jsx)(L.Tag,{children:e},e))}):(0,t.jsx)(eS.Typography.Text,{children:"All Team Models"})})]})})]})]})}let eM="overview",ez="my-user",eA="virtual-keys",eF="members",eO="member-permissions",eP="settings",eD={[eM]:"Overview",[ez]:"My User",[eA]:"Virtual Keys",[eF]:"Members",[eO]:"Member Permissions",[eP]:"Settings"};var eL=e.i(292639),eR=e.i(294612);function eB({teamData:e,canEditTeam:a,handleMemberDelete:s,setSelectedEditMember:i,setIsEditMemberModalVisible:r,setIsAddMemberModalVisible:n}){let o=e=>{if(null==e)return"0";if("number"==typeof e){let t=Number(e);return t===Math.floor(t)?t.toString():(0,m.formatNumberWithCommas)(t,8).replace(/\.?0+$/,"")}return"0"},{data:d}=(0,eL.useUISettings)(),{userId:c,userRole:g}=(0,l.default)(),h=!!d?.values?.disable_team_admin_delete_team_user,x=(0,u.isUserTeamAdminForSingleTeam)(e.team_info.members_with_roles,c||""),_=(0,u.isProxyAdminRole)(g||""),b=[{title:(0,t.jsxs)(O.Space,{direction:"horizontal",children:["Model Scope",(0,t.jsx)(R.Tooltip,{title:"Models this member can access. Empty means they inherit all team models.",children:(0,t.jsx)(p.InfoCircleOutlined,{})})]}),key:"model_scope",render:(l,a)=>{let s=(t=>{if(!t)return null;let l=e.team_memberships.find(e=>e.user_id===t),a=l?.litellm_budget_table?.allowed_models;return a&&a.length>0?a:null})(a.user_id);if(!s)return(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"(all team models)"});let i=s.slice(0,2),r=s.length-i.length;return(0,t.jsxs)(O.Space,{wrap:!0,children:[i.map(e=>(0,t.jsx)(eS.Typography.Text,{code:!0,style:{fontSize:"12px"},children:e},e)),r>0&&(0,t.jsx)(R.Tooltip,{title:s.slice(2).join(", "),children:(0,t.jsxs)(eS.Typography.Text,{type:"secondary",children:["+",r," more"]})})]})}},{title:(0,t.jsxs)(O.Space,{direction:"horizontal",children:["Current Cycle Spend (USD)",(0,t.jsx)(R.Tooltip,{title:"Spend for the current budget cycle. Resets to $0 when the member's budget window rolls over. This is the value checked against the member's budget.",children:(0,t.jsx)(p.InfoCircleOutlined,{})})]}),key:"spend",render:(l,a)=>(0,t.jsxs)(eS.Typography.Text,{children:["$",(0,m.formatNumberWithCommas)((t=>{if(!t)return 0;let l=e.team_memberships.find(e=>e.user_id===t);return l?.spend??0})(a.user_id),4)]})},{title:(0,t.jsxs)(O.Space,{direction:"horizontal",children:["Total Spend (USD)",(0,t.jsx)(R.Tooltip,{title:"Cumulative spend by this member within this team, across all budget cycles. Tracking began 2026-04-21; spend from before that date is not included.",children:(0,t.jsx)(p.InfoCircleOutlined,{})})]}),key:"total_spend",render:(l,a)=>(0,t.jsxs)(eS.Typography.Text,{children:["$",(0,m.formatNumberWithCommas)((t=>{if(!t)return 0;let l=e.team_memberships.find(e=>e.user_id===t);return l?.total_spend??0})(a.user_id),4)]})},{title:"Team Member Budget (USD)",key:"budget",render:(l,a)=>{let s=(t=>{if(!t)return null;let l=e.team_memberships.find(e=>e.user_id===t),a=l?.litellm_budget_table?.max_budget;return null==a?null:o(a)})(a.user_id);return(0,t.jsx)(eS.Typography.Text,{children:s?`$${(0,m.formatNumberWithCommas)(Number(s),4)}`:"No Limit"})}},{title:"Budget Reset",key:"budget_reset",render:(l,a)=>{let s=(t=>{if(!t)return null;let l=e.team_memberships.find(e=>e.user_id===t);return ej(l?.litellm_budget_table?.budget_reset_at)})(a.user_id);return s?(0,t.jsx)(eS.Typography.Text,{children:s}):(0,t.jsx)(eS.Typography.Text,{type:"secondary",children:"—"})}},{title:(0,t.jsxs)(O.Space,{direction:"horizontal",children:["Team Member Rate Limits",(0,t.jsx)(R.Tooltip,{title:"Rate limits for this member's usage within this team.",children:(0,t.jsx)(p.InfoCircleOutlined,{})})]}),key:"rate_limits",render:(l,a)=>(0,t.jsx)(eS.Typography.Text,{children:(t=>{if(!t)return"No Limits";let l=e.team_memberships.find(e=>e.user_id===t),a=l?.litellm_budget_table?.rpm_limit,s=l?.litellm_budget_table?.tpm_limit,i=[a?`${o(a)} RPM`:null,s?`${o(s)} TPM`:null].filter(Boolean);return i.length>0?i.join(" / "):"No Limits"})(a.user_id)})}];return(0,t.jsx)(eR.default,{members:e.team_info.members_with_roles,canEdit:a,onEdit:t=>{let l=e.team_memberships.find(e=>e.user_id===t.user_id);i({...t,max_budget_in_team:l?.litellm_budget_table?.max_budget||null,tpm_limit:l?.litellm_budget_table?.tpm_limit||null,rpm_limit:l?.litellm_budget_table?.rpm_limit||null,allowed_models:l?.litellm_budget_table?.allowed_models||[]}),r(!0)},onDelete:s,onAddMember:()=>n(!0),roleColumnTitle:"Team Role",roleTooltip:"This role applies only to this team and is independent from the user's proxy-level role.",extraColumns:b,showDeleteForMember:()=>_||a&&!x||x&&!h})}var eV=e.i(207082),eU=e.i(871943),eE=e.i(502547),e$=e.i(360820),eK=e.i(94629),eG=e.i(152990),eW=e.i(682830),eq=e.i(994388),eH=e.i(752978),eJ=e.i(282786),eQ=e.i(981339),eY=e.i(969550),eX=e.i(20147),eZ=e.i(633627);function e0({teamId:e,teamAlias:a,organization:s}){let{accessToken:i}=(0,l.default)(),[r,o]=(0,E.useState)(null),[d,c]=(0,E.useState)([{id:"created_at",desc:!0}]),[u,g]=(0,E.useState)({pageIndex:0,pageSize:50}),[h,x]=(0,E.useState)({"Organization ID":"","Key Alias":"","User ID":"","Sort By":"created_at","Sort Order":"desc"}),_=d.length>0?d[0].id:"created_at",b=d.length>0?d[0].desc?"desc":"asc":"desc",y=u.pageIndex,j=u.pageSize,{data:f,isPending:v,isFetching:S,refetch:w}=(0,eV.useKeys)(y+1,j,{teamID:e,organizationID:h["Organization ID"]?.trim()||void 0,selectedKeyAlias:h["Key Alias"]?.trim()||void 0,userID:h["User ID"]?.trim()||void 0,sortBy:_||void 0,sortOrder:b||void 0,expand:"user"}),C=(0,E.useMemo)(()=>{let e=f?.keys||[],t=s?.organization_id;return t?e.map(e=>({...e,organization_id:(e.organization_id??e.org_id)||t})):e},[f?.keys,s?.organization_id]),k=f?.total_pages??0,[I,M]=(0,E.useState)({}),z=(0,E.useMemo)(()=>({team_id:e,team_alias:a||e,models:[],max_budget:null,budget_duration:null,tpm_limit:null,rpm_limit:null,organization_id:s?.organization_id||"",created_at:"",keys:[],members_with_roles:[],spend:0}),[e,a,s]),A=(0,n.useQuery)({queryKey:["teamFilterOptions",e,i],queryFn:async()=>(0,eZ.fetchTeamFilterOptions)(i,e),enabled:!!i&&!!e,staleTime:3e4}).data||{keyAliases:[],organizationIds:[],userIds:[]},F=(0,E.useCallback)(()=>{w?.()},[w]);(0,E.useEffect)(()=>(window.addEventListener("storage",F),()=>window.removeEventListener("storage",F)),[F]);let O=(0,E.useCallback)((e,t=!1)=>{x(t=>({...t,"Organization ID":e["Organization ID"]??t["Organization ID"],"Key Alias":e["Key Alias"]??t["Key Alias"],"User ID":e["User ID"]??t["User ID"],"Sort By":e["Sort By"]??t["Sort By"]??"created_at","Sort Order":e["Sort Order"]??t["Sort Order"]??"desc"})),t||g(e=>({...e,pageIndex:0}))},[]),P=(0,E.useCallback)(()=>{x({"Organization ID":"","Key Alias":"","User ID":"","Sort By":"created_at","Sort Order":"desc"}),g(e=>({...e,pageIndex:0}))},[]),D=(0,E.useMemo)(()=>[{name:"Organization ID",label:"Organization ID",isSearchable:!0,searchFn:async e=>{let{organizationIds:t}=A;if(!t.length)return[];let l=e.toLowerCase();return(l?t.filter(e=>e.toLowerCase().includes(l)):t).map(e=>({label:e,value:e}))}},{name:"Key Alias",label:"Key Alias",isSearchable:!0,searchFn:async e=>{let{keyAliases:t}=A,l=e.toLowerCase();return(l?t.filter(e=>e.toLowerCase().includes(l)):t).map(e=>({label:e,value:e}))}},{name:"User ID",label:"User ID",isSearchable:!0,searchFn:async e=>{let{userIds:t}=A,l=e.toLowerCase();return(l?t.filter(e=>e.id.toLowerCase().includes(l)||e.email.toLowerCase().includes(l)):t).map(e=>({label:e.email?`${e.id} (${e.email})`:e.id,value:e.id}))}}],[A]),L=(0,E.useMemo)(()=>[{id:"token",accessorKey:"token",header:"Key ID",size:100,enableSorting:!0,cell:e=>{let l=e.getValue(),a=e.cell.column.getSize();return(0,t.jsx)(R.Tooltip,{title:l,children:(0,t.jsx)(eq.Button,{size:"xs",variant:"light",className:"font-mono text-blue-500 bg-blue-50 hover:bg-blue-100 text-xs font-normal px-2 py-0.5 text-left overflow-hidden truncate block",style:{maxWidth:a,overflow:"hidden"},onClick:()=>o(e.row.original),children:l??"-"})})}},{id:"key_alias",accessorKey:"key_alias",header:"Key Alias",size:150,enableSorting:!0,cell:e=>{let l=e.getValue(),a=e.cell.column.getSize();return(0,t.jsx)(R.Tooltip,{title:l,children:(0,t.jsx)("span",{className:"font-mono text-xs truncate block",style:{maxWidth:a,overflow:"hidden"},children:l??"-"})})}},{id:"key_name",accessorKey:"key_name",header:"Secret Key",size:120,enableSorting:!1,cell:e=>(0,t.jsx)("span",{className:"font-mono text-xs",children:e.getValue()})},{id:"organization_id",accessorKey:"organization_id",header:"Organization ID",size:140,enableSorting:!1,cell:e=>e.getValue()?e.renderValue():"-"},{id:"user_email",accessorKey:"user",header:"User Email",size:160,enableSorting:!1,cell:e=>{let l=e.getValue(),a=l?.user_email,s=e.cell.column.getSize();return(0,t.jsx)(R.Tooltip,{title:a,children:(0,t.jsx)("span",{className:"font-mono text-xs truncate block",style:{maxWidth:s,overflow:"hidden"},children:a??"-"})})}},{id:"user_id",accessorKey:"user_id",header:"User ID",size:70,enableSorting:!1,cell:e=>{let l=e.getValue(),a="default_user_id"===l?"Default Proxy Admin":l,s=e.cell.column.getSize();return(0,t.jsx)(R.Tooltip,{title:a,children:(0,t.jsx)("span",{className:"font-mono text-xs truncate block",style:{maxWidth:s,overflow:"hidden"},children:a??"-"})})}},{id:"created_at",accessorKey:"created_at",header:"Created At",size:120,enableSorting:!0,cell:e=>{let t=e.getValue();return t?new Date(t).toLocaleDateString():"-"}},{id:"created_by",accessorKey:"created_by",header:"Created By",size:70,enableSorting:!1,cell:e=>{let l=e.getValue(),a="default_user_id"===l?"Default Proxy Admin":l,s=e.cell.column.getSize();return(0,t.jsx)(R.Tooltip,{title:a,children:(0,t.jsx)("span",{className:"font-mono text-xs truncate block",style:{maxWidth:s,overflow:"hidden"},children:a??"-"})})}},{id:"updated_at",accessorKey:"updated_at",header:"Updated At",size:120,enableSorting:!0,cell:e=>{let t=e.getValue();return t?new Date(t).toLocaleDateString():"Never"}},{id:"last_active",accessorKey:"last_active",header:()=>(0,t.jsxs)("span",{className:"flex items-center gap-1",children:["Last Active",(0,t.jsx)(eJ.Popover,{content:"This is a new field and is not backfilled. Only new key usage will update this value.",trigger:"hover",children:(0,t.jsx)(p.InfoCircleOutlined,{className:"text-gray-400 text-xs cursor-help"})})]}),size:130,enableSorting:!1,cell:e=>{let l=e.getValue();if(!l)return"Unknown";let a=new Date(l);return(0,t.jsx)(R.Tooltip,{title:a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"long"}),children:(0,t.jsx)("span",{children:a.toLocaleDateString()})})}},{id:"expires",accessorKey:"expires",header:"Expires",size:120,enableSorting:!1,cell:e=>{let t=e.getValue();return t?new Date(t).toLocaleDateString():"Never"}},{id:"spend",accessorKey:"spend",header:"Spend (USD)",size:100,enableSorting:!0,cell:e=>(0,m.formatNumberWithCommas)(e.getValue(),4)},{id:"max_budget",accessorKey:"max_budget",header:"Budget (USD)",size:110,enableSorting:!0,cell:e=>{let t=e.getValue();return null===t?"Unlimited":`$${(0,m.formatNumberWithCommas)(t)}`}},{id:"budget_reset_at",accessorKey:"budget_reset_at",header:"Budget Reset",size:130,enableSorting:!1,cell:e=>{let t=e.getValue();return t?new Date(t).toLocaleString():"Never"}},{id:"models",accessorKey:"models",header:"Models",size:200,enableSorting:!1,cell:e=>{let l=e.getValue();return(0,t.jsx)("div",{className:"flex flex-col py-2",children:Array.isArray(l)?(0,t.jsx)("div",{className:"flex flex-col",children:0===l.length?(0,t.jsx)(T.Badge,{size:"xs",className:"mb-1",color:"red",children:(0,t.jsx)(N.Text,{children:"All Proxy Models"})}):(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex items-start",children:[l.length>3&&(0,t.jsx)("div",{children:(0,t.jsx)(eH.Icon,{icon:I[e.row.id]?eU.ChevronDownIcon:eE.ChevronRightIcon,className:"cursor-pointer",size:"xs",onClick:()=>M(t=>({...t,[e.row.id]:!t[e.row.id]}))})}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",children:[l.slice(0,3).map((e,l)=>"all-proxy-models"===e?(0,t.jsx)(T.Badge,{size:"xs",color:"red",children:(0,t.jsx)(N.Text,{children:"All Proxy Models"})},l):(0,t.jsx)(T.Badge,{size:"xs",color:"blue",children:(0,t.jsx)(N.Text,{children:e.length>30?`${(0,H.getModelDisplayName)(e).slice(0,30)}...`:(0,H.getModelDisplayName)(e)})},l)),l.length>3&&!I[e.row.id]&&(0,t.jsx)(T.Badge,{size:"xs",color:"gray",className:"cursor-pointer",children:(0,t.jsxs)(N.Text,{children:["+",l.length-3," ",l.length-3==1?"more model":"more models"]})}),I[e.row.id]&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:l.slice(3).map((e,l)=>"all-proxy-models"===e?(0,t.jsx)(T.Badge,{size:"xs",color:"red",children:(0,t.jsx)(N.Text,{children:"All Proxy Models"})},l+3):(0,t.jsx)(T.Badge,{size:"xs",color:"blue",children:(0,t.jsx)(N.Text,{children:e.length>30?`${(0,H.getModelDisplayName)(e).slice(0,30)}...`:(0,H.getModelDisplayName)(e)})},l+3))})]})]})})}):null})}},{id:"rate_limits",header:"Rate Limits",size:140,enableSorting:!1,cell:({row:e})=>{let l=e.original;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{children:["TPM: ",null!==l.tpm_limit?l.tpm_limit:"Unlimited"]}),(0,t.jsxs)("div",{children:["RPM: ",null!==l.rpm_limit?l.rpm_limit:"Unlimited"]})]})}}],[I]),B=(0,E.useCallback)(e=>{let t="function"==typeof e?e(d):e;if(c(t),t?.length>0){let e=t[0];O({"Sort By":e.id,"Sort Order":e.desc?"desc":"asc"},!0)}},[d,O]),V=(0,eG.useReactTable)({data:C,columns:L,columnResizeMode:"onChange",columnResizeDirection:"ltr",state:{sorting:d,pagination:u},onSortingChange:B,onPaginationChange:g,getCoreRowModel:(0,eW.getCoreRowModel)(),enableSorting:!0,manualSorting:!0,manualPagination:!0,pageCount:k});return(0,t.jsx)("div",{className:"w-full h-full overflow-hidden",children:r?(0,t.jsx)(eX.default,{keyId:r.token,onClose:()=>o(null),keyData:r,teams:[z],onDelete:w}):(0,t.jsxs)("div",{className:"border-b py-4 flex-1 overflow-hidden",children:[(0,t.jsx)("div",{className:"w-full mb-6",children:(0,t.jsx)(eY.default,{options:D,onApplyFilters:O,initialValues:h,onResetFilters:P})}),(0,t.jsx)("div",{className:"flex items-center justify-end w-full mb-4",children:(0,t.jsxs)("div",{className:"inline-flex items-center gap-2",children:[v||S?(0,t.jsx)(eQ.Skeleton.Node,{active:!0,style:{width:74,height:20}}):(0,t.jsxs)("span",{className:"text-sm text-gray-700",children:["Page ",y+1," of ",V.getPageCount()]}),v||S?(0,t.jsx)(eQ.Skeleton.Button,{active:!0,size:"small",style:{width:84,height:30}}):(0,t.jsx)("button",{onClick:()=>V.previousPage(),disabled:v||S||!V.getCanPreviousPage(),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),v||S?(0,t.jsx)(eQ.Skeleton.Button,{active:!0,size:"small",style:{width:58,height:30}}):(0,t.jsx)("button",{onClick:()=>V.nextPage(),disabled:v||S||!V.getCanNextPage(),className:"px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})}),(0,t.jsx)("div",{className:"h-[75vh] overflow-auto",children:(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)(ed.Table,{className:"[&_td]:py-0.5 [&_th]:py-1",style:{width:V.getCenterTotalSize()},children:[(0,t.jsx)(eu.TableHead,{children:V.getHeaderGroups().map(e=>(0,t.jsx)(eh.TableRow,{children:e.headers.map(e=>(0,t.jsx)(eg.TableHeaderCell,{"data-header-id":e.id,className:`py-1 h-8 relative hover:bg-gray-50 ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]":""}`,style:{width:e.getSize(),position:"relative",cursor:e.column.getCanSort()?"pointer":"default"},onMouseEnter:()=>{let t=document.querySelector(`[data-header-id="${e.id}"] .resizer`);t&&(t.style.opacity="0.5")},onMouseLeave:()=>{let t=document.querySelector(`[data-header-id="${e.id}"] .resizer`);t&&!e.column.getIsResizing()&&(t.style.opacity="0")},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,eG.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&(0,t.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,t.jsx)(e$.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,t.jsx)(eU.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,t.jsx)(eK.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})}),(0,t.jsx)("div",{onDoubleClick:()=>e.column.resetSize(),onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:`resizer ${V.options.columnResizeDirection} ${e.column.getIsResizing()?"isResizing":""}`,style:{position:"absolute",right:0,top:0,height:"100%",width:"5px",background:e.column.getIsResizing()?"#3b82f6":"transparent",cursor:"col-resize",userSelect:"none",touchAction:"none",opacity:+!!e.column.getIsResizing()}})]})},e.id))},e.id))}),(0,t.jsx)(em.TableBody,{children:v||S?(0,t.jsx)(eh.TableRow,{children:(0,t.jsx)(ec.TableCell,{colSpan:L.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"Loading keys..."})})})}):C.length>0?V.getRowModel().rows.map(e=>(0,t.jsx)(eh.TableRow,{className:"h-8",children:e.getVisibleCells().map(e=>(0,t.jsx)(ec.TableCell,{style:{width:e.column.getSize(),maxWidth:"8-x",whiteSpace:"pre-wrap",overflow:"hidden"},className:`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${"models"===e.column.id&&Array.isArray(e.getValue())&&e.getValue().length>3?"px-0":""}`,children:(0,eG.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,t.jsx)(eh.TableRow,{children:(0,t.jsx)(ec.TableCell,{colSpan:L.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"No keys found"})})})})})]})})})})]})})}e.s(["default",0,({teamId:e,onClose:n,accessToken:o,is_team_admin:eo,is_proxy_admin:ed,is_org_admin:em=!1,userModels:ec,editTeam:eu,premiumUser:eg=!1,onUpdate:eh})=>{let ep,ex,e_,ey,ej,ef,[ev,eT]=(0,E.useState)(null),[eS,ew]=(0,E.useState)(!0),[eN,eC]=(0,E.useState)(!1),[ek]=M.Form.useForm(),[eL,eR]=(0,E.useState)(!1),[eV,eU]=(0,E.useState)(null),[eE,e$]=(0,E.useState)(!1),[eK,eG]=(0,E.useState)([]),[eW,eq]=(0,E.useState)(!1),[eH,eJ]=(0,E.useState)({}),{data:eQ,isLoading:eY}=d(),eX=eQ?.globalGuardrailNames??new Set,[eZ,e1]=(0,E.useState)([]),[e4,e2]=(0,E.useState)({}),[e5,e3]=(0,E.useState)(!1),[e6,e8]=(0,E.useState)(null),[e7,e9]=(0,E.useState)(!1),[te,tt]=(0,E.useState)(!1),[tl,ta]=(0,E.useState)(!1),ts=E.default.useRef(null),[ti,tr]=(0,E.useState)(null),{userRole:tn,userId:to}=(0,l.default)(),{data:td=[]}=(0,a.useOrganizations)(),tm=(0,s.useQueryClient)(),tc=(0,E.useMemo)(()=>{let e=ev?.team_info?.organization_id;if(!e||!to)return!1;let t=td.find(t=>t.organization_id===e);return t?.members?.some(e=>e.user_id===to&&"org_admin"===e.user_role)??!1},[ev,td,to]),tu=M.Form.useWatch("models",ek),tg=M.Form.useWatch("disable_global_guardrails",ek),th=(0,E.useMemo)(()=>{let e=tu??ev?.team_info?.models??[];return e.includes("all-proxy-models")||e.includes("all-team-models")?ec:(0,H.unfurlWildcardModelsInList)(e,ec)},[tu,ev,ec]),tp=eo||ed||em||tc,tx=(0,E.useMemo)(()=>{let e;return e=[eM,ez,eA],tp?[...e,eF,eO,eP]:e},[tp]),t_=(0,E.useMemo)(()=>eu&&tp?eP:eM,[eu,tp]),tb=async()=>{try{if(ew(!0),!o)return;let t=await (0,r.teamInfoCall)(o,e);eT(t)}catch(e){ee.default.fromBackend("Failed to load team information"),console.error("Error fetching team info:",e)}finally{ew(!1)}};(0,E.useEffect)(()=>{tb()},[e,o]),(0,E.useEffect)(()=>{(async()=>{if(!o||!ev?.team_info?.organization_id)return tr(null);try{let e=await (0,r.organizationInfoCall)(o,ev.team_info.organization_id);tr(e)}catch(e){console.error("Error fetching organization info:",e),tr(null)}})()},[o,ev?.team_info?.organization_id]),(0,E.useMemo)(()=>{let e;return e=[],e=ti?ti.models.includes("all-proxy-models")?ec:ti.models.length>0?ti.models:ec:ec,(0,H.unfurlWildcardModelsInList)(e,ec)},[ti,ec]),(0,E.useEffect)(()=>{(async()=>{try{if(!o)return;let e=(await (0,r.getPoliciesList)(o)).policies.map(e=>e.policy_name);e1(e)}catch(e){console.error("Failed to fetch policies:",e)}})()},[o]),(0,E.useEffect)(()=>{(async()=>{if(!o||!ev?.team_info?.policies||0===ev.team_info.policies.length)return;e3(!0);let e={};try{await Promise.all(ev.team_info.policies.map(async t=>{try{let l=await (0,r.getPolicyInfoWithGuardrails)(o,t);e[t]=l.resolved_guardrails||[]}catch(l){console.error(`Failed to fetch guardrails for policy ${t}:`,l),e[t]=[]}})),e2(e)}catch(e){console.error("Failed to fetch policy guardrails:",e)}finally{e3(!1)}})()},[o,ev?.team_info?.policies]);let ty=async t=>{try{if(null==o)return;let l={user_email:t.user_email,user_id:t.user_id,role:t.role};await (0,r.teamMemberAddCall)(o,e,l),ee.default.success("Team member added successfully"),eC(!1),ek.resetFields();let a=await (0,r.teamInfoCall)(o,e);eT(a),eh(a)}catch(t){let e="Failed to add team member";t?.raw?.detail?.error?.includes("Assigning team admins is a premium feature")?e="Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.":t?.message&&(e=t.message),ee.default.fromBackend(e),console.error("Error adding team member:",t)}},tj=async t=>{try{if(null==o)return;let l={user_email:t.user_email,user_id:t.user_id,role:t.role,max_budget_in_team:t.max_budget_in_team,tpm_limit:t.tpm_limit,rpm_limit:t.rpm_limit,allowed_models:t.allowed_models};B.default.destroy(),await (0,r.teamMemberUpdateCall)(o,e,l),ee.default.success("Team member updated successfully"),eR(!1);let a=await (0,r.teamInfoCall)(o,e);eT(a),eh(a)}catch(t){let e="Failed to update team member";t?.raw?.detail?.includes("Assigning team admins is a premium feature")?e="Assigning admins is an enterprise-only feature. Please upgrade your LiteLLM plan to enable this.":t?.message&&(e=t.message),eR(!1),B.default.destroy(),ee.default.fromBackend(e),console.error("Error updating team member:",t)}},tf=async()=>{if(e6&&o){tt(!0);try{await (0,r.teamMemberDeleteCall)(o,e,e6),ee.default.success("Team member removed successfully");let t=await (0,r.teamInfoCall)(o,e);eT(t),eh(t)}catch(e){ee.default.fromBackend("Failed to remove team member"),console.error("Error removing team member:",e)}finally{tt(!1),e9(!1),e8(null)}}},tv=async t=>{try{let l;if(!o)return;ta(!0);let s={};try{let{soft_budget_alerting_emails:e,...l}=t.metadata?JSON.parse(t.metadata):{};s=l}catch(e){ee.default.fromBackend("Invalid JSON in metadata field");return}if("string"==typeof t.secret_manager_settings&&t.secret_manager_settings.trim().length>0)try{l=JSON.parse(t.secret_manager_settings)}catch(e){ee.default.fromBackend("Invalid JSON in secret manager settings");return}let i=e=>null==e||"string"==typeof e&&""===e.trim()||"number"==typeof e&&Number.isNaN(e)?null:e,n={},d={};for(let e of t.modelLimits??[])e?.model&&(null!=e.tpm&&(n[e.model]=e.tpm),null!=e.rpm&&(d[e.model]=e.rpm));let m=!0===t.disable_global_guardrails,u=m?Array.from(eX):Array.from(eX).filter(e=>!(t.guardrails||[]).includes(e)),g={team_id:e,team_alias:t.team_alias,models:t.models,tpm_limit:i(t.tpm_limit),rpm_limit:i(t.rpm_limit),model_tpm_limit:n,model_rpm_limit:d,max_budget:t.max_budget,soft_budget:i(t.soft_budget),budget_duration:t.budget_duration,metadata:{...s,guardrails:(t.guardrails||[]).filter(e=>!eX.has(e)),opted_out_global_guardrails:u,...t.logging_settings?.length>0?{logging:t.logging_settings}:{},disable_global_guardrails:m,soft_budget_alerting_emails:"string"==typeof t.soft_budget_alerting_emails?t.soft_budget_alerting_emails.split(",").map(e=>e.trim()).filter(e=>e.length>0):t.soft_budget_alerting_emails||[],...void 0!==l?{secret_manager_settings:l}:{}},...t.policies?.length>0?{policies:t.policies}:{},...t.organization_id!==tT.organization_id?{organization_id:t.organization_id??null}:{}};g.max_budget=(0,c.mapEmptyStringToNull)(g.max_budget),g.team_member_budget_duration=t.team_member_budget_duration,void 0!==t.team_member_budget&&(g.team_member_budget=Number(t.team_member_budget)),void 0!==t.team_member_key_duration&&(g.team_member_key_duration=t.team_member_key_duration),(void 0!==t.team_member_tpm_limit||void 0!==t.team_member_rpm_limit)&&(g.team_member_tpm_limit=i(t.team_member_tpm_limit),g.team_member_rpm_limit=i(t.team_member_rpm_limit));let{servers:h,accessGroups:p,toolsets:x}=t.mcp_servers_and_groups||{servers:[],accessGroups:[],toolsets:[]},_=new Set(h||[]),b=Object.fromEntries(Object.entries(t.mcp_tool_permissions||{}).filter(([e])=>_.has(e)));g.object_permission={},h&&(g.object_permission.mcp_servers=h),p&&(g.object_permission.mcp_access_groups=p),b&&(g.object_permission.mcp_tool_permissions=b),x&&(g.object_permission.mcp_toolsets=x),delete t.mcp_servers_and_groups,delete t.mcp_tool_permissions;let{agents:y,accessGroups:j}=t.agents_and_groups||{agents:[],accessGroups:[]};y&&y.length>0&&(g.object_permission.agents=y),j&&j.length>0&&(g.object_permission.agent_access_groups=j),delete t.agents_and_groups,t.vector_stores&&t.vector_stores.length>0&&(g.object_permission.vector_stores=t.vector_stores),Array.isArray(t.object_permission_search_tools)&&(g.object_permission.search_tools=t.object_permission_search_tools),void 0!==t.access_group_ids&&(g.access_group_ids=t.access_group_ids),void 0!==t.default_team_member_models&&(g.default_team_member_models=t.default_team_member_models);let f=ts.current?.getValue();if(f?.router_settings){let e=e=>null!=e&&""!==e&&!1!==e&&!(Array.isArray(e)&&0===e.length),t=Object.values(f.router_settings).some(e),l=tT.router_settings&&Object.values(tT.router_settings).some(e);(t||l)&&(g.router_settings=f.router_settings)}await (0,r.teamUpdateCall)(o,g),tm.invalidateQueries({queryKey:a.organizationKeys.all}),ee.default.success("Team settings updated successfully"),e$(!1),tb()}catch(e){console.error("Error updating team:",e)}finally{ta(!1)}};if(eS)return(0,t.jsx)("div",{className:"p-4",children:"Loading..."});if(!ev?.team_info)return(0,t.jsx)("div",{className:"p-4",children:"Team not found"});let{team_info:tT}=ev,tS=tT.metadata?.disable_global_guardrails===!0,tw=new Set(Array.isArray(tT.metadata?.opted_out_global_guardrails)?tT.metadata.opted_out_global_guardrails:[]),tN=(Array.isArray(tT.metadata?.guardrails)?tT.metadata.guardrails:[]).filter(e=>!eX.has(e)),tC=tS?tN:[...Array.from(eX).filter(e=>!tw.has(e)),...tN],tk=e=>{e.preventDefault(),e.stopPropagation()},tI=async(e,t)=>{await (0,m.copyToClipboard)(e)&&(eJ(e=>({...e,[t]:!0})),setTimeout(()=>{eJ(e=>({...e,[t]:!1}))},2e3))};return(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsx)("div",{className:"flex justify-between items-center mb-6",children:(0,t.jsxs)("div",{children:[(0,t.jsx)(I.Button,{type:"text",icon:(0,t.jsx)(y.ArrowLeftIcon,{className:"h-4 w-4"}),onClick:n,className:"mb-4",children:"Back to Teams"}),(0,t.jsx)(k.Title,{children:tT.team_alias}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(N.Text,{className:"text-gray-500 font-mono",children:tT.team_id}),(0,t.jsx)(I.Button,{type:"text",size:"small",icon:eH["team-id"]?(0,t.jsx)(V.CheckIcon,{size:12}):(0,t.jsx)(U.CopyIcon,{size:12}),onClick:()=>tI(tT.team_id,"team-id"),className:`left-2 z-10 transition-all duration-200 ${eH["team-id"]?"text-green-600 bg-green-50 border-green-200":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"}`})]})]})}),(0,t.jsx)(D.Tabs,{defaultActiveKey:t_,className:"mb-4",items:[{key:eM,label:eD[eM],children:(0,t.jsxs)(w.Grid,{numItems:1,numItemsSm:2,numItemsLg:3,className:"gap-6",children:[(0,t.jsxs)(S.Card,{children:[(0,t.jsx)(N.Text,{children:"Budget Status"}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsxs)(k.Title,{children:["$",(0,m.formatNumberWithCommas)(tT.spend,4)]}),(0,t.jsxs)(N.Text,{children:["of ",null===tT.max_budget?"Unlimited":`$${(0,m.formatNumberWithCommas)(tT.max_budget,4)}`]}),tT.budget_duration&&(0,t.jsxs)(N.Text,{className:"text-gray-500",children:["Reset: ",tT.budget_duration]}),(0,t.jsx)("br",{}),tT.team_member_budget_table&&(0,t.jsxs)(N.Text,{className:"text-gray-500",children:["Team Member Budget: $",(0,m.formatNumberWithCommas)(tT.team_member_budget_table.max_budget,4)]})]})]}),(0,t.jsxs)(S.Card,{children:[(0,t.jsx)(N.Text,{children:"Rate Limits"}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsxs)(N.Text,{children:["TPM: ",tT.tpm_limit||"Unlimited"]}),(0,t.jsxs)(N.Text,{children:["RPM: ",tT.rpm_limit||"Unlimited"]}),tT.max_parallel_requests&&(0,t.jsxs)(N.Text,{children:["Max Parallel Requests: ",tT.max_parallel_requests]}),(ep=tT.metadata?.model_tpm_limit??{},ex=tT.metadata?.model_rpm_limit??{},0===(e_=Array.from(new Set([...Object.keys(ep),...Object.keys(ex)]))).length?null:(0,t.jsxs)("div",{className:"mt-3",children:[(0,t.jsx)(N.Text,{className:"text-gray-500",children:"Per-model limits:"}),e_.map(e=>(0,t.jsxs)(N.Text,{className:"text-xs",children:[e,": TPM ",ep[e]??"—",", RPM ",ex[e]??"—"]},e))]}))]})]}),(0,t.jsxs)(S.Card,{children:[(0,t.jsx)(N.Text,{children:"Models"}),(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:0===tT.models.length||tT.models.includes("all-proxy-models")?(0,t.jsx)(T.Badge,{color:"red",children:"All proxy models"}):(0,t.jsxs)(t.Fragment,{children:[tT.models.map((e,l)=>(0,t.jsx)(T.Badge,{color:"blue",children:e},`direct-${l}`)),(tT.access_group_models||[]).map((e,l)=>(0,t.jsx)(T.Badge,{color:"green",title:"From access group",children:e},`ag-${l}`))]})})]}),(0,t.jsxs)(S.Card,{children:[(0,t.jsx)(N.Text,{className:"font-semibold text-gray-900",children:"Virtual Keys"}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsxs)(N.Text,{children:["User Keys: ",ev.keys.filter(e=>e.user_id).length]}),(0,t.jsxs)(N.Text,{children:["Service Account Keys: ",ev.keys.filter(e=>!e.user_id).length]}),(0,t.jsxs)(N.Text,{className:"text-gray-500",children:["Total: ",ev.keys.length]})]})]}),(0,t.jsx)(et.default,{objectPermission:tT.object_permission,variant:"card",accessToken:o}),(0,t.jsx)(S.Card,{children:(0,t.jsx)(J,{globalGuardrailNames:eX,teamGuardrails:Array.isArray(tT.metadata?.guardrails)?tT.metadata.guardrails:[],optedOutGlobalGuardrails:Array.isArray(tT.metadata?.opted_out_global_guardrails)?tT.metadata.opted_out_global_guardrails:[],killSwitchOn:tS,variant:"inline"})}),(0,t.jsxs)(S.Card,{children:[(0,t.jsx)(N.Text,{className:"font-semibold text-gray-900 mb-3",children:"Policies"}),tT.policies&&tT.policies.length>0?(0,t.jsx)("div",{className:"space-y-4",children:tT.policies.map((e,l)=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(T.Badge,{color:"purple",children:e}),e5&&(0,t.jsx)(N.Text,{className:"text-xs text-gray-400",children:"Loading guardrails..."})]}),!e5&&e4[e]&&e4[e].length>0&&(0,t.jsxs)("div",{className:"ml-4 pl-3 border-l-2 border-gray-200",children:[(0,t.jsx)(N.Text,{className:"text-xs text-gray-500 mb-1",children:"Resolved Guardrails:"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:e4[e].map((e,l)=>(0,t.jsx)(T.Badge,{color:"blue",size:"xs",children:e},l))})]})]},l))}):(0,t.jsx)(N.Text,{className:"text-gray-500",children:"No policies configured"})]}),(0,t.jsx)(Q.default,{loggingConfigs:tT.metadata?.logging||[],disabledCallbacks:[],variant:"card"})]})},{key:ez,label:eD[ez],children:(0,t.jsx)(eI,{teamId:e})},{key:eA,label:eD[eA],children:(0,t.jsx)(e0,{teamId:e,teamAlias:tT.team_alias,organization:ti})},{key:eF,label:eD[eF],children:(0,t.jsx)(eB,{teamData:ev,canEditTeam:tp,handleMemberDelete:e=>{e8(e),e9(!0)},setSelectedEditMember:eU,setIsEditMemberModalVisible:eR,setIsAddMemberModalVisible:eC})},{key:eO,label:eD[eO],children:(0,t.jsx)(eb,{teamId:e,accessToken:o,canEditTeam:tp})},{key:eP,label:eD[eP],children:(0,t.jsxs)(S.Card,{className:"overflow-y-auto max-h-[65vh]",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,t.jsx)(k.Title,{children:"Team Settings"}),tp&&!eE&&(0,t.jsx)(I.Button,{icon:(0,t.jsx)(g.EditOutlined,{className:"h-4 w-4"}),onClick:()=>e$(!0),children:"Edit Settings"})]}),eE&&eY?(0,t.jsx)("div",{className:"p-4",children:"Loading..."}):eE?(0,t.jsxs)(M.Form,{form:ek,onFinish:tv,onValuesChange:e=>{if("disable_global_guardrails"in e){let t=!0===e.disable_global_guardrails,l=(ek.getFieldValue("guardrails")||[]).filter(e=>!eX.has(e));ek.setFieldValue("guardrails",t?l:[...Array.from(eX),...l])}},initialValues:{...tT,team_alias:tT.team_alias,models:tT.models,tpm_limit:tT.tpm_limit,rpm_limit:tT.rpm_limit,object_permission_search_tools:tT.object_permission?.search_tools||[],modelLimits:Array.from(new Set([...Object.keys(tT.metadata?.model_tpm_limit??{}),...Object.keys(tT.metadata?.model_rpm_limit??{})])).map(e=>({model:e,tpm:tT.metadata?.model_tpm_limit?.[e],rpm:tT.metadata?.model_rpm_limit?.[e]})),max_budget:tT.max_budget,soft_budget:tT.soft_budget,budget_duration:tT.budget_duration,team_member_tpm_limit:tT.team_member_budget_table?.tpm_limit,team_member_rpm_limit:tT.team_member_budget_table?.rpm_limit,team_member_budget:tT.team_member_budget_table?.max_budget,team_member_budget_duration:tT.team_member_budget_table?.budget_duration,guardrails:tC,policies:tT.policies||[],disable_global_guardrails:tT.metadata?.disable_global_guardrails||!1,soft_budget_alerting_emails:Array.isArray(tT.metadata?.soft_budget_alerting_emails)?tT.metadata.soft_budget_alerting_emails.join(", "):"",metadata:tT.metadata?JSON.stringify((({logging:e,secret_manager_settings:t,soft_budget_alerting_emails:l,model_tpm_limit:a,model_rpm_limit:s,...i})=>i)(tT.metadata),null,2):"",logging_settings:tT.metadata?.logging||[],secret_manager_settings:tT.metadata?.secret_manager_settings?JSON.stringify(tT.metadata.secret_manager_settings,null,2):"",organization_id:tT.organization_id,vector_stores:tT.object_permission?.vector_stores||[],mcp_servers:tT.object_permission?.mcp_servers||[],mcp_access_groups:tT.object_permission?.mcp_access_groups||[],mcp_servers_and_groups:{servers:tT.object_permission?.mcp_servers||[],accessGroups:tT.object_permission?.mcp_access_groups||[],toolsets:tT.object_permission?.mcp_toolsets||[]},mcp_tool_permissions:tT.object_permission?.mcp_tool_permissions||{},agents_and_groups:{agents:tT.object_permission?.agents||[],accessGroups:tT.object_permission?.agent_access_groups||[]},access_group_ids:tT.access_group_ids||[],default_team_member_models:tT.default_team_member_models||[]},layout:"vertical",children:[(0,t.jsx)(M.Form.Item,{label:"Team Name",name:"team_alias",rules:[{required:!0,message:"Please input a team name"}],children:(0,t.jsx)(z.Input,{type:""})}),(0,t.jsx)(M.Form.Item,{label:"Models",name:"models",rules:[{required:!0,message:"Please select at least one model"}],children:(0,t.jsx)(Z.ModelSelect,{value:ek.getFieldValue("models")||[],onChange:e=>ek.setFieldValue("models",e),teamID:e,organizationID:ev?.team_info?.organization_id||void 0,options:{includeSpecialOptions:!0,includeUserModels:!ev?.team_info?.organization_id,showAllProxyModelsOverride:(0,u.isProxyAdminRole)(tn)&&!ev?.team_info?.organization_id},context:"team",dataTestId:"models-select"})}),(0,t.jsx)(M.Form.Item,{label:"Max Budget (USD)",name:"max_budget",children:(0,t.jsx)(el.default,{step:.01,precision:2,style:{width:"100%"}})}),(0,t.jsx)(M.Form.Item,{label:"Soft Budget (USD)",name:"soft_budget",children:(0,t.jsx)(el.default,{step:.01,precision:2,style:{width:"100%"}})}),(0,t.jsx)(M.Form.Item,{label:"Soft Budget Alerting Emails",name:"soft_budget_alerting_emails",tooltip:"Comma-separated email addresses to receive alerts when the soft budget is reached",children:(0,t.jsx)(z.Input,{placeholder:"example1@test.com, example2@test.com"})}),(0,t.jsxs)(j.Accordion,{className:"mt-4 mb-4",children:[(0,t.jsx)(v.AccordionHeader,{children:(0,t.jsx)("b",{children:"Team Member Settings"})}),(0,t.jsxs)(f.AccordionBody,{children:[(0,t.jsx)(N.Text,{className:"text-xs text-gray-500 mb-4",children:"Optional defaults applied when members join this team. All fields can be overridden per member."}),(0,t.jsx)(M.Form.Item,{label:(0,t.jsxs)("span",{children:["Default Model Access"," ",(0,t.jsx)(R.Tooltip,{title:"Optional. If set, new members can only access these models by default. Must be a subset of the team's models above. Leave empty to give all members access to all team models.",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"default_team_member_models",children:(0,t.jsx)(M.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.models!==t.models,children:({getFieldValue:e})=>{let l=e("models")||tT.models||[];return(0,t.jsx)(F.Select,{mode:"multiple",placeholder:"Leave empty — all team models accessible to every member",value:ek.getFieldValue("default_team_member_models")||[],onChange:e=>ek.setFieldValue("default_team_member_models",e),options:l.map(e=>({label:e,value:e}))})}})}),(0,t.jsx)(M.Form.Item,{label:"Default Budget (USD)",name:"team_member_budget",tooltip:"Default spend budget for each member in this team.",children:(0,t.jsx)(el.default,{step:.01,precision:2,style:{width:"100%"}})}),(0,t.jsx)(M.Form.Item,{label:"Default Budget Duration",name:"team_member_budget_duration",children:(0,t.jsx)(W,{onChange:e=>ek.setFieldValue("team_member_budget_duration",e),value:ek.getFieldValue("team_member_budget_duration")})}),(0,t.jsx)(M.Form.Item,{label:"Default Key Duration (eg: 1d, 1mo)",name:"team_member_key_duration",tooltip:"Set a limit to the duration of a team member's key. Format: 30s (seconds), 30m (minutes), 30h (hours), 30d (days), 1mo (month)",children:(0,t.jsx)(C.TextInput,{placeholder:"e.g., 30d"})}),(0,t.jsx)(M.Form.Item,{label:"Default TPM Limit",name:"team_member_tpm_limit",tooltip:"Default tokens per minute limit for each member. Can be overridden per member.",children:(0,t.jsx)(el.default,{step:1,style:{width:"100%"},placeholder:"e.g., 1000"})}),(0,t.jsx)(M.Form.Item,{label:"Default RPM Limit",name:"team_member_rpm_limit",tooltip:"Default requests per minute limit for each member. Can be overridden per member.",children:(0,t.jsx)(el.default,{step:1,style:{width:"100%"},placeholder:"e.g., 100"})})]})]}),(0,t.jsx)(M.Form.Item,{label:"Reset Budget",name:"budget_duration",children:(0,t.jsxs)(F.Select,{placeholder:"n/a",children:[(0,t.jsx)(F.Select.Option,{value:"24h",children:"daily"}),(0,t.jsx)(F.Select.Option,{value:"7d",children:"weekly"}),(0,t.jsx)(F.Select.Option,{value:"30d",children:"monthly"})]})}),(0,t.jsx)(M.Form.Item,{label:"Tokens per minute Limit (TPM)",name:"tpm_limit",children:(0,t.jsx)(el.default,{step:1,style:{width:"100%"}})}),(0,t.jsx)(M.Form.Item,{label:"Requests per minute Limit (RPM)",name:"rpm_limit",children:(0,t.jsx)(el.default,{step:1,style:{width:"100%"}})}),(0,t.jsx)(M.Form.Item,{label:"Model-Specific Rate Limits",tooltip:"Set per-model TPM/RPM limits that apply across the whole team.",children:(0,t.jsx)(M.Form.List,{name:"modelLimits",children:(e,{add:l,remove:a})=>(0,t.jsxs)(t.Fragment,{children:[e.map(({key:e,name:l,...s})=>(0,t.jsxs)(O.Space,{style:{display:"flex",marginBottom:8},align:"baseline",children:[(0,t.jsx)(M.Form.Item,{...s,name:[l,"model"],rules:[{required:!0,message:"Missing model"},{validator:(e,t)=>t&&(ek.getFieldValue("modelLimits")??[]).filter(e=>e?.model===t).length>1?Promise.reject(Error("Duplicate model")):Promise.resolve()}],style:{minWidth:240},children:(0,t.jsx)(F.Select,{showSearch:!0,placeholder:"Select model",allowClear:!0,options:th.map(e=>({value:e,label:e}))})}),(0,t.jsx)(M.Form.Item,{...s,name:[l,"tpm"],rules:[{validator:async(e,t)=>{let a=(ek.getFieldValue("modelLimits")??[])[l]??{};return a.model&&null==t&&null==a.rpm?Promise.reject(Error("Set at least one of TPM or RPM")):Promise.resolve()}}],children:(0,t.jsx)(A.InputNumber,{placeholder:"TPM Limit",min:0})}),(0,t.jsx)(M.Form.Item,{...s,name:[l,"rpm"],children:(0,t.jsx)(A.InputNumber,{placeholder:"RPM Limit",min:0})}),(0,t.jsx)(x.MinusCircleOutlined,{onClick:()=>a(l),style:{color:"#ef4444"}})]},e)),(0,t.jsx)(M.Form.Item,{children:(0,t.jsx)(I.Button,{type:"dashed",onClick:()=>l(),block:!0,icon:(0,t.jsx)(_.PlusOutlined,{}),children:"Add Model Limit"})})]})})}),(0,t.jsx)(M.Form.Item,{label:"Router Settings",children:(0,t.jsx)(er.default,{ref:ts,accessToken:o||"",value:tT.router_settings?{router_settings:tT.router_settings}:void 0})}),(0,t.jsx)(M.Form.Item,{label:(0,t.jsxs)("span",{children:["Guardrails"," ",(0,t.jsx)(R.Tooltip,{title:"Select which guardrails apply to this team. Global guardrails are enabled by default — uncheck to opt out. Other guardrails are opt-in.",children:(0,t.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/quick_start",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})})]}),name:"guardrails",children:(0,t.jsxs)(F.Select,{mode:"multiple",placeholder:"Select guardrails",optionLabelProp:"label",tagRender:({label:e,value:l,closable:a,onClose:s})=>{let i=eX.has(l);return(0,t.jsxs)(L.Tag,{color:"blue",closable:a,onClose:s,onMouseDown:tk,style:{marginInlineEnd:4},children:[i&&(0,t.jsx)(h.GlobalOutlined,{style:{marginInlineEnd:4},"aria-label":"Global guardrail"}),e]})},children:[(0,t.jsx)(F.Select.OptGroup,{label:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.GlobalOutlined,{style:{marginInlineEnd:4}}),"Global"]}),children:(eQ?.guardrails??[]).filter(e=>e.litellm_params?.default_on).map(e=>(0,t.jsx)(F.Select.Option,{value:e.guardrail_name,label:e.guardrail_name,disabled:tg,children:e.guardrail_name},e.guardrail_name))}),(0,t.jsx)(F.Select.OptGroup,{label:"Other",children:(eQ?.guardrails??[]).filter(e=>!e.litellm_params?.default_on).map(e=>(0,t.jsx)(F.Select.Option,{value:e.guardrail_name,label:e.guardrail_name,children:e.guardrail_name},e.guardrail_name))})]})}),(0,t.jsx)(M.Form.Item,{label:(0,t.jsxs)("span",{children:["Disable all global guardrails"," ",(0,t.jsx)(R.Tooltip,{title:"Kill switch: bypass every global guardrail for this team, including any added in the future. For per-guardrail opt-out instead, use the Guardrails dropdown above.",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"disable_global_guardrails",valuePropName:"checked",children:(0,t.jsx)(P.Switch,{checkedChildren:"Yes",unCheckedChildren:"No"})}),(0,t.jsx)(M.Form.Item,{label:(0,t.jsxs)("span",{children:["Policies"," ",(0,t.jsx)(R.Tooltip,{title:"Apply policies to this team to control guardrails and other settings",children:(0,t.jsx)("a",{href:"https://docs.litellm.ai/docs/proxy/guardrails/guardrail_policies",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})})]}),name:"policies",children:(0,t.jsx)(F.Select,{mode:"tags",placeholder:"Select or enter policies",options:eZ.map(e=>({value:e,label:e}))})}),(0,t.jsx)(M.Form.Item,{label:(0,t.jsxs)("span",{children:["Access Groups"," ",(0,t.jsx)(R.Tooltip,{title:"Assign access groups to this team. Access groups control which models, MCP servers, and agents this team can use",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"access_group_ids",children:(0,t.jsx)($.default,{placeholder:"Select access groups (optional)"})}),(0,t.jsx)(M.Form.Item,{label:"Vector Stores",name:"vector_stores","aria-label":"Vector Stores",children:(0,t.jsx)(ea.default,{onChange:e=>ek.setFieldValue("vector_stores",e),value:ek.getFieldValue("vector_stores"),accessToken:o||"",placeholder:"Select vector stores"})}),(0,t.jsx)(M.Form.Item,{label:"Allowed Pass Through Routes",name:"allowed_passthrough_routes",children:(0,t.jsx)(q.default,{onChange:e=>ek.setFieldValue("allowed_passthrough_routes",e),value:ek.getFieldValue("allowed_passthrough_routes"),accessToken:o||"",placeholder:"Select pass through routes"})}),(0,t.jsx)(M.Form.Item,{label:"MCP Servers / Access Groups",name:"mcp_servers_and_groups",children:(0,t.jsx)(Y.default,{onChange:e=>ek.setFieldValue("mcp_servers_and_groups",e),value:ek.getFieldValue("mcp_servers_and_groups"),accessToken:o||"",placeholder:"Select MCP servers or access groups (optional)"})}),(0,t.jsx)(M.Form.Item,{name:"mcp_tool_permissions",initialValue:{},hidden:!0,children:(0,t.jsx)(z.Input,{type:"hidden"})}),(0,t.jsx)(M.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.mcp_servers_and_groups!==t.mcp_servers_and_groups||e.mcp_tool_permissions!==t.mcp_tool_permissions,children:()=>(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)(X.default,{accessToken:o||"",selectedServers:ek.getFieldValue("mcp_servers_and_groups")?.servers||[],toolPermissions:ek.getFieldValue("mcp_tool_permissions")||{},onChange:e=>ek.setFieldsValue({mcp_tool_permissions:e})})})}),(0,t.jsx)(M.Form.Item,{label:"Agents / Access Groups",name:"agents_and_groups",children:(0,t.jsx)(K.default,{onChange:e=>ek.setFieldValue("agents_and_groups",e),value:ek.getFieldValue("agents_and_groups"),accessToken:o||"",placeholder:"Select agents or access groups (optional)"})}),(0,t.jsxs)(j.Accordion,{className:"mt-4 mb-4",children:[(0,t.jsx)(v.AccordionHeader,{children:(0,t.jsx)("b",{children:"Search Tool Settings"})}),(0,t.jsx)(f.AccordionBody,{children:(0,t.jsx)(M.Form.Item,{label:"Allowed Search Tools",name:"object_permission_search_tools",tooltip:"Select which search tools this team can access. Leave empty to allow all search tools.",children:(0,t.jsx)(es,{onChange:e=>ek.setFieldValue("object_permission_search_tools",e),value:ek.getFieldValue("object_permission_search_tools"),accessToken:o||"",placeholder:"Select search tools (optional, empty = all allowed)"})})})]}),(0,t.jsx)(M.Form.Item,{label:"Organization",name:"organization_id",children:(0,t.jsx)(F.Select,{allowClear:!0,placeholder:"Select an organization",showSearch:!0,optionFilterProp:"label",options:td.map(e=>({value:e.organization_id,label:e.organization_alias||e.organization_id}))})}),(0,t.jsx)(M.Form.Item,{label:"Logging Settings",name:"logging_settings",children:(0,t.jsx)(ei.default,{value:ek.getFieldValue("logging_settings"),onChange:e=>ek.setFieldValue("logging_settings",e)})}),(0,t.jsx)(M.Form.Item,{label:"Secret Manager Settings",name:"secret_manager_settings",help:eg?"Enter secret manager configuration as a JSON object.":"Premium feature - Upgrade to manage secret manager settings.",rules:[{validator:async(e,t)=>{if(!t)return Promise.resolve();try{return JSON.parse(t),Promise.resolve()}catch(e){return Promise.reject(Error("Please enter valid JSON"))}}}],children:(0,t.jsx)(z.Input.TextArea,{rows:6,placeholder:'{"namespace": "admin", "mount": "secret", "path_prefix": "litellm"}',disabled:!eg})}),(0,t.jsx)(M.Form.Item,{label:"Metadata",name:"metadata",children:(0,t.jsx)(z.Input.TextArea,{rows:10})}),(0,t.jsx)("div",{className:"sticky z-10 bg-white p-4 pr-0 border-t border-gray-200 bottom-[-1.5rem] inset-x-[-1.5rem]",children:(0,t.jsxs)("div",{className:"flex justify-end items-center gap-2",children:[(0,t.jsx)(I.Button,{onClick:()=>e$(!1),disabled:tl,children:"Cancel"}),(0,t.jsx)(I.Button,{icon:(0,t.jsx)(b.SaveOutlined,{className:"h-4 w-4"}),type:"primary",htmlType:"submit",loading:tl,children:"Save Changes"})]})})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Team Name"}),(0,t.jsx)("div",{children:tT.team_alias})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Team ID"}),(0,t.jsx)("div",{className:"font-mono",children:tT.team_id})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Created At"}),(0,t.jsx)("div",{children:new Date(tT.created_at).toLocaleString()})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Models"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:tT.models.map((e,l)=>(0,t.jsx)(T.Badge,{color:"red",children:e},l))})]}),tT.default_team_member_models&&tT.default_team_member_models.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Default Member Models"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:tT.default_team_member_models.map((e,l)=>(0,t.jsx)(T.Badge,{color:"blue",children:e},l))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Rate Limits"}),(0,t.jsxs)("div",{children:["TPM: ",tT.tpm_limit||"Unlimited"]}),(0,t.jsxs)("div",{children:["RPM: ",tT.rpm_limit||"Unlimited"]}),(ey=tT.metadata?.model_tpm_limit??{},ej=tT.metadata?.model_rpm_limit??{},0===(ef=Array.from(new Set([...Object.keys(ey),...Object.keys(ej)]))).length?null:(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)(N.Text,{className:"text-gray-500",children:"Per-model limits:"}),ef.map(e=>(0,t.jsxs)("div",{className:"text-xs ml-2",children:[e,": TPM ",ey[e]??"—",", RPM ",ej[e]??"—"]},e))]}))]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Team Budget"}),(0,t.jsxs)("div",{children:["Max Budget:"," ",null!==tT.max_budget?`$${(0,m.formatNumberWithCommas)(tT.max_budget,4)}`:"No Limit"]}),(0,t.jsxs)("div",{children:["Soft Budget:"," ",null!==tT.soft_budget&&void 0!==tT.soft_budget?`$${(0,m.formatNumberWithCommas)(tT.soft_budget,4)}`:"No Limit"]}),(0,t.jsxs)("div",{children:["Budget Reset: ",tT.budget_duration||"Never"]}),tT.metadata?.soft_budget_alerting_emails&&Array.isArray(tT.metadata.soft_budget_alerting_emails)&&tT.metadata.soft_budget_alerting_emails.length>0&&(0,t.jsxs)("div",{children:["Soft Budget Alerting Emails: ",tT.metadata.soft_budget_alerting_emails.join(", ")]})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)(N.Text,{className:"font-medium",children:["Team Member Settings"," ",(0,t.jsx)(R.Tooltip,{title:"These are limits on individual team members",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),(0,t.jsxs)("div",{children:["Max Budget: ",tT.team_member_budget_table?.max_budget||"No Limit"]}),(0,t.jsxs)("div",{children:["Budget Duration: ",tT.team_member_budget_table?.budget_duration||"No Limit"]}),(0,t.jsxs)("div",{children:["Key Duration: ",tT.metadata?.team_member_key_duration||"No Limit"]}),(0,t.jsxs)("div",{children:["TPM Limit: ",tT.team_member_budget_table?.tpm_limit||"No Limit"]}),(0,t.jsxs)("div",{children:["RPM Limit: ",tT.team_member_budget_table?.rpm_limit||"No Limit"]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Router Settings"}),tT.router_settings&&Object.values(tT.router_settings).some(e=>null!=e&&""!==e&&!(Array.isArray(e)&&0===e.length))?(0,t.jsxs)("div",{className:"mt-1 space-y-1",children:[tT.router_settings.routing_strategy&&(0,t.jsxs)("div",{children:["Routing Strategy:"," ",(0,t.jsx)(T.Badge,{color:"blue",children:tT.router_settings.routing_strategy})]}),null!=tT.router_settings.num_retries&&(0,t.jsxs)("div",{children:["Number of Retries: ",tT.router_settings.num_retries]}),null!=tT.router_settings.allowed_fails&&(0,t.jsxs)("div",{children:["Allowed Failures: ",tT.router_settings.allowed_fails]}),null!=tT.router_settings.cooldown_time&&(0,t.jsxs)("div",{children:["Cooldown Time: ",tT.router_settings.cooldown_time,"s"]}),null!=tT.router_settings.timeout&&(0,t.jsxs)("div",{children:["Timeout: ",tT.router_settings.timeout,"s"]}),null!=tT.router_settings.retry_after&&(0,t.jsxs)("div",{children:["Retry After: ",tT.router_settings.retry_after,"s"]}),tT.router_settings.fallbacks&&Array.isArray(tT.router_settings.fallbacks)&&tT.router_settings.fallbacks.length>0&&(0,t.jsxs)("div",{children:["Fallbacks: ",tT.router_settings.fallbacks.length," configured"]}),tT.router_settings.enable_tag_filtering&&(0,t.jsx)("div",{children:"Tag Filtering: Enabled"})]}):(0,t.jsx)("div",{className:"text-gray-400",children:"No router settings configured"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Organization ID"}),(0,t.jsx)("div",{children:tT.organization_id})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Status"}),(0,t.jsx)(T.Badge,{color:tT.blocked?"red":"green",children:tT.blocked?"Blocked":"Active"})]}),(0,t.jsx)(et.default,{objectPermission:tT.object_permission,variant:"inline",className:"pt-4 border-t border-gray-200",accessToken:o}),(0,t.jsx)(J,{globalGuardrailNames:eX,teamGuardrails:Array.isArray(tT.metadata?.guardrails)?tT.metadata.guardrails:[],optedOutGlobalGuardrails:Array.isArray(tT.metadata?.opted_out_global_guardrails)?tT.metadata.opted_out_global_guardrails:[],killSwitchOn:tS,variant:"inline",className:"pt-4 border-t border-gray-200"}),(0,t.jsx)(Q.default,{loggingConfigs:tT.metadata?.logging||[],disabledCallbacks:[],variant:"inline",className:"pt-4 border-t border-gray-200"}),tT.metadata?.secret_manager_settings&&(0,t.jsxs)("div",{className:"pt-4 border-t border-gray-200",children:[(0,t.jsx)(N.Text,{className:"font-medium",children:"Secret Manager Settings"}),(0,t.jsx)("pre",{className:"mt-2 bg-gray-50 p-3 rounded text-xs overflow-x-auto",children:JSON.stringify(tT.metadata.secret_manager_settings,null,2)})]})]})]})}].filter(e=>tx.includes(e.key))}),(0,t.jsx)(en.default,{visible:eL,onCancel:()=>eR(!1),onSubmit:tj,initialData:eV,mode:"edit",config:{title:"Edit Member",showEmail:!0,showUserId:!0,roleOptions:[{label:"Admin",value:"admin"},{label:"User",value:"user"}],additionalFields:[{name:"max_budget_in_team",label:(0,t.jsxs)("span",{children:["Team Member Budget (USD)"," ",(0,t.jsx)(R.Tooltip,{title:"Maximum amount in USD this member can spend within this team. This is separate from any global user budget limits",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),type:"numerical",step:.01,min:0,placeholder:"Budget limit for this member within this team"},{name:"tpm_limit",label:(0,t.jsxs)("span",{children:["Team Member TPM Limit"," ",(0,t.jsx)(R.Tooltip,{title:"Maximum tokens per minute this member can use within this team. This is separate from any global user TPM limit",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),type:"numerical",step:1,min:0,placeholder:"Tokens per minute limit for this member in this team"},{name:"rpm_limit",label:(0,t.jsxs)("span",{children:["Team Member RPM Limit"," ",(0,t.jsx)(R.Tooltip,{title:"Maximum requests per minute this member can make within this team. This is separate from any global user RPM limit",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),type:"numerical",step:1,min:0,placeholder:"Requests per minute limit for this member in this team"},{name:"allowed_models",label:(0,t.jsxs)("span",{children:["Allowed Models"," ",(0,t.jsx)(R.Tooltip,{title:"Models this member can access within this team. Leave empty to inherit all team models.",children:(0,t.jsx)(p.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),type:"multi-select",options:(tT.models||[]).map(e=>({label:e,value:e})),placeholder:"Leave empty to inherit all team models"}]}}),(0,t.jsx)(i.default,{isVisible:eN,onCancel:()=>eC(!1),onSubmit:ty,accessToken:o,teamId:e}),(0,t.jsx)(G.default,{isOpen:e7,title:"Delete Team Member",alertMessage:"Removing team members will also delete any keys created by or created for this member.",message:"Are you sure you want to remove this member from the team? This action cannot be undone.",resourceInformationTitle:"Team Member Information",resourceInformation:[{label:"User ID",value:e6?.user_id,code:!0},{label:"Email",value:e6?.user_email},{label:"Role",value:e6?.role}],onCancel:()=>{e9(!1),e8(null)},onOk:tf,confirmLoading:te})]})}],56567)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/0493aafc4891dd29.js b/litellm/proxy/_experimental/out/_next/static/chunks/0493aafc4891dd29.js new file mode 100644 index 0000000000..90c97f4525 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0493aafc4891dd29.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,312361,e=>{"use strict";e.i(247167);var t=e.i(271645),n=e.i(343794),r=e.i(242064),i=e.i(517455);e.i(296059);var a=e.i(915654),l=e.i(183293),o=e.i(246422),c=e.i(838378);let s=(0,o.genStyleHooks)("Divider",e=>{let t=(0,c.mergeToken)(e,{dividerHorizontalWithTextGutterMargin:e.margin,sizePaddingEdgeHorizontal:0});return[(e=>{let{componentCls:t,sizePaddingEdgeHorizontal:n,colorSplit:r,lineWidth:i,textPaddingInline:o,orientationMargin:c,verticalMarginInline:s}=e;return{[t]:Object.assign(Object.assign({},(0,l.resetComponent)(e)),{borderBlockStart:`${(0,a.unit)(i)} solid ${r}`,"&-vertical":{position:"relative",top:"-0.06em",display:"inline-block",height:"0.9em",marginInline:s,marginBlock:0,verticalAlign:"middle",borderTop:0,borderInlineStart:`${(0,a.unit)(i)} solid ${r}`},"&-horizontal":{display:"flex",clear:"both",width:"100%",minWidth:"100%",margin:`${(0,a.unit)(e.marginLG)} 0`},[`&-horizontal${t}-with-text`]:{display:"flex",alignItems:"center",margin:`${(0,a.unit)(e.dividerHorizontalWithTextGutterMargin)} 0`,color:e.colorTextHeading,fontWeight:500,fontSize:e.fontSizeLG,whiteSpace:"nowrap",textAlign:"center",borderBlockStart:`0 ${r}`,"&::before, &::after":{position:"relative",width:"50%",borderBlockStart:`${(0,a.unit)(i)} solid transparent`,borderBlockStartColor:"inherit",borderBlockEnd:0,transform:"translateY(50%)",content:"''"}},[`&-horizontal${t}-with-text-start`]:{"&::before":{width:`calc(${c} * 100%)`},"&::after":{width:`calc(100% - ${c} * 100%)`}},[`&-horizontal${t}-with-text-end`]:{"&::before":{width:`calc(100% - ${c} * 100%)`},"&::after":{width:`calc(${c} * 100%)`}},[`${t}-inner-text`]:{display:"inline-block",paddingBlock:0,paddingInline:o},"&-dashed":{background:"none",borderColor:r,borderStyle:"dashed",borderWidth:`${(0,a.unit)(i)} 0 0`},[`&-horizontal${t}-with-text${t}-dashed`]:{"&::before, &::after":{borderStyle:"dashed none none"}},[`&-vertical${t}-dashed`]:{borderInlineStartWidth:i,borderInlineEnd:0,borderBlockStart:0,borderBlockEnd:0},"&-dotted":{background:"none",borderColor:r,borderStyle:"dotted",borderWidth:`${(0,a.unit)(i)} 0 0`},[`&-horizontal${t}-with-text${t}-dotted`]:{"&::before, &::after":{borderStyle:"dotted none none"}},[`&-vertical${t}-dotted`]:{borderInlineStartWidth:i,borderInlineEnd:0,borderBlockStart:0,borderBlockEnd:0},[`&-plain${t}-with-text`]:{color:e.colorText,fontWeight:"normal",fontSize:e.fontSize},[`&-horizontal${t}-with-text-start${t}-no-default-orientation-margin-start`]:{"&::before":{width:0},"&::after":{width:"100%"},[`${t}-inner-text`]:{paddingInlineStart:n}},[`&-horizontal${t}-with-text-end${t}-no-default-orientation-margin-end`]:{"&::before":{width:"100%"},"&::after":{width:0},[`${t}-inner-text`]:{paddingInlineEnd:n}}})}})(t),(e=>{let{componentCls:t}=e;return{[t]:{"&-horizontal":{[`&${t}`]:{"&-sm":{marginBlock:e.marginXS},"&-md":{marginBlock:e.margin}}}}}})(t)]},e=>({textPaddingInline:"1em",orientationMargin:.05,verticalMarginInline:e.marginXS}),{unitless:{orientationMargin:!0}});var d=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let u={small:"sm",middle:"md"};e.s(["Divider",0,e=>{let{getPrefixCls:a,direction:l,className:o,style:c}=(0,r.useComponentConfig)("divider"),{prefixCls:g,type:m="horizontal",orientation:p="center",orientationMargin:h,className:f,rootClassName:b,children:$,dashed:y,variant:S="solid",plain:v,style:k,size:C}=e,w=d(e,["prefixCls","type","orientation","orientationMargin","className","rootClassName","children","dashed","variant","plain","style","size"]),I=a("divider",g),[x,O,E]=s(I),z=u[(0,i.default)(C)],j=!!$,N=t.useMemo(()=>"left"===p?"rtl"===l?"end":"start":"right"===p?"rtl"===l?"start":"end":p,[l,p]),P="start"===N&&null!=h,T="end"===N&&null!=h,M=(0,n.default)(I,o,O,E,`${I}-${m}`,{[`${I}-with-text`]:j,[`${I}-with-text-${N}`]:j,[`${I}-dashed`]:!!y,[`${I}-${S}`]:"solid"!==S,[`${I}-plain`]:!!v,[`${I}-rtl`]:"rtl"===l,[`${I}-no-default-orientation-margin-start`]:P,[`${I}-no-default-orientation-margin-end`]:T,[`${I}-${z}`]:!!z},f,b),B=t.useMemo(()=>"number"==typeof h?h:/^\d+$/.test(h)?Number(h):h,[h]);return x(t.createElement("div",Object.assign({className:M,style:Object.assign(Object.assign({},c),k)},w,{role:"separator"}),$&&"vertical"!==m&&t.createElement("span",{className:`${I}-inner-text`,style:{marginInlineStart:P?B:void 0,marginInlineEnd:T?B:void 0}},$)))}],312361)},801312,e=>{"use strict";e.i(247167);var t=e.i(931067),n=e.i(271645);let r={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"}}]},name:"left",theme:"outlined"};var i=e.i(9583),a=n.forwardRef(function(e,a){return n.createElement(i.default,(0,t.default)({},e,{ref:a,icon:r}))});e.s(["default",0,a],801312)},475254,e=>{"use strict";var t=e.i(271645);let n=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},r=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim();var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let a=(0,t.forwardRef)(({color:e="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,iconNode:s,...d},u)=>(0,t.createElement)("svg",{ref:u,...i,width:n,height:n,stroke:e,strokeWidth:l?24*Number(a)/Number(n):a,className:r("lucide",o),...!c&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(d)&&{"aria-hidden":"true"},...d},[...s.map(([e,n])=>(0,t.createElement)(e,n)),...Array.isArray(c)?c:[c]])),l=(e,i)=>{let l=(0,t.forwardRef)(({className:l,...o},c)=>(0,t.createElement)(a,{ref:c,iconNode:i,className:r(`lucide-${n(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,l),...o}));return l.displayName=n(e),l};e.s(["default",()=>l],475254)},262218,e=>{"use strict";e.i(247167);var t=e.i(271645),n=e.i(343794),r=e.i(529681),i=e.i(702779),a=e.i(563113),l=e.i(763731),o=e.i(121872),c=e.i(242064);e.i(296059);var s=e.i(915654);e.i(262370);var d=e.i(135551),u=e.i(183293),g=e.i(246422),m=e.i(838378);let p=e=>{let{lineWidth:t,fontSizeIcon:n,calc:r}=e,i=e.fontSizeSM;return(0,m.mergeToken)(e,{tagFontSize:i,tagLineHeight:(0,s.unit)(r(e.lineHeightSM).mul(i).equal()),tagIconSize:r(n).sub(r(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},h=e=>({defaultBg:new d.FastColor(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),f=(0,g.genStyleHooks)("Tag",e=>(e=>{let{paddingXXS:t,lineWidth:n,tagPaddingHorizontal:r,componentCls:i,calc:a}=e,l=a(r).sub(n).equal(),o=a(t).sub(n).equal();return{[i]:Object.assign(Object.assign({},(0,u.resetComponent)(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:l,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${(0,s.unit)(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${i}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${i}-close-icon`]:{marginInlineStart:o,fontSize:e.tagIconSize,color:e.colorIcon,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${i}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${i}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:l}}),[`${i}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}})(p(e)),h);var b=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let $=t.forwardRef((e,r)=>{let{prefixCls:i,style:a,className:l,checked:o,children:s,icon:d,onChange:u,onClick:g}=e,m=b(e,["prefixCls","style","className","checked","children","icon","onChange","onClick"]),{getPrefixCls:p,tag:h}=t.useContext(c.ConfigContext),$=p("tag",i),[y,S,v]=f($),k=(0,n.default)($,`${$}-checkable`,{[`${$}-checkable-checked`]:o},null==h?void 0:h.className,l,S,v);return y(t.createElement("span",Object.assign({},m,{ref:r,style:Object.assign(Object.assign({},a),null==h?void 0:h.style),className:k,onClick:e=>{null==u||u(!o),null==g||g(e)}}),d,t.createElement("span",null,s)))});var y=e.i(403541);let S=(0,g.genSubStyleComponent)(["Tag","preset"],e=>{let t;return t=p(e),(0,y.genPresetColor)(t,(e,{textColor:n,lightBorderColor:r,lightColor:i,darkColor:a})=>({[`${t.componentCls}${t.componentCls}-${e}`]:{color:n,background:i,borderColor:r,"&-inverse":{color:t.colorTextLightSolid,background:a,borderColor:a},[`&${t.componentCls}-borderless`]:{borderColor:"transparent"}}}))},h),v=(e,t,n)=>{let r="string"!=typeof n?n:n.charAt(0).toUpperCase()+n.slice(1);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${n}`],background:e[`color${r}Bg`],borderColor:e[`color${r}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},k=(0,g.genSubStyleComponent)(["Tag","status"],e=>{let t=p(e);return[v(t,"success","Success"),v(t,"processing","Info"),v(t,"error","Error"),v(t,"warning","Warning")]},h);var C=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let w=t.forwardRef((e,s)=>{let{prefixCls:d,className:u,rootClassName:g,style:m,children:p,icon:h,color:b,onClose:$,bordered:y=!0,visible:v}=e,w=C(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:I,direction:x,tag:O}=t.useContext(c.ConfigContext),[E,z]=t.useState(!0),j=(0,r.default)(w,["closeIcon","closable"]);t.useEffect(()=>{void 0!==v&&z(v)},[v]);let N=(0,i.isPresetColor)(b),P=(0,i.isPresetStatusColor)(b),T=N||P,M=Object.assign(Object.assign({backgroundColor:b&&!T?b:void 0},null==O?void 0:O.style),m),B=I("tag",d),[H,L,R]=f(B),q=(0,n.default)(B,null==O?void 0:O.className,{[`${B}-${b}`]:T,[`${B}-has-color`]:b&&!T,[`${B}-hidden`]:!E,[`${B}-rtl`]:"rtl"===x,[`${B}-borderless`]:!y},u,g,L,R),G=e=>{e.stopPropagation(),null==$||$(e),e.defaultPrevented||z(!1)},[,A]=(0,a.useClosable)((0,a.pickClosable)(e),(0,a.pickClosable)(O),{closable:!1,closeIconRender:e=>{let r=t.createElement("span",{className:`${B}-close-icon`,onClick:G},e);return(0,l.replaceElement)(e,r,e=>({onClick:t=>{var n;null==(n=null==e?void 0:e.onClick)||n.call(e,t),G(t)},className:(0,n.default)(null==e?void 0:e.className,`${B}-close-icon`)}))}}),W="function"==typeof w.onClick||p&&"a"===p.type,D=h||null,X=D?t.createElement(t.Fragment,null,D,p&&t.createElement("span",null,p)):p,F=t.createElement("span",Object.assign({},j,{ref:s,className:q,style:M}),X,A,N&&t.createElement(S,{key:"preset",prefixCls:B}),P&&t.createElement(k,{key:"status",prefixCls:B}));return H(W?t.createElement(o.default,{component:"Tag"},F):F)});w.CheckableTag=$,e.s(["Tag",0,w],262218)},653496,e=>{"use strict";var t=e.i(721369);e.s(["Tabs",()=>t.default])},790848,e=>{"use strict";e.i(247167);var t=e.i(271645),n=e.i(739295),r=e.i(343794),i=e.i(931067),a=e.i(211577),l=e.i(392221),o=e.i(703923),c=e.i(914949),s=e.i(404948),d=["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"],u=t.forwardRef(function(e,n){var u,g=e.prefixCls,m=void 0===g?"rc-switch":g,p=e.className,h=e.checked,f=e.defaultChecked,b=e.disabled,$=e.loadingIcon,y=e.checkedChildren,S=e.unCheckedChildren,v=e.onClick,k=e.onChange,C=e.onKeyDown,w=(0,o.default)(e,d),I=(0,c.default)(!1,{value:h,defaultValue:f}),x=(0,l.default)(I,2),O=x[0],E=x[1];function z(e,t){var n=O;return b||(E(n=e),null==k||k(n,t)),n}var j=(0,r.default)(m,p,(u={},(0,a.default)(u,"".concat(m,"-checked"),O),(0,a.default)(u,"".concat(m,"-disabled"),b),u));return t.createElement("button",(0,i.default)({},w,{type:"button",role:"switch","aria-checked":O,disabled:b,className:j,ref:n,onKeyDown:function(e){e.which===s.default.LEFT?z(!1,e):e.which===s.default.RIGHT&&z(!0,e),null==C||C(e)},onClick:function(e){var t=z(!O,e);null==v||v(t,e)}}),$,t.createElement("span",{className:"".concat(m,"-inner")},t.createElement("span",{className:"".concat(m,"-inner-checked")},y),t.createElement("span",{className:"".concat(m,"-inner-unchecked")},S)))});u.displayName="Switch";var g=e.i(121872),m=e.i(242064),p=e.i(937328),h=e.i(517455);e.i(296059);var f=e.i(915654);e.i(262370);var b=e.i(135551),$=e.i(183293),y=e.i(246422),S=e.i(838378);let v=(0,y.genStyleHooks)("Switch",e=>{let t=(0,S.mergeToken)(e,{switchDuration:e.motionDurationMid,switchColor:e.colorPrimary,switchDisabledOpacity:e.opacityLoading,switchLoadingIconSize:e.calc(e.fontSizeIcon).mul(.75).equal(),switchLoadingIconColor:`rgba(0, 0, 0, ${e.opacityLoading})`,switchHandleActiveInset:"-30%"});return[(e=>{let{componentCls:t,trackHeight:n,trackMinWidth:r}=e;return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,$.resetComponent)(e)),{position:"relative",display:"inline-block",boxSizing:"border-box",minWidth:r,height:n,lineHeight:(0,f.unit)(n),verticalAlign:"middle",background:e.colorTextQuaternary,border:"0",borderRadius:100,cursor:"pointer",transition:`all ${e.motionDurationMid}`,userSelect:"none",[`&:hover:not(${t}-disabled)`]:{background:e.colorTextTertiary}}),(0,$.genFocusStyle)(e)),{[`&${t}-checked`]:{background:e.switchColor,[`&:hover:not(${t}-disabled)`]:{background:e.colorPrimaryHover}},[`&${t}-loading, &${t}-disabled`]:{cursor:"not-allowed",opacity:e.switchDisabledOpacity,"*":{boxShadow:"none",cursor:"not-allowed"}},[`&${t}-rtl`]:{direction:"rtl"}})}})(t),(e=>{let{componentCls:t,trackHeight:n,trackPadding:r,innerMinMargin:i,innerMaxMargin:a,handleSize:l,calc:o}=e,c=`${t}-inner`,s=(0,f.unit)(o(l).add(o(r).mul(2)).equal()),d=(0,f.unit)(o(a).mul(2).equal());return{[t]:{[c]:{display:"block",overflow:"hidden",borderRadius:100,height:"100%",paddingInlineStart:a,paddingInlineEnd:i,transition:`padding-inline-start ${e.switchDuration} ease-in-out, padding-inline-end ${e.switchDuration} ease-in-out`,[`${c}-checked, ${c}-unchecked`]:{display:"block",color:e.colorTextLightSolid,fontSize:e.fontSizeSM,transition:`margin-inline-start ${e.switchDuration} ease-in-out, margin-inline-end ${e.switchDuration} ease-in-out`,pointerEvents:"none",minHeight:n},[`${c}-checked`]:{marginInlineStart:`calc(-100% + ${s} - ${d})`,marginInlineEnd:`calc(100% - ${s} + ${d})`},[`${c}-unchecked`]:{marginTop:o(n).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`&${t}-checked ${c}`]:{paddingInlineStart:i,paddingInlineEnd:a,[`${c}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${c}-unchecked`]:{marginInlineStart:`calc(100% - ${s} + ${d})`,marginInlineEnd:`calc(-100% + ${s} - ${d})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${c}`]:{[`${c}-unchecked`]:{marginInlineStart:o(r).mul(2).equal(),marginInlineEnd:o(r).mul(-1).mul(2).equal()}},[`&${t}-checked ${c}`]:{[`${c}-checked`]:{marginInlineStart:o(r).mul(-1).mul(2).equal(),marginInlineEnd:o(r).mul(2).equal()}}}}}})(t),(e=>{let{componentCls:t,trackPadding:n,handleBg:r,handleShadow:i,handleSize:a,calc:l}=e,o=`${t}-handle`;return{[t]:{[o]:{position:"absolute",top:n,insetInlineStart:n,width:a,height:a,transition:`all ${e.switchDuration} ease-in-out`,"&::before":{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,backgroundColor:r,borderRadius:l(a).div(2).equal(),boxShadow:i,transition:`all ${e.switchDuration} ease-in-out`,content:'""'}},[`&${t}-checked ${o}`]:{insetInlineStart:`calc(100% - ${(0,f.unit)(l(a).add(n).equal())})`},[`&:not(${t}-disabled):active`]:{[`${o}::before`]:{insetInlineEnd:e.switchHandleActiveInset,insetInlineStart:0},[`&${t}-checked ${o}::before`]:{insetInlineEnd:0,insetInlineStart:e.switchHandleActiveInset}}}}})(t),(e=>{let{componentCls:t,handleSize:n,calc:r}=e;return{[t]:{[`${t}-loading-icon${e.iconCls}`]:{position:"relative",top:r(r(n).sub(e.fontSize)).div(2).equal(),color:e.switchLoadingIconColor,verticalAlign:"top"},[`&${t}-checked ${t}-loading-icon`]:{color:e.switchColor}}}})(t),(e=>{let{componentCls:t,trackHeightSM:n,trackPadding:r,trackMinWidthSM:i,innerMinMarginSM:a,innerMaxMarginSM:l,handleSizeSM:o,calc:c}=e,s=`${t}-inner`,d=(0,f.unit)(c(o).add(c(r).mul(2)).equal()),u=(0,f.unit)(c(l).mul(2).equal());return{[t]:{[`&${t}-small`]:{minWidth:i,height:n,lineHeight:(0,f.unit)(n),[`${t}-inner`]:{paddingInlineStart:l,paddingInlineEnd:a,[`${s}-checked, ${s}-unchecked`]:{minHeight:n},[`${s}-checked`]:{marginInlineStart:`calc(-100% + ${d} - ${u})`,marginInlineEnd:`calc(100% - ${d} + ${u})`},[`${s}-unchecked`]:{marginTop:c(n).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`${t}-handle`]:{width:o,height:o},[`${t}-loading-icon`]:{top:c(c(o).sub(e.switchLoadingIconSize)).div(2).equal(),fontSize:e.switchLoadingIconSize},[`&${t}-checked`]:{[`${t}-inner`]:{paddingInlineStart:a,paddingInlineEnd:l,[`${s}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${s}-unchecked`]:{marginInlineStart:`calc(100% - ${d} + ${u})`,marginInlineEnd:`calc(-100% + ${d} - ${u})`}},[`${t}-handle`]:{insetInlineStart:`calc(100% - ${(0,f.unit)(c(o).add(r).equal())})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${s}`]:{[`${s}-unchecked`]:{marginInlineStart:c(e.marginXXS).div(2).equal(),marginInlineEnd:c(e.marginXXS).mul(-1).div(2).equal()}},[`&${t}-checked ${s}`]:{[`${s}-checked`]:{marginInlineStart:c(e.marginXXS).mul(-1).div(2).equal(),marginInlineEnd:c(e.marginXXS).div(2).equal()}}}}}}})(t)]},e=>{let{fontSize:t,lineHeight:n,controlHeight:r,colorWhite:i}=e,a=t*n,l=r/2,o=a-4,c=l-4;return{trackHeight:a,trackHeightSM:l,trackMinWidth:2*o+8,trackMinWidthSM:2*c+4,trackPadding:2,handleBg:i,handleSize:o,handleSizeSM:c,handleShadow:`0 2px 4px 0 ${new b.FastColor("#00230b").setA(.2).toRgbString()}`,innerMinMargin:o/2,innerMaxMargin:o+2+4,innerMinMarginSM:c/2,innerMaxMarginSM:c+2+4}});var k=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let C=t.forwardRef((e,i)=>{let{prefixCls:a,size:l,disabled:o,loading:s,className:d,rootClassName:f,style:b,checked:$,value:y,defaultChecked:S,defaultValue:C,onChange:w}=e,I=k(e,["prefixCls","size","disabled","loading","className","rootClassName","style","checked","value","defaultChecked","defaultValue","onChange"]),[x,O]=(0,c.default)(!1,{value:null!=$?$:y,defaultValue:null!=S?S:C}),{getPrefixCls:E,direction:z,switch:j}=t.useContext(m.ConfigContext),N=t.useContext(p.default),P=(null!=o?o:N)||s,T=E("switch",a),M=t.createElement("div",{className:`${T}-handle`},s&&t.createElement(n.default,{className:`${T}-loading-icon`})),[B,H,L]=v(T),R=(0,h.default)(l),q=(0,r.default)(null==j?void 0:j.className,{[`${T}-small`]:"small"===R,[`${T}-loading`]:s,[`${T}-rtl`]:"rtl"===z},d,f,H,L),G=Object.assign(Object.assign({},null==j?void 0:j.style),b);return B(t.createElement(g.default,{component:"Switch",disabled:P},t.createElement(u,Object.assign({},I,{checked:x,onChange:(...e)=>{O(e[0]),null==w||w.apply(void 0,e)},prefixCls:T,className:q,style:G,disabled:P,ref:i,loadingIcon:M}))))});C.__ANT_SWITCH=!0,e.s(["Switch",0,C],790848)},38243,908286,e=>{"use strict";e.i(247167);var t=e.i(271645),n=e.i(343794),r=e.i(876556);function i(e){return["small","middle","large"].includes(e)}function a(e){return!!e&&"number"==typeof e&&!Number.isNaN(e)}e.s(["isPresetSize",()=>i,"isValidGapNumber",()=>a],908286);var l=e.i(242064),o=e.i(249616),c=e.i(372409),s=e.i(246422);let d=(0,s.genStyleHooks)(["Space","Addon"],e=>[(e=>{let{componentCls:t,borderRadius:n,paddingSM:r,colorBorder:i,paddingXS:a,fontSizeLG:l,fontSizeSM:o,borderRadiusLG:s,borderRadiusSM:d,colorBgContainerDisabled:u,lineWidth:g}=e;return{[t]:[{display:"inline-flex",alignItems:"center",gap:0,paddingInline:r,margin:0,background:u,borderWidth:g,borderStyle:"solid",borderColor:i,borderRadius:n,"&-large":{fontSize:l,borderRadius:s},"&-small":{paddingInline:a,borderRadius:d,fontSize:o},"&-compact-last-item":{borderEndStartRadius:0,borderStartStartRadius:0},"&-compact-first-item":{borderEndEndRadius:0,borderStartEndRadius:0},"&-compact-item:not(:first-child):not(:last-child)":{borderRadius:0},"&-compact-item:not(:last-child)":{borderInlineEndWidth:0}},(0,c.genCompactItemStyle)(e,{focus:!1})]}})(e)]);var u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let g=t.default.forwardRef((e,r)=>{let{className:i,children:a,style:c,prefixCls:s}=e,g=u(e,["className","children","style","prefixCls"]),{getPrefixCls:m,direction:p}=t.default.useContext(l.ConfigContext),h=m("space-addon",s),[f,b,$]=d(h),{compactItemClassnames:y,compactSize:S}=(0,o.useCompactItemContext)(h,p),v=(0,n.default)(h,b,y,$,{[`${h}-${S}`]:S},i);return f(t.default.createElement("div",Object.assign({ref:r,className:v,style:c},g),a))}),m=t.default.createContext({latestIndex:0}),p=m.Provider,h=({className:e,index:n,children:r,split:i,style:a})=>{let{latestIndex:l}=t.useContext(m);return null==r?null:t.createElement(t.Fragment,null,t.createElement("div",{className:e,style:a},r),n{let t=(0,f.mergeToken)(e,{spaceGapSmallSize:e.paddingXS,spaceGapMiddleSize:e.padding,spaceGapLargeSize:e.paddingLG});return[(e=>{let{componentCls:t,antCls:n}=e;return{[t]:{display:"inline-flex","&-rtl":{direction:"rtl"},"&-vertical":{flexDirection:"column"},"&-align":{flexDirection:"column","&-center":{alignItems:"center"},"&-start":{alignItems:"flex-start"},"&-end":{alignItems:"flex-end"},"&-baseline":{alignItems:"baseline"}},[`${t}-item:empty`]:{display:"none"},[`${t}-item > ${n}-badge-not-a-wrapper:only-child`]:{display:"block"}}}})(t),(e=>{let{componentCls:t}=e;return{[t]:{"&-gap-row-small":{rowGap:e.spaceGapSmallSize},"&-gap-row-middle":{rowGap:e.spaceGapMiddleSize},"&-gap-row-large":{rowGap:e.spaceGapLargeSize},"&-gap-col-small":{columnGap:e.spaceGapSmallSize},"&-gap-col-middle":{columnGap:e.spaceGapMiddleSize},"&-gap-col-large":{columnGap:e.spaceGapLargeSize}}}})(t)]},()=>({}),{resetStyle:!1});var $=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};let y=t.forwardRef((e,o)=>{var c;let{getPrefixCls:s,direction:d,size:u,className:g,style:m,classNames:f,styles:y}=(0,l.useComponentConfig)("space"),{size:S=null!=u?u:"small",align:v,className:k,rootClassName:C,children:w,direction:I="horizontal",prefixCls:x,split:O,style:E,wrap:z=!1,classNames:j,styles:N}=e,P=$(e,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[T,M]=Array.isArray(S)?S:[S,S],B=i(M),H=i(T),L=a(M),R=a(T),q=(0,r.default)(w,{keepEmpty:!0}),G=void 0===v&&"horizontal"===I?"center":v,A=s("space",x),[W,D,X]=b(A),F=(0,n.default)(A,g,D,`${A}-${I}`,{[`${A}-rtl`]:"rtl"===d,[`${A}-align-${G}`]:G,[`${A}-gap-row-${M}`]:B,[`${A}-gap-col-${T}`]:H},k,C,X),K=(0,n.default)(`${A}-item`,null!=(c=null==j?void 0:j.item)?c:f.item),U=Object.assign(Object.assign({},y.item),null==N?void 0:N.item),V=q.map((e,n)=>{let r=(null==e?void 0:e.key)||`${K}-${n}`;return t.createElement(h,{className:K,key:r,index:n,split:O,style:U},e)}),Q=t.useMemo(()=>({latestIndex:q.reduce((e,t,n)=>null!=t?n:e,0)}),[q]);if(0===q.length)return null;let _={};return z&&(_.flexWrap="wrap"),!H&&R&&(_.columnGap=T),!B&&L&&(_.rowGap=M),W(t.createElement("div",Object.assign({ref:o,className:F,style:Object.assign(Object.assign(Object.assign({},_),m),E)},P),t.createElement(p,{value:Q},V)))});y.Compact=o.default,y.Addon=g,e.s(["default",0,y],38243)},770914,e=>{"use strict";var t=e.i(38243);e.s(["Space",()=>t.default])},292639,e=>{"use strict";var t=e.i(764205),n=e.i(266027);let r=(0,e.i(243652).createQueryKeys)("uiSettings");e.s(["useUISettings",0,()=>(0,n.useQuery)({queryKey:r.list({}),queryFn:async()=>await (0,t.getUiSettings)(),staleTime:36e5,gcTime:36e5})])},250980,e=>{"use strict";var t=e.i(271645);let n=t.forwardRef(function(e,n){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:n},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["PlusCircleIcon",0,n],250980)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/052aaa8d01e02cd3.js b/litellm/proxy/_experimental/out/_next/static/chunks/052aaa8d01e02cd3.js deleted file mode 100644 index b20ca34844..0000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/052aaa8d01e02cd3.js +++ /dev/null @@ -1 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,519756,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"upload",theme:"outlined"};var s=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(s.default,(0,t.default)({},e,{ref:n,icon:i}))});e.s(["UploadOutlined",0,n],519756)},981339,e=>{"use strict";var t=e.i(185793);e.s(["Skeleton",()=>t.default])},500330,e=>{"use strict";var t=e.i(727749);function r(e,t){let r=structuredClone(e);for(let[e,i]of Object.entries(t))e in r&&(r[e]=i);return r}let i=(e,t=0,r=!1,i=!0)=>{if(null==e||!Number.isFinite(e)||0===e&&!i)return"-";let s={minimumFractionDigits:t,maximumFractionDigits:t};if(!r)return e.toLocaleString("en-US",s);let n=e<0?"-":"",a=Math.abs(e),l=a,o="";return a>=1e6?(l=a/1e6,o="M"):a>=1e3&&(l=a/1e3,o="K"),`${n}${l.toLocaleString("en-US",s)}${o}`},s=async(e,r="Copied to clipboard")=>{if(!e)return!1;if(!navigator||!navigator.clipboard||!navigator.clipboard.writeText)return n(e,r);try{return await navigator.clipboard.writeText(e),t.default.success(r),!0}catch(t){return console.error("Clipboard API failed: ",t),n(e,r)}},n=(e,r)=>{try{let i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.left="-999999px",i.style.top="-999999px",i.setAttribute("readonly",""),document.body.appendChild(i),i.focus(),i.select();let s=document.execCommand("copy");if(document.body.removeChild(i),s)return t.default.success(r),!0;throw Error("execCommand failed")}catch(e){return t.default.fromBackend("Failed to copy to clipboard"),console.error("Failed to copy: ",e),!1}};e.s(["copyToClipboard",0,s,"formatNumberWithCommas",0,i,"getSpendString",0,(e,t=6)=>{if(null==e||!Number.isFinite(e)||0===e)return"-";let r=i(e,t,!1,!1);if(0===Number(r.replace(/,/g,""))){let e=(1/10**t).toFixed(t);return`< $${e}`}return`$${r}`},"updateExistingKeys",()=>r])},663435,152473,e=>{"use strict";var t=e.i(843476),r=e.i(271645),i=e.i(199133),s=e.i(898586),n=e.i(56456);let a={enabled:!0,leading:!1,trailing:!0,wait:0,onExecute:()=>{}};class l{constructor(e,t){this.fn=e,this._canLeadingExecute=!0,this._isPending=!1,this._executionCount=0,this._options={...a,...t}}setOptions(e){return this._options={...this._options,...e},this._options.enabled||(this._isPending=!1),this._options}getOptions(){return this._options}maybeExecute(...e){this._options.leading&&this._canLeadingExecute&&(this.executeFunction(...e),this._canLeadingExecute=!1),(this._options.leading||this._options.trailing)&&(this._isPending=!0),this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=setTimeout(()=>{this._canLeadingExecute=!0,this._isPending=!1,this._options.trailing&&this.executeFunction(...e)},this._options.wait)}executeFunction(...e){this._options.enabled&&(this.fn(...e),this._executionCount++,this._options.onExecute(this))}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._canLeadingExecute=!0,this._isPending=!1)}getExecutionCount(){return this._executionCount}getIsPending(){return this._options.enabled&&this._isPending}}function o(e,t){let[i,s]=(0,r.useState)(e),n=function(e,t){let[i]=(0,r.useState)(()=>{var r;return Object.getOwnPropertyNames(Object.getPrototypeOf(r=new l(e,t))).filter(e=>"function"==typeof r[e]).reduce((e,t)=>{let i=r[t];return"function"==typeof i&&(e[t]=i.bind(r)),e},{})});return i.setOptions(t),i}(s,t);return[i,n.maybeExecute,n]}e.s(["useDebouncedState",()=>o],152473);var d=e.i(785242);let{Text:c}=s.Typography;e.s(["default",0,({value:e,onChange:s,onTeamSelect:a,disabled:l,organizationId:u,pageSize:h=20})=>{let[m,f]=(0,r.useState)(""),[p,x]=o("",{wait:300}),{data:g,fetchNextPage:y,hasNextPage:_,isFetchingNextPage:b,isLoading:v}=(0,d.useInfiniteTeams)(h,p||void 0,u),j=(0,r.useMemo)(()=>{if(!g?.pages)return[];let e=new Set,t=[];for(let r of g.pages)for(let i of r.teams)e.has(i.team_id)||(e.add(i.team_id),t.push(i));return t},[g]);return(0,t.jsx)(i.Select,{showSearch:!0,placeholder:"Search or select a team",value:e||void 0,onChange:e=>{s?.(e??""),a&&a(e?j.find(t=>t.team_id===e)??null:null)},disabled:l,allowClear:!0,filterOption:!1,onSearch:e=>{f(e),x(e)},searchValue:m,onPopupScroll:e=>{let t=e.currentTarget;(t.scrollTop+t.clientHeight)/t.scrollHeight>=.8&&_&&!b&&y()},loading:v,notFoundContent:v?(0,t.jsx)(n.LoadingOutlined,{spin:!0}):"No teams found","data-testid":"team-dropdown",popupRender:e=>(0,t.jsxs)(t.Fragment,{children:[e,b&&(0,t.jsx)("div",{style:{textAlign:"center",padding:8},children:(0,t.jsx)(n.LoadingOutlined,{spin:!0})})]}),children:j.map(e=>(0,t.jsxs)(i.Select.Option,{value:e.team_id,children:[(0,t.jsx)("span",{className:"font-medium",children:e.team_alias})," ",(0,t.jsxs)(c,{type:"secondary",children:["(",e.team_id,")"]})]},e.team_id))})}],663435)},743151,(e,t,r)=>{"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.CopyToClipboard=void 0;var s=l(e.r(271645)),n=l(e.r(844343)),a=["text","onCopy","options","children"];function l(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function d(e){for(var t=1;t=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}(e,a),i=s.default.Children.only(t);return s.default.cloneElement(i,d(d({},r),{},{onClick:this.onClick}))}}],function(e,t){for(var r=0;r{"use strict";var i=e.r(743151).CopyToClipboard;i.CopyToClipboard=i,t.exports=i},59935,(e,t,r)=>{var i;let s;e.e,i=function e(){var t,r="u">typeof self?self:"u">typeof window?window:void 0!==r?r:{},i=!r.document&&!!r.postMessage,s=r.IS_PAPA_WORKER||!1,n={},a=0,l={};function o(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(e){var t=_(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new m(t),(this._handle.streamer=this)._config=t}).call(this,e),this.parseChunk=function(e,t){var i=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview,s)r.postMessage({results:n,workerId:l.WORKER_ID,finished:i});else if(v(this._config.chunk)&&!t){if(this._config.chunk(n,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=n=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(n.data),this._completeResults.errors=this._completeResults.errors.concat(n.errors),this._completeResults.meta=n.meta),this._completed||!i||!v(this._config.complete)||n&&n.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),i||n&&n.meta.paused||this._nextChunk(),n}this._halted=!0},this._sendError=function(e){v(this._config.error)?this._config.error(e):s&&this._config.error&&r.postMessage({workerId:l.WORKER_ID,error:e,finished:!1})}}function d(e){var t;(e=e||{}).chunkSize||(e.chunkSize=l.RemoteChunkSize),o.call(this,e),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),i||(t.onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var e,r,s=this._config.downloadRequestHeaders;for(r in s)t.setRequestHeader(r,s[r])}this._config.chunkSize&&(e=this._start+this._config.chunkSize-1,t.setRequestHeader("Range","bytes="+this._start+"-"+e));try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}i&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){let e;4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize||t.responseText.length,this._finished=!this._config.chunkSize||this._start>=(null!==(e=(e=t).getResponseHeader("Content-Range"))?parseInt(e.substring(e.lastIndexOf("/")+1)):-1),this.parseChunk(t.responseText)))},this._chunkError=function(e){e=t.statusText||e,this._sendError(Error(e))}}function c(e){(e=e||{}).chunkSize||(e.chunkSize=l.LocalChunkSize),o.call(this,e);var t,r,i="u">typeof FileReader;this.stream=function(e){this._input=e,r=e.slice||e.webkitSlice||e.mozSlice,i?((t=new FileReader).onload=b(this._chunkLoaded,this),t.onerror=b(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function u(e){var t;o.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){var e,r;if(!this._finished)return t=(e=this._config.chunkSize)?(r=t.substring(0,e),t.substring(e)):(r=t,""),this._finished=!t,this.parseChunk(r)}}function h(e){o.call(this,e=e||{});var t=[],r=!0,i=!1;this.pause=function(){o.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){o.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){i&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):r=!0},this._streamData=b(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=b(function(e){this._streamCleanUp(),this._sendError(e)},this),this._streamEnd=b(function(){this._streamCleanUp(),i=!0,this._streamData("")},this),this._streamCleanUp=b(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function m(e){var t,r,i,s,n=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,a=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,o=this,d=0,c=0,u=!1,h=!1,m=[],x={data:[],errors:[],meta:{}};function g(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function y(){if(x&&i&&(j("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+l.DefaultDelimiter+"'"),i=!1),e.skipEmptyLines&&(x.data=x.data.filter(function(e){return!g(e)})),b()){if(x)if(Array.isArray(x.data[0])){for(var t,r=0;b()&&r(e.dynamicTypingFunction&&void 0===e.dynamicTyping[t]&&(e.dynamicTyping[t]=e.dynamicTypingFunction(t)),!0===(e.dynamicTyping[t]||e.dynamicTyping))?"true"===r||"TRUE"===r||"false"!==r&&"FALSE"!==r&&((e=>{if(n.test(e)&&-0x20000000000000<(e=parseFloat(e))&&e<0x20000000000000)return 1})(r)?parseFloat(r):a.test(r)?new Date(r):""===r?null:r):r)(l=e.header?s>=m.length?"__parsed_extra":m[s]:l,o=e.transform?e.transform(o,l):o);"__parsed_extra"===l?(i[l]=i[l]||[],i[l].push(o)):i[l]=o}return e.header&&(s>m.length?j("FieldMismatch","TooManyFields","Too many fields: expected "+m.length+" fields but parsed "+s,c+r):se.preview?r.abort():(x.data=x.data[0],s(x,o))))}),this.parse=function(s,n,a){var o=e.quoteChar||'"',o=(e.newline||(e.newline=this.guessLineEndings(s,o)),i=!1,e.delimiter?v(e.delimiter)&&(e.delimiter=e.delimiter(s),x.meta.delimiter=e.delimiter):((o=((t,r,i,s,n)=>{var a,o,d,c;n=n||[","," ","|",";",l.RECORD_SEP,l.UNIT_SEP];for(var u=0;u=r.length/2?"\r\n":"\r"}}function f(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function p(e){var t=(e=e||{}).delimiter,r=e.newline,i=e.comments,s=e.step,n=e.preview,a=e.fastMode,o=null,d=!1,c=null==e.quoteChar?'"':e.quoteChar,u=c;if(void 0!==e.escapeChar&&(u=e.escapeChar),("string"!=typeof t||-1=n)return D(!0);break}C.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:w.length,index:h}),R++}}else if(i&&0===k.length&&l.substring(h,h+b)===i){if(-1===I)return D();h=I+_,I=l.indexOf(r,h),E=l.indexOf(t,h)}else if(-1!==E&&(E=n)return D(!0)}return A();function F(e){w.push(e),S=h}function P(e){return -1!==e&&(e=l.substring(R+1,e))&&""===e.trim()?e.length:0}function A(e){return x||(void 0===e&&(e=l.substring(h)),k.push(e),h=g,F(k),j&&M()),D()}function U(e){h=e,F(k),k=[],I=l.indexOf(r,h)}function D(i){if(e.header&&!p&&w.length&&!d){var s=w[0],n=Object.create(null),a=new Set(s);let t=!1;for(let r=0;r{if("object"==typeof t){if("string"!=typeof t.delimiter||l.BAD_DELIMITERS.filter(function(e){return -1!==t.delimiter.indexOf(e)}).length||(s=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(r=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(d=t.skipEmptyLines),"string"==typeof t.newline&&(n=t.newline),"string"==typeof t.quoteChar&&(a=t.quoteChar),"boolean"==typeof t.header&&(i=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(o=t.escapeChar+a),t.escapeFormulae instanceof RegExp?u=t.escapeFormulae:"boolean"==typeof t.escapeFormulae&&t.escapeFormulae&&(u=/^[=+\-@\t\r].*$/)}})(),RegExp(f(a),"g"));if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return m(null,e,d);if("object"==typeof e[0])return m(c||Object.keys(e[0]),e,d)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),m(e.fields||[],e.data||[],d);throw Error("Unable to serialize unrecognized input");function m(e,t,r){var a="",l=("string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t)),Array.isArray(e)&&0{for(var r=0;r{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z"}}]},name:"warning",theme:"outlined"};var s=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(s.default,(0,t.default)({},e,{ref:n,icon:i}))});e.s(["WarningOutlined",0,n],285027)},213205,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let i={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M678.3 642.4c24.2-13 51.9-20.4 81.4-20.4h.1c3 0 4.4-3.6 2.2-5.6a371.67 371.67 0 00-103.7-65.8c-.4-.2-.8-.3-1.2-.5C719.2 505 759.6 431.7 759.6 349c0-137-110.8-248-247.5-248S264.7 212 264.7 349c0 82.7 40.4 156 102.6 201.1-.4.2-.8.3-1.2.5-44.7 18.9-84.8 46-119.3 80.6a373.42 373.42 0 00-80.4 119.5A373.6 373.6 0 00137 888.8a8 8 0 008 8.2h59.9c4.3 0 7.9-3.5 8-7.8 2-77.2 32.9-149.5 87.6-204.3C357 628.2 432.2 597 512.2 597c56.7 0 111.1 15.7 158 45.1a8.1 8.1 0 008.1.3zM512.2 521c-45.8 0-88.9-17.9-121.4-50.4A171.2 171.2 0 01340.5 349c0-45.9 17.9-89.1 50.3-121.6S466.3 177 512.2 177s88.9 17.9 121.4 50.4A171.2 171.2 0 01683.9 349c0 45.9-17.9 89.1-50.3 121.6C601.1 503.1 558 521 512.2 521zM880 759h-84v-84c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v84h-84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h84v84c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-84h84c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z"}}]},name:"user-add",theme:"outlined"};var s=e.i(9583),n=r.forwardRef(function(e,n){return r.createElement(s.default,(0,t.default)({},e,{ref:n,icon:i}))});e.s(["UserAddOutlined",0,n],213205)},355619,e=>{"use strict";var t=e.i(764205);let r=async(e,r,i)=>{try{if(null===e||null===r)return;if(null!==i){let s=(await (0,t.modelAvailableCall)(i,e,r,!0,null,!0)).data.map(e=>e.id),n=[],a=[];return s.forEach(e=>{e.endsWith("/*")?n.push(e):a.push(e)}),[...n,...a]}}catch(e){console.error("Error fetching user models:",e)}};e.s(["fetchAvailableModelsForTeamOrKey",0,r,"getModelDisplayName",0,e=>{if("all-proxy-models"===e)return"All Proxy Models";if(e.endsWith("/*")){let t=e.replace("/*","");return`All ${t} models`}return e},"unfurlWildcardModelsInList",0,(e,t)=>{let r=[],i=[];return console.log("teamModels",e),console.log("allModels",t),e.forEach(e=>{if(e.endsWith("/*")){let s=e.replace("/*",""),n=t.filter(e=>e.startsWith(s+"/"));i.push(...n),r.push(e)}else i.push(e)}),[...r,...i].filter((e,t,r)=>r.indexOf(e)===t)}])},860585,e=>{"use strict";var t=e.i(843476),r=e.i(199133);let{Option:i}=r.Select;e.s(["default",0,({value:e,onChange:s,className:n="",style:a={}})=>(0,t.jsxs)(r.Select,{style:{width:"100%",...a},value:e||void 0,onChange:s,className:n,placeholder:"n/a",allowClear:!0,children:[(0,t.jsx)(i,{value:"1h",children:"hourly"}),(0,t.jsx)(i,{value:"24h",children:"daily"}),(0,t.jsx)(i,{value:"7d",children:"weekly"}),(0,t.jsx)(i,{value:"30d",children:"monthly"})]}),"getBudgetDurationLabel",0,e=>e?({"1h":"hourly","24h":"daily","7d":"weekly","30d":"monthly"})[e]||e:"Not set"])},447082,e=>{"use strict";var t=e.i(843476),r=e.i(271645),i=e.i(599724),s=e.i(464571),n=e.i(212931),a=e.i(291542),l=e.i(515831),o=e.i(898586),d=e.i(519756),c=e.i(737434),u=e.i(285027),h=e.i(993914),m=e.i(955135);e.i(247167);var f=e.i(931067);let p={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM472 744a40 40 0 1080 0 40 40 0 10-80 0zm16-104h48c4.4 0 8-3.6 8-8V448c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v184c0 4.4 3.6 8 8 8z"}}]},name:"file-exclamation",theme:"outlined"};var x=e.i(9583),g=r.forwardRef(function(e,t){return r.createElement(x.default,(0,f.default)({},e,{ref:t,icon:p}))}),y=e.i(764205),_=e.i(59935),b=e.i(220508),v=e.i(964306);let j=r.forwardRef(function(e,t){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:t},e),r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"}))});var w=e.i(237016),C=e.i(727749);e.s(["default",0,({accessToken:e,teams:f,possibleUIRoles:p,onUsersCreated:x})=>{let[k,S]=(0,r.useState)(!1),[N,O]=(0,r.useState)([]),[E,I]=(0,r.useState)(!1),[T,R]=(0,r.useState)(null),[L,F]=(0,r.useState)(null),[P,A]=(0,r.useState)(null),[U,D]=(0,r.useState)(null),[M,z]=(0,r.useState)(null),[B,V]=(0,r.useState)("http://localhost:4000");(0,r.useEffect)(()=>{(async()=>{try{let t=await (0,y.getProxyUISettings)(e);z(t)}catch(e){console.error("Error fetching UI settings:",e)}})(),V(new URL("/",window.location.href).toString())},[e]);let $=async()=>{I(!0);let t=N.map(e=>({...e,status:"pending"}));O(t);let r=!1;for(let i=0;ie.trim()).filter(Boolean),0===t.teams.length&&delete t.teams),s.models&&"string"==typeof s.models&&""!==s.models.trim()&&(t.models=s.models.split(",").map(e=>e.trim()).filter(Boolean),0===t.models.length&&delete t.models),s.max_budget&&""!==s.max_budget.toString().trim()){let e=parseFloat(s.max_budget.toString());!isNaN(e)&&e>0&&(t.max_budget=e)}s.budget_duration&&""!==s.budget_duration.trim()&&(t.budget_duration=s.budget_duration.trim()),s.metadata&&"string"==typeof s.metadata&&""!==s.metadata.trim()&&(t.metadata=s.metadata.trim()),console.log("Sending user data:",t);let n=await (0,y.userCreateCall)(e,null,t);if(console.log("Full response:",n),n&&(n.key||n.user_id)){r=!0,console.log("Success case triggered");let t=n.data?.user_id||n.user_id;try{if(M?.SSO_ENABLED){let e=new URL("/ui",B).toString();O(t=>t.map((t,r)=>r===i?{...t,status:"success",key:n.key||n.user_id,invitation_link:e}:t))}else{let r=await (0,y.invitationCreateCall)(e,t),s=new URL(`/ui?invitation_id=${r.id}`,B).toString();O(e=>e.map((e,t)=>t===i?{...e,status:"success",key:n.key||n.user_id,invitation_link:s}:e))}}catch(e){console.error("Error creating invitation:",e),O(e=>e.map((e,t)=>t===i?{...e,status:"success",key:n.key||n.user_id,error:"User created but failed to generate invitation link"}:e))}}else{console.log("Error case triggered");let e=n?.error||"Failed to create user";console.log("Error message:",e),O(t=>t.map((t,r)=>r===i?{...t,status:"failed",error:e}:t))}}catch(t){console.error("Caught error:",t);let e=t?.response?.data?.error||t?.message||String(t);O(t=>t.map((t,r)=>r===i?{...t,status:"failed",error:e}:t))}}I(!1),r&&x&&x()},q=[{title:"Row",dataIndex:"rowNumber",key:"rowNumber",width:80},{title:"Email",dataIndex:"user_email",key:"user_email"},{title:"Role",dataIndex:"user_role",key:"user_role"},{title:"Teams",dataIndex:"teams",key:"teams"},{title:"Budget",dataIndex:"max_budget",key:"max_budget"},{title:"Status",key:"status",render:(e,r)=>r.isValid?r.status&&"pending"!==r.status?"success"===r.status?(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(b.CheckCircleIcon,{className:"h-5 w-5 text-green-500 mr-2"}),(0,t.jsx)("span",{className:"text-green-500",children:"Success"})]}),r.invitation_link&&(0,t.jsx)("div",{className:"mt-1",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("span",{className:"text-xs text-gray-500 truncate max-w-[150px]",children:r.invitation_link}),(0,t.jsx)(w.CopyToClipboard,{text:r.invitation_link,onCopy:()=>C.default.success("Invitation link copied!"),children:(0,t.jsx)("button",{className:"ml-1 text-blue-500 text-xs hover:text-blue-700",children:"Copy"})})]})})]}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(v.XCircleIcon,{className:"h-5 w-5 text-red-500 mr-2"}),(0,t.jsx)("span",{className:"text-red-500",children:"Failed"})]}),r.error&&(0,t.jsx)("span",{className:"text-sm text-red-500 ml-7",children:JSON.stringify(r.error)})]}):(0,t.jsx)("span",{className:"text-gray-500",children:"Pending"}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(v.XCircleIcon,{className:"h-5 w-5 text-red-500 mr-2"}),(0,t.jsx)("span",{className:"text-red-500",children:"Invalid"})]}),r.error&&(0,t.jsx)("span",{className:"text-sm text-red-500 ml-7",children:r.error})]})}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Button,{type:"primary",className:"mb-0",onClick:()=>S(!0),children:"+ Bulk Invite Users"}),(0,t.jsx)(n.Modal,{title:"Bulk Invite Users",open:k,width:800,onCancel:()=>S(!1),bodyStyle:{maxHeight:"70vh",overflow:"auto"},footer:null,children:(0,t.jsx)("div",{className:"flex flex-col",children:0===N.length?(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center mb-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-blue-500 text-white flex items-center justify-center mr-3",children:"1"}),(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Download and fill the template"})]}),(0,t.jsxs)("div",{className:"ml-11 mb-6",children:[(0,t.jsx)("p",{className:"mb-4",children:"Add multiple users at once by following these steps:"}),(0,t.jsxs)("ol",{className:"list-decimal list-inside space-y-2 ml-2 mb-4",children:[(0,t.jsx)("li",{children:"Download our CSV template"}),(0,t.jsx)("li",{children:"Add your users' information to the spreadsheet"}),(0,t.jsx)("li",{children:"Save the file and upload it here"}),(0,t.jsx)("li",{children:"After creation, download the results file containing the Virtual Keys for each user"})]}),(0,t.jsxs)("div",{className:"bg-gray-50 p-4 rounded-md border border-gray-200 mb-4",children:[(0,t.jsx)("h4",{className:"font-medium mb-2",children:"Template Column Names"}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-red-500 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"user_email"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:"User's email address (required)"})]})]}),(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-red-500 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"user_role"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:'User\'s role (one of: "proxy_admin", "proxy_admin_viewer", "internal_user", "internal_user_viewer")'})]})]}),(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-300 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"teams"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:'Comma-separated team IDs (e.g., "team-1,team-2")'})]})]}),(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-300 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"max_budget"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:'Maximum budget as a number (e.g., "100")'})]})]}),(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-300 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"budget_duration"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:'Budget reset period (e.g., "30d", "1mo")'})]})]}),(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"w-3 h-3 rounded-full bg-gray-300 mt-1.5 mr-2 flex-shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"models"}),(0,t.jsx)("p",{className:"text-sm text-gray-600",children:'Comma-separated allowed models (e.g., "gpt-3.5-turbo,gpt-4")'})]})]})]})]}),(0,t.jsx)(s.Button,{type:"primary",size:"large",className:"w-full md:w-auto",icon:(0,t.jsx)(c.DownloadOutlined,{}),children:"Download CSV Template"})]}),(0,t.jsxs)("div",{className:"flex items-center mb-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-blue-500 text-white flex items-center justify-center mr-3",children:"2"}),(0,t.jsx)("h3",{className:"text-lg font-medium",children:"Upload your completed CSV"})]}),(0,t.jsxs)("div",{className:"ml-11",children:[U?(0,t.jsxs)("div",{className:`mb-4 p-4 rounded-md border ${P?"bg-red-50 border-red-200":"bg-blue-50 border-blue-200"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center",children:[P?(0,t.jsx)(g,{className:"text-red-500 text-xl mr-3"}):(0,t.jsx)(h.FileTextOutlined,{className:"text-blue-500 text-xl mr-3"}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Typography.Text,{strong:!0,className:P?"text-red-800":"text-blue-800",children:U.name}),(0,t.jsxs)(o.Typography.Text,{className:`block text-xs ${P?"text-red-600":"text-blue-600"}`,children:[(U.size/1024).toFixed(1)," KB • ",new Date().toLocaleDateString()]})]})]}),(0,t.jsx)(s.Button,{size:"small",onClick:()=>{D(null),O([]),R(null),F(null),A(null)},className:"flex items-center",icon:(0,t.jsx)(m.DeleteOutlined,{}),children:"Remove"})]}),P?(0,t.jsxs)("div",{className:"mt-3 text-red-600 text-sm flex items-start",children:[(0,t.jsx)(u.WarningOutlined,{className:"mr-2 mt-0.5"}),(0,t.jsx)("span",{children:P})]}):!L&&(0,t.jsxs)("div",{className:"mt-3 flex items-center",children:[(0,t.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-1.5",children:(0,t.jsx)("div",{className:"bg-blue-500 h-1.5 rounded-full w-full animate-pulse"})}),(0,t.jsx)("span",{className:"ml-2 text-xs text-blue-600",children:"Processing..."})]})]}):(0,t.jsx)(l.Upload,{beforeUpload:e=>((R(null),F(null),A(null),D(e),"text/csv"===e.type||e.name.endsWith(".csv"))?e.size>5242880?A(`File is too large (${(e.size/1048576).toFixed(1)} MB). Please upload a CSV file smaller than 5MB.`):_.default.parse(e,{complete:e=>{if(!e.data||0===e.data.length){F("The CSV file appears to be empty. Please upload a file with data."),O([]);return}if(1===e.data.length){F("The CSV file only contains headers but no user data. Please add user data to your CSV."),O([]);return}let t=e.data[0];if(0===t.length||1===t.length&&""===t[0]){F("The CSV file doesn't contain any column headers. Please make sure your CSV has headers."),O([]);return}let r=["user_email","user_role"].filter(e=>!t.includes(e));if(r.length>0){F(`Your CSV is missing these required columns: ${r.join(", ")}. Please add these columns to your CSV file.`),O([]);return}try{let r=e.data.slice(1).map((e,r)=>{if(0===e.length||1===e.length&&""===e[0])return null;if(e.length=parseFloat(i.max_budget.toString())&&s.push("Max budget must be greater than 0")),i.budget_duration&&!i.budget_duration.match(/^\d+[dhmwy]$|^\d+mo$/)&&s.push(`Invalid budget duration format "${i.budget_duration}". Use format like "30d", "1mo", "2w", "6h"`),i.teams&&"string"==typeof i.teams&&f&&f.length>0){let e=f.map(e=>e.team_id),t=i.teams.split(",").map(e=>e.trim()).filter(t=>!e.includes(t));t.length>0&&s.push(`Unknown team(s): ${t.join(", ")}`)}return s.length>0&&(i.isValid=!1,i.error=s.join(", ")),i}).filter(Boolean),i=r.filter(e=>e.isValid);O(r),0===r.length?F("No valid data rows found in the CSV file. Please check your file format."):0===i.length?R("No valid users found in the CSV. Please check the errors below and fix your CSV file."):i.length{R(`Failed to parse CSV file: ${e.message}`),O([])},header:!1}):(A(`Invalid file type: ${e.name}. Please upload a CSV file (.csv extension).`),C.default.fromBackend("Invalid file type. Please upload a CSV file.")),!1),accept:".csv",maxCount:1,showUploadList:!1,children:(0,t.jsxs)("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-8 text-center hover:border-blue-500 transition-colors cursor-pointer",children:[(0,t.jsx)(d.UploadOutlined,{className:"text-3xl text-gray-400 mb-2"}),(0,t.jsx)("p",{className:"mb-1",children:"Drag and drop your CSV file here"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 mb-3",children:"or"}),(0,t.jsx)(s.Button,{size:"small",children:"Browse files"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 mt-4",children:"Only CSV files (.csv) are supported"})]})}),L&&(0,t.jsx)("div",{className:"mb-4 p-4 bg-yellow-50 border border-yellow-200 rounded-md",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)(j,{className:"h-5 w-5 text-yellow-500 mr-2 mt-0.5"}),(0,t.jsxs)("div",{children:[(0,t.jsx)(o.Typography.Text,{strong:!0,className:"text-yellow-800",children:"CSV Structure Error"}),(0,t.jsx)(o.Typography.Paragraph,{className:"text-yellow-700 mt-1 mb-0",children:L}),(0,t.jsx)(o.Typography.Paragraph,{className:"text-yellow-700 mt-2 mb-0",children:"Please download our template and ensure your CSV follows the required format."})]})]})})]})]}):(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center mb-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-full bg-blue-500 text-white flex items-center justify-center mr-3",children:"3"}),(0,t.jsx)("h3",{className:"text-lg font-medium",children:N.some(e=>"success"===e.status||"failed"===e.status)?"User Creation Results":"Review and create users"})]}),T&&(0,t.jsx)("div",{className:"ml-11 mb-4 p-4 bg-red-50 border border-red-200 rounded-md",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)(u.WarningOutlined,{className:"text-red-500 mr-2 mt-1"}),(0,t.jsxs)("div",{children:[(0,t.jsx)(i.Text,{className:"text-red-600 font-medium",children:T}),N.some(e=>!e.isValid)&&(0,t.jsxs)("ul",{className:"mt-2 list-disc list-inside text-red-600 text-sm",children:[(0,t.jsx)("li",{children:"Check the table below for specific errors in each row"}),(0,t.jsx)("li",{children:"Common issues include invalid email formats, missing required fields, or incorrect role values"}),(0,t.jsx)("li",{children:"Fix these issues in your CSV file and upload again"})]})]})]})}),(0,t.jsxs)("div",{className:"ml-11",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,t.jsx)("div",{className:"flex items-center",children:N.some(e=>"success"===e.status||"failed"===e.status)?(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(i.Text,{className:"text-lg font-medium mr-3",children:"Creation Summary"}),(0,t.jsxs)(i.Text,{className:"text-sm bg-green-100 text-green-800 px-2 py-1 rounded mr-2",children:[N.filter(e=>"success"===e.status).length," Successful"]}),N.some(e=>"failed"===e.status)&&(0,t.jsxs)(i.Text,{className:"text-sm bg-red-100 text-red-800 px-2 py-1 rounded",children:[N.filter(e=>"failed"===e.status).length," Failed"]})]}):(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(i.Text,{className:"text-lg font-medium mr-3",children:"User Preview"}),(0,t.jsxs)(i.Text,{className:"text-sm bg-blue-100 text-blue-800 px-2 py-1 rounded",children:[N.filter(e=>e.isValid).length," of ",N.length," users valid"]})]})}),!N.some(e=>"success"===e.status||"failed"===e.status)&&(0,t.jsxs)("div",{className:"flex space-x-3",children:[(0,t.jsx)(s.Button,{onClick:()=>{O([]),R(null)},children:"Back"}),(0,t.jsx)(s.Button,{type:"primary",onClick:$,disabled:0===N.filter(e=>e.isValid).length||E,children:E?"Creating...":`Create ${N.filter(e=>e.isValid).length} Users`})]})]}),N.some(e=>"success"===e.status)&&(0,t.jsx)("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-md",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"mr-3 mt-1",children:(0,t.jsx)(b.CheckCircleIcon,{className:"h-5 w-5 text-blue-500"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)(i.Text,{className:"font-medium text-blue-800",children:"User creation complete"}),(0,t.jsxs)(i.Text,{className:"block text-sm text-blue-700 mt-1",children:[(0,t.jsx)("span",{className:"font-medium",children:"Next step:"})," Download the credentials file containing Virtual Keys and invitation links. Users will need these Virtual Keys to make LLM requests through LiteLLM."]})]})]})}),(0,t.jsx)(a.Table,{dataSource:N,columns:q,size:"small",pagination:{pageSize:5},scroll:{y:300},rowClassName:e=>e.isValid?"":"bg-red-50"}),!N.some(e=>"success"===e.status||"failed"===e.status)&&(0,t.jsxs)("div",{className:"flex justify-end mt-4",children:[(0,t.jsx)(s.Button,{onClick:()=>{O([]),R(null)},className:"mr-3",children:"Back"}),(0,t.jsx)(s.Button,{type:"primary",onClick:$,disabled:0===N.filter(e=>e.isValid).length||E,children:E?"Creating...":`Create ${N.filter(e=>e.isValid).length} Users`})]}),N.some(e=>"success"===e.status||"failed"===e.status)&&(0,t.jsxs)("div",{className:"flex justify-end mt-4",children:[(0,t.jsx)(s.Button,{onClick:()=>{O([]),R(null)},className:"mr-3",children:"Start New Bulk Import"}),(0,t.jsx)(s.Button,{type:"primary",onClick:()=>{let e=N.map(e=>({user_email:e.user_email,user_role:e.user_role,status:e.status,key:e.key||"",invitation_link:e.invitation_link||"",error:e.error||""})),t=new Blob([_.default.unparse(e)],{type:"text/csv"}),r=window.URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download="bulk_users_results.csv",document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)},icon:(0,t.jsx)(c.DownloadOutlined,{}),children:"Download User Credentials"})]})]})]})})})]})}],447082)},371455,172372,e=>{"use strict";var t=e.i(843476),r=e.i(827252),i=e.i(213205),s=e.i(912598),n=e.i(109799),a=e.i(677667),l=e.i(130643),o=e.i(898667),d=e.i(35983),c=e.i(779241),u=e.i(560445),h=e.i(464571),m=e.i(536916),f=e.i(808613),p=e.i(311451),x=e.i(212931),g=e.i(199133),y=e.i(770914),_=e.i(592968),b=e.i(898586),v=e.i(271645),j=e.i(447082),w=e.i(663435),C=e.i(355619),k=e.i(727749),S=e.i(764205),N=e.i(237016),O=e.i(599724);function E({isInvitationLinkModalVisible:e,setIsInvitationLinkModalVisible:r,baseUrl:i,invitationLinkData:s,modalType:n="invitation"}){let{Title:a,Paragraph:l}=b.Typography,o=()=>{if(!i)return"";let e=new URL(i).pathname,t=e&&"/"!==e?`${e}/ui`:"ui";if(s?.has_user_setup_sso)return new URL(t,i).toString();let r=`${t}?invitation_id=${s?.id}`;return"resetPassword"===n&&(r+="&action=reset_password"),new URL(r,i).toString()};return(0,t.jsxs)(x.Modal,{title:"invitation"===n?"Invitation Link":"Reset Password Link",open:e,width:800,footer:null,onOk:()=>{r(!1)},onCancel:()=>{r(!1)},children:[(0,t.jsx)(l,{children:"invitation"===n?"Copy and send the generated link to onboard this user to the proxy.":"Copy and send the generated link to the user to reset their password."}),(0,t.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,t.jsx)(O.Text,{className:"text-base",children:"User ID"}),(0,t.jsx)(O.Text,{children:s?.user_id})]}),(0,t.jsxs)("div",{className:"flex justify-between pt-5 pb-2",children:[(0,t.jsx)(O.Text,{children:"invitation"===n?"Invitation Link":"Reset Password Link"}),(0,t.jsx)(O.Text,{children:(0,t.jsx)(O.Text,{children:o()})})]}),(0,t.jsx)("div",{className:"flex justify-end mt-5",children:(0,t.jsx)(N.CopyToClipboard,{text:o(),onCopy:()=>k.default.success("Copied!"),children:(0,t.jsx)(h.Button,{type:"primary",children:"invitation"===n?"Copy invitation link":"Copy password reset link"})})})]})}e.s(["default",()=>E],172372);let{Option:I}=g.Select,{Text:T,Link:R,Title:L}=b.Typography;e.s(["CreateUserButton",0,({userID:e,accessToken:b,teams:N,possibleUIRoles:O,onUserCreated:L,isEmbedded:F=!1})=>{let P=(0,s.useQueryClient)(),[A,U]=(0,v.useState)(null),[D]=f.Form.useForm(),[M,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(!1),[$,q]=(0,v.useState)([]),[K,W]=(0,v.useState)(!1),[H,Q]=(0,v.useState)(null),[J,G]=(0,v.useState)(null),{data:X=[]}=(0,n.useOrganizations)();(0,v.useMemo)(()=>{let e=X.flatMap(e=>e.teams||[]);return e.length>0?e:N||[]},[X,N]),(0,v.useEffect)(()=>{let t=async()=>{try{let t=await (0,S.modelAvailableCall)(b,e,"any"),r=[];for(let e=0;e{try{k.default.info("Making API Call"),F||z(!0),t.models&&0!==t.models.length||"proxy_admin"===t.user_role||(t.models=["no-default-models"]),t.organization_ids&&(t.organizations=t.organization_ids,delete t.organization_ids);let r=await (0,S.userCreateCall)(b,null,t);await P.invalidateQueries({queryKey:["userList"]}),V(!0);let i=r.data?.user_id||r.user_id;if(L&&F){L(i),D.resetFields();return}if(A?.SSO_ENABLED){let t={id:"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}),user_id:i,is_accepted:!1,accepted_at:null,expires_at:new Date(Date.now()+6048e5),created_at:new Date,created_by:e,updated_at:new Date,updated_by:e,has_user_setup_sso:!0};Q(t),W(!0)}else(0,S.invitationCreateCall)(b,i).then(e=>{e.has_user_setup_sso=!1,Q(e),W(!0)});k.default.success("API user Created"),D.resetFields(),localStorage.removeItem("userData"+e)}catch(t){let e=t.response?.data?.detail||t?.message||"Error creating the user";k.default.fromBackend(e),console.error("Error creating the user:",t)}};return F?(0,t.jsxs)(f.Form,{form:D,onFinish:Y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_role:"internal_user_viewer",send_invite_email:!0},children:[(0,t.jsx)(u.Alert,{message:"Email invitations",description:(0,t.jsxs)(t.Fragment,{children:["New users receive an email invite only when an email integration (SMTP, Resend, or SendGrid) is configured."," ",(0,t.jsx)(R,{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",children:"Learn how to set up email notifications"})]}),type:"info",showIcon:!0,className:"mb-4"}),(0,t.jsx)(f.Form.Item,{label:"User Email",name:"user_email",children:(0,t.jsx)(c.TextInput,{placeholder:""})}),(0,t.jsx)(f.Form.Item,{label:"User Role",name:"user_role",children:(0,t.jsx)(g.Select,{children:O&&Object.entries(O).map(([e,{ui_label:r,description:i}])=>(0,t.jsx)(d.SelectItem,{value:e,title:r,children:(0,t.jsxs)("div",{className:"flex",children:[r," ",(0,t.jsx)(T,{className:"ml-2",style:{color:"gray",fontSize:"12px"},children:i})]})},e))})}),(0,t.jsx)(f.Form.Item,{label:"Team",name:"team_id",children:(0,t.jsx)(w.default,{})}),(0,t.jsx)(f.Form.Item,{label:"Metadata",name:"metadata",children:(0,t.jsx)(p.Input.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,t.jsx)(f.Form.Item,{label:"Send invitation email",name:"send_invite_email",valuePropName:"checked",children:(0,t.jsx)(m.Checkbox,{})}),(0,t.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,t.jsx)(h.Button,{htmlType:"submit",children:"Create User"})})]}):(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(h.Button,{type:"primary",className:"mb-0",onClick:()=>z(!0),children:"+ Invite User"}),(0,t.jsx)(j.default,{accessToken:b,teams:N,possibleUIRoles:O}),(0,t.jsxs)(x.Modal,{title:"Invite User",open:M,width:800,footer:null,onOk:()=>{z(!1),D.resetFields()},onCancel:()=>{z(!1),V(!1),D.resetFields()},children:[(0,t.jsxs)(y.Space,{direction:"vertical",size:"middle",children:[(0,t.jsx)(T,{className:"mb-1",children:"Create a User who can own keys"}),(0,t.jsx)(u.Alert,{message:"Email invitations",description:(0,t.jsxs)(t.Fragment,{children:["New users receive an email invite only when an email integration (SMTP, Resend, or SendGrid) is configured."," ",(0,t.jsx)(R,{href:"https://docs.litellm.ai/docs/proxy/email",target:"_blank",children:"Learn how to set up email notifications"})]}),type:"info",showIcon:!0,className:"mb-4"})]}),(0,t.jsxs)(f.Form,{form:D,onFinish:Y,labelCol:{span:8},wrapperCol:{span:16},labelAlign:"left",initialValues:{user_role:"internal_user_viewer",send_invite_email:!0},children:[(0,t.jsx)(f.Form.Item,{label:"User Email",name:"user_email",children:(0,t.jsx)(p.Input,{})}),(0,t.jsx)(f.Form.Item,{label:(0,t.jsxs)("span",{children:["Global Proxy Role"," ",(0,t.jsx)(_.Tooltip,{title:"This role is independent of any team/org specific roles. Configure Team / Organization Admins in the Settings",children:(0,t.jsx)(r.InfoCircleOutlined,{})})]}),name:"user_role",children:(0,t.jsx)(g.Select,{children:O&&Object.entries(O).map(([e,{ui_label:r,description:i}])=>(0,t.jsxs)(d.SelectItem,{value:e,title:r,children:[(0,t.jsx)(T,{children:r}),(0,t.jsxs)(T,{type:"secondary",children:[" - ",i]})]},e))})}),(0,t.jsx)(f.Form.Item,{label:"Team",className:"gap-2",name:"team_id",help:"If selected, user will be added as a 'user' role to the team.",children:(0,t.jsx)(w.default,{})}),(0,t.jsx)(f.Form.Item,{label:"Organization",name:"organization_ids",help:"The user will be added to the selected organization(s).",children:(0,t.jsx)(g.Select,{mode:"multiple",placeholder:"Select Organization",style:{width:"100%"},children:X.map(e=>(0,t.jsxs)(I,{value:e.organization_id,children:[e.organization_alias," (",e.organization_id,")"]},e.organization_id))})}),(0,t.jsx)(f.Form.Item,{label:"Metadata",name:"metadata",children:(0,t.jsx)(p.Input.TextArea,{rows:4,placeholder:"Enter metadata as JSON"})}),(0,t.jsx)(f.Form.Item,{label:"Send invitation email",name:"send_invite_email",valuePropName:"checked",children:(0,t.jsx)(m.Checkbox,{})}),(0,t.jsxs)(a.Accordion,{children:[(0,t.jsx)(o.AccordionHeader,{children:(0,t.jsx)(T,{strong:!0,children:"Personal Key Creation"})}),(0,t.jsx)(l.AccordionBody,{children:(0,t.jsx)(f.Form.Item,{className:"gap-2",label:(0,t.jsxs)("span",{children:["Models"," ",(0,t.jsx)(_.Tooltip,{title:"Models user has access to, outside of team scope.",children:(0,t.jsx)(r.InfoCircleOutlined,{style:{marginLeft:"4px"}})})]}),name:"models",help:"Models user has access to, outside of team scope.",children:(0,t.jsxs)(g.Select,{mode:"multiple",placeholder:"Select models",style:{width:"100%"},children:[(0,t.jsx)(g.Select.Option,{value:"all-proxy-models",children:"All Proxy Models"},"all-proxy-models"),(0,t.jsx)(g.Select.Option,{value:"no-default-models",children:"No Default Models"},"no-default-models"),$.map(e=>(0,t.jsx)(g.Select.Option,{value:e,children:(0,C.getModelDisplayName)(e)},e))]})})})]}),(0,t.jsx)("div",{style:{textAlign:"right",marginTop:"10px"},children:(0,t.jsx)(h.Button,{type:"primary",icon:(0,t.jsx)(i.UserAddOutlined,{}),htmlType:"submit",children:"Invite User"})})]})]}),B&&(0,t.jsx)(E,{isInvitationLinkModalVisible:K,setIsInvitationLinkModalVisible:W,baseUrl:J||"",invitationLinkData:H})]})}],371455)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/05d900c88781d712.js b/litellm/proxy/_experimental/out/_next/static/chunks/05d900c88781d712.js deleted file mode 100644 index cdf2168b93..0000000000 --- a/litellm/proxy/_experimental/out/_next/static/chunks/05d900c88781d712.js +++ /dev/null @@ -1 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,653496,e=>{"use strict";var t=e.i(721369);e.s(["Tabs",()=>t.default])},790848,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(739295),n=e.i(343794),a=e.i(931067),i=e.i(211577),l=e.i(392221),o=e.i(703923),c=e.i(914949),d=e.i(404948),s=["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"],u=t.forwardRef(function(e,r){var u,g=e.prefixCls,m=void 0===g?"rc-switch":g,p=e.className,h=e.checked,f=e.defaultChecked,b=e.disabled,$=e.loadingIcon,v=e.checkedChildren,y=e.unCheckedChildren,C=e.onClick,S=e.onChange,k=e.onKeyDown,w=(0,o.default)(e,s),x=(0,c.default)(!1,{value:h,defaultValue:f}),I=(0,l.default)(x,2),O=I[0],E=I[1];function N(e,t){var r=O;return b||(E(r=e),null==S||S(r,t)),r}var z=(0,n.default)(m,p,(u={},(0,i.default)(u,"".concat(m,"-checked"),O),(0,i.default)(u,"".concat(m,"-disabled"),b),u));return t.createElement("button",(0,a.default)({},w,{type:"button",role:"switch","aria-checked":O,disabled:b,className:z,ref:r,onKeyDown:function(e){e.which===d.default.LEFT?N(!1,e):e.which===d.default.RIGHT&&N(!0,e),null==k||k(e)},onClick:function(e){var t=N(!O,e);null==C||C(t,e)}}),$,t.createElement("span",{className:"".concat(m,"-inner")},t.createElement("span",{className:"".concat(m,"-inner-checked")},v),t.createElement("span",{className:"".concat(m,"-inner-unchecked")},y)))});u.displayName="Switch";var g=e.i(121872),m=e.i(242064),p=e.i(937328),h=e.i(517455);e.i(296059);var f=e.i(915654);e.i(262370);var b=e.i(135551),$=e.i(183293),v=e.i(246422),y=e.i(838378);let C=(0,v.genStyleHooks)("Switch",e=>{let t=(0,y.mergeToken)(e,{switchDuration:e.motionDurationMid,switchColor:e.colorPrimary,switchDisabledOpacity:e.opacityLoading,switchLoadingIconSize:e.calc(e.fontSizeIcon).mul(.75).equal(),switchLoadingIconColor:`rgba(0, 0, 0, ${e.opacityLoading})`,switchHandleActiveInset:"-30%"});return[(e=>{let{componentCls:t,trackHeight:r,trackMinWidth:n}=e;return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,$.resetComponent)(e)),{position:"relative",display:"inline-block",boxSizing:"border-box",minWidth:n,height:r,lineHeight:(0,f.unit)(r),verticalAlign:"middle",background:e.colorTextQuaternary,border:"0",borderRadius:100,cursor:"pointer",transition:`all ${e.motionDurationMid}`,userSelect:"none",[`&:hover:not(${t}-disabled)`]:{background:e.colorTextTertiary}}),(0,$.genFocusStyle)(e)),{[`&${t}-checked`]:{background:e.switchColor,[`&:hover:not(${t}-disabled)`]:{background:e.colorPrimaryHover}},[`&${t}-loading, &${t}-disabled`]:{cursor:"not-allowed",opacity:e.switchDisabledOpacity,"*":{boxShadow:"none",cursor:"not-allowed"}},[`&${t}-rtl`]:{direction:"rtl"}})}})(t),(e=>{let{componentCls:t,trackHeight:r,trackPadding:n,innerMinMargin:a,innerMaxMargin:i,handleSize:l,calc:o}=e,c=`${t}-inner`,d=(0,f.unit)(o(l).add(o(n).mul(2)).equal()),s=(0,f.unit)(o(i).mul(2).equal());return{[t]:{[c]:{display:"block",overflow:"hidden",borderRadius:100,height:"100%",paddingInlineStart:i,paddingInlineEnd:a,transition:`padding-inline-start ${e.switchDuration} ease-in-out, padding-inline-end ${e.switchDuration} ease-in-out`,[`${c}-checked, ${c}-unchecked`]:{display:"block",color:e.colorTextLightSolid,fontSize:e.fontSizeSM,transition:`margin-inline-start ${e.switchDuration} ease-in-out, margin-inline-end ${e.switchDuration} ease-in-out`,pointerEvents:"none",minHeight:r},[`${c}-checked`]:{marginInlineStart:`calc(-100% + ${d} - ${s})`,marginInlineEnd:`calc(100% - ${d} + ${s})`},[`${c}-unchecked`]:{marginTop:o(r).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`&${t}-checked ${c}`]:{paddingInlineStart:a,paddingInlineEnd:i,[`${c}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${c}-unchecked`]:{marginInlineStart:`calc(100% - ${d} + ${s})`,marginInlineEnd:`calc(-100% + ${d} - ${s})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${c}`]:{[`${c}-unchecked`]:{marginInlineStart:o(n).mul(2).equal(),marginInlineEnd:o(n).mul(-1).mul(2).equal()}},[`&${t}-checked ${c}`]:{[`${c}-checked`]:{marginInlineStart:o(n).mul(-1).mul(2).equal(),marginInlineEnd:o(n).mul(2).equal()}}}}}})(t),(e=>{let{componentCls:t,trackPadding:r,handleBg:n,handleShadow:a,handleSize:i,calc:l}=e,o=`${t}-handle`;return{[t]:{[o]:{position:"absolute",top:r,insetInlineStart:r,width:i,height:i,transition:`all ${e.switchDuration} ease-in-out`,"&::before":{position:"absolute",top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,backgroundColor:n,borderRadius:l(i).div(2).equal(),boxShadow:a,transition:`all ${e.switchDuration} ease-in-out`,content:'""'}},[`&${t}-checked ${o}`]:{insetInlineStart:`calc(100% - ${(0,f.unit)(l(i).add(r).equal())})`},[`&:not(${t}-disabled):active`]:{[`${o}::before`]:{insetInlineEnd:e.switchHandleActiveInset,insetInlineStart:0},[`&${t}-checked ${o}::before`]:{insetInlineEnd:0,insetInlineStart:e.switchHandleActiveInset}}}}})(t),(e=>{let{componentCls:t,handleSize:r,calc:n}=e;return{[t]:{[`${t}-loading-icon${e.iconCls}`]:{position:"relative",top:n(n(r).sub(e.fontSize)).div(2).equal(),color:e.switchLoadingIconColor,verticalAlign:"top"},[`&${t}-checked ${t}-loading-icon`]:{color:e.switchColor}}}})(t),(e=>{let{componentCls:t,trackHeightSM:r,trackPadding:n,trackMinWidthSM:a,innerMinMarginSM:i,innerMaxMarginSM:l,handleSizeSM:o,calc:c}=e,d=`${t}-inner`,s=(0,f.unit)(c(o).add(c(n).mul(2)).equal()),u=(0,f.unit)(c(l).mul(2).equal());return{[t]:{[`&${t}-small`]:{minWidth:a,height:r,lineHeight:(0,f.unit)(r),[`${t}-inner`]:{paddingInlineStart:l,paddingInlineEnd:i,[`${d}-checked, ${d}-unchecked`]:{minHeight:r},[`${d}-checked`]:{marginInlineStart:`calc(-100% + ${s} - ${u})`,marginInlineEnd:`calc(100% - ${s} + ${u})`},[`${d}-unchecked`]:{marginTop:c(r).mul(-1).equal(),marginInlineStart:0,marginInlineEnd:0}},[`${t}-handle`]:{width:o,height:o},[`${t}-loading-icon`]:{top:c(c(o).sub(e.switchLoadingIconSize)).div(2).equal(),fontSize:e.switchLoadingIconSize},[`&${t}-checked`]:{[`${t}-inner`]:{paddingInlineStart:i,paddingInlineEnd:l,[`${d}-checked`]:{marginInlineStart:0,marginInlineEnd:0},[`${d}-unchecked`]:{marginInlineStart:`calc(100% - ${s} + ${u})`,marginInlineEnd:`calc(-100% + ${s} - ${u})`}},[`${t}-handle`]:{insetInlineStart:`calc(100% - ${(0,f.unit)(c(o).add(n).equal())})`}},[`&:not(${t}-disabled):active`]:{[`&:not(${t}-checked) ${d}`]:{[`${d}-unchecked`]:{marginInlineStart:c(e.marginXXS).div(2).equal(),marginInlineEnd:c(e.marginXXS).mul(-1).div(2).equal()}},[`&${t}-checked ${d}`]:{[`${d}-checked`]:{marginInlineStart:c(e.marginXXS).mul(-1).div(2).equal(),marginInlineEnd:c(e.marginXXS).div(2).equal()}}}}}}})(t)]},e=>{let{fontSize:t,lineHeight:r,controlHeight:n,colorWhite:a}=e,i=t*r,l=n/2,o=i-4,c=l-4;return{trackHeight:i,trackHeightSM:l,trackMinWidth:2*o+8,trackMinWidthSM:2*c+4,trackPadding:2,handleBg:a,handleSize:o,handleSizeSM:c,handleShadow:`0 2px 4px 0 ${new b.FastColor("#00230b").setA(.2).toRgbString()}`,innerMinMargin:o/2,innerMaxMargin:o+2+4,innerMinMarginSM:c/2,innerMaxMarginSM:c+2+4}});var S=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let k=t.forwardRef((e,a)=>{let{prefixCls:i,size:l,disabled:o,loading:d,className:s,rootClassName:f,style:b,checked:$,value:v,defaultChecked:y,defaultValue:k,onChange:w}=e,x=S(e,["prefixCls","size","disabled","loading","className","rootClassName","style","checked","value","defaultChecked","defaultValue","onChange"]),[I,O]=(0,c.default)(!1,{value:null!=$?$:v,defaultValue:null!=y?y:k}),{getPrefixCls:E,direction:N,switch:z}=t.useContext(m.ConfigContext),j=t.useContext(p.default),P=(null!=o?o:j)||d,T=E("switch",i),M=t.createElement("div",{className:`${T}-handle`},d&&t.createElement(r.default,{className:`${T}-loading-icon`})),[B,q,H]=C(T),R=(0,h.default)(l),L=(0,n.default)(null==z?void 0:z.className,{[`${T}-small`]:"small"===R,[`${T}-loading`]:d,[`${T}-rtl`]:"rtl"===N},s,f,q,H),G=Object.assign(Object.assign({},null==z?void 0:z.style),b);return B(t.createElement(g.default,{component:"Switch",disabled:P},t.createElement(u,Object.assign({},x,{checked:I,onChange:(...e)=>{O(e[0]),null==w||w.apply(void 0,e)},prefixCls:T,className:L,style:G,disabled:P,ref:a,loadingIcon:M}))))});k.__ANT_SWITCH=!0,e.s(["Switch",0,k],790848)},475254,e=>{"use strict";var t=e.i(271645);let r=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},n=(...e)=>e.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim();var a={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,t.forwardRef)(({color:e="currentColor",size:r=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...s},u)=>(0,t.createElement)("svg",{ref:u,...a,width:r,height:r,stroke:e,strokeWidth:l?24*Number(i)/Number(r):i,className:n("lucide",o),...!c&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(s)&&{"aria-hidden":"true"},...s},[...d.map(([e,r])=>(0,t.createElement)(e,r)),...Array.isArray(c)?c:[c]])),l=(e,a)=>{let l=(0,t.forwardRef)(({className:l,...o},c)=>(0,t.createElement)(i,{ref:c,iconNode:a,className:n(`lucide-${r(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,l),...o}));return l.displayName=r(e),l};e.s(["default",()=>l],475254)},464571,e=>{"use strict";var t=e.i(920228);e.s(["Button",()=>t.default])},959013,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}},{tag:"path",attrs:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z"}}]},name:"plus",theme:"outlined"};var a=e.i(9583),i=r.forwardRef(function(e,i){return r.createElement(a.default,(0,t.default)({},e,{ref:i,icon:n}))});e.s(["default",0,i],959013)},599724,936325,e=>{"use strict";var t=e.i(95779),r=e.i(444755),n=e.i(673706),a=e.i(271645);let i=a.default.forwardRef((e,i)=>{let{color:l,className:o,children:c}=e;return a.default.createElement("p",{ref:i,className:(0,r.tremorTwMerge)("text-tremor-default",l?(0,n.getColorClassNames)(l,t.colorPalette.text).textColor:(0,r.tremorTwMerge)("text-tremor-content","dark:text-dark-tremor-content"),o)},c)});i.displayName="Text",e.s(["default",()=>i],936325),e.s(["Text",()=>i],599724)},304967,e=>{"use strict";var t=e.i(290571),r=e.i(271645),n=e.i(480731),a=e.i(95779),i=e.i(444755),l=e.i(673706);let o=(0,l.makeClassName)("Card"),c=r.default.forwardRef((e,c)=>{let{decoration:d="",decorationColor:s,children:u,className:g}=e,m=(0,t.__rest)(e,["decoration","decorationColor","children","className"]);return r.default.createElement("div",Object.assign({ref:c,className:(0,i.tremorTwMerge)(o("root"),"relative w-full text-left ring-1 rounded-tremor-default p-6","bg-tremor-background ring-tremor-ring shadow-tremor-card","dark:bg-dark-tremor-background dark:ring-dark-tremor-ring dark:shadow-dark-tremor-card",s?(0,l.getColorClassNames)(s,a.colorPalette.border).borderColor:"border-tremor-brand dark:border-dark-tremor-brand",(e=>{if(!e)return"";switch(e){case n.HorizontalPositions.Left:return"border-l-4";case n.VerticalPositions.Top:return"border-t-4";case n.HorizontalPositions.Right:return"border-r-4";case n.VerticalPositions.Bottom:return"border-b-4";default:return""}})(d),g)},m),u)});c.displayName="Card",e.s(["Card",()=>c],304967)},262218,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),n=e.i(529681),a=e.i(702779),i=e.i(563113),l=e.i(763731),o=e.i(121872),c=e.i(242064);e.i(296059);var d=e.i(915654);e.i(262370);var s=e.i(135551),u=e.i(183293),g=e.i(246422),m=e.i(838378);let p=e=>{let{lineWidth:t,fontSizeIcon:r,calc:n}=e,a=e.fontSizeSM;return(0,m.mergeToken)(e,{tagFontSize:a,tagLineHeight:(0,d.unit)(n(e.lineHeightSM).mul(a).equal()),tagIconSize:n(r).sub(n(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},h=e=>({defaultBg:new s.FastColor(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),f=(0,g.genStyleHooks)("Tag",e=>(e=>{let{paddingXXS:t,lineWidth:r,tagPaddingHorizontal:n,componentCls:a,calc:i}=e,l=i(n).sub(r).equal(),o=i(t).sub(r).equal();return{[a]:Object.assign(Object.assign({},(0,u.resetComponent)(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:l,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${(0,d.unit)(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${a}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${a}-close-icon`]:{marginInlineStart:o,fontSize:e.tagIconSize,color:e.colorIcon,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${a}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${a}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:l}}),[`${a}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}})(p(e)),h);var b=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let $=t.forwardRef((e,n)=>{let{prefixCls:a,style:i,className:l,checked:o,children:d,icon:s,onChange:u,onClick:g}=e,m=b(e,["prefixCls","style","className","checked","children","icon","onChange","onClick"]),{getPrefixCls:p,tag:h}=t.useContext(c.ConfigContext),$=p("tag",a),[v,y,C]=f($),S=(0,r.default)($,`${$}-checkable`,{[`${$}-checkable-checked`]:o},null==h?void 0:h.className,l,y,C);return v(t.createElement("span",Object.assign({},m,{ref:n,style:Object.assign(Object.assign({},i),null==h?void 0:h.style),className:S,onClick:e=>{null==u||u(!o),null==g||g(e)}}),s,t.createElement("span",null,d)))});var v=e.i(403541);let y=(0,g.genSubStyleComponent)(["Tag","preset"],e=>{let t;return t=p(e),(0,v.genPresetColor)(t,(e,{textColor:r,lightBorderColor:n,lightColor:a,darkColor:i})=>({[`${t.componentCls}${t.componentCls}-${e}`]:{color:r,background:a,borderColor:n,"&-inverse":{color:t.colorTextLightSolid,background:i,borderColor:i},[`&${t.componentCls}-borderless`]:{borderColor:"transparent"}}}))},h),C=(e,t,r)=>{let n="string"!=typeof r?r:r.charAt(0).toUpperCase()+r.slice(1);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${r}`],background:e[`color${n}Bg`],borderColor:e[`color${n}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},S=(0,g.genSubStyleComponent)(["Tag","status"],e=>{let t=p(e);return[C(t,"success","Success"),C(t,"processing","Info"),C(t,"error","Error"),C(t,"warning","Warning")]},h);var k=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let w=t.forwardRef((e,d)=>{let{prefixCls:s,className:u,rootClassName:g,style:m,children:p,icon:h,color:b,onClose:$,bordered:v=!0,visible:C}=e,w=k(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:x,direction:I,tag:O}=t.useContext(c.ConfigContext),[E,N]=t.useState(!0),z=(0,n.default)(w,["closeIcon","closable"]);t.useEffect(()=>{void 0!==C&&N(C)},[C]);let j=(0,a.isPresetColor)(b),P=(0,a.isPresetStatusColor)(b),T=j||P,M=Object.assign(Object.assign({backgroundColor:b&&!T?b:void 0},null==O?void 0:O.style),m),B=x("tag",s),[q,H,R]=f(B),L=(0,r.default)(B,null==O?void 0:O.className,{[`${B}-${b}`]:T,[`${B}-has-color`]:b&&!T,[`${B}-hidden`]:!E,[`${B}-rtl`]:"rtl"===I,[`${B}-borderless`]:!v},u,g,H,R),G=e=>{e.stopPropagation(),null==$||$(e),e.defaultPrevented||N(!1)},[,A]=(0,i.useClosable)((0,i.pickClosable)(e),(0,i.pickClosable)(O),{closable:!1,closeIconRender:e=>{let n=t.createElement("span",{className:`${B}-close-icon`,onClick:G},e);return(0,l.replaceElement)(e,n,e=>({onClick:t=>{var r;null==(r=null==e?void 0:e.onClick)||r.call(e,t),G(t)},className:(0,r.default)(null==e?void 0:e.className,`${B}-close-icon`)}))}}),W="function"==typeof w.onClick||p&&"a"===p.type,D=h||null,X=D?t.createElement(t.Fragment,null,D,p&&t.createElement("span",null,p)):p,F=t.createElement("span",Object.assign({},z,{ref:d,className:L,style:M}),X,A,j&&t.createElement(y,{key:"preset",prefixCls:B}),P&&t.createElement(S,{key:"status",prefixCls:B}));return q(W?t.createElement(o.default,{component:"Tag"},F):F)});w.CheckableTag=$,e.s(["Tag",0,w],262218)},770914,e=>{"use strict";var t=e.i(38243);e.s(["Space",()=>t.default])},38243,908286,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),n=e.i(876556);function a(e){return["small","middle","large"].includes(e)}function i(e){return!!e&&"number"==typeof e&&!Number.isNaN(e)}e.s(["isPresetSize",()=>a,"isValidGapNumber",()=>i],908286);var l=e.i(242064),o=e.i(249616),c=e.i(372409),d=e.i(246422);let s=(0,d.genStyleHooks)(["Space","Addon"],e=>[(e=>{let{componentCls:t,borderRadius:r,paddingSM:n,colorBorder:a,paddingXS:i,fontSizeLG:l,fontSizeSM:o,borderRadiusLG:d,borderRadiusSM:s,colorBgContainerDisabled:u,lineWidth:g}=e;return{[t]:[{display:"inline-flex",alignItems:"center",gap:0,paddingInline:n,margin:0,background:u,borderWidth:g,borderStyle:"solid",borderColor:a,borderRadius:r,"&-large":{fontSize:l,borderRadius:d},"&-small":{paddingInline:i,borderRadius:s,fontSize:o},"&-compact-last-item":{borderEndStartRadius:0,borderStartStartRadius:0},"&-compact-first-item":{borderEndEndRadius:0,borderStartEndRadius:0},"&-compact-item:not(:first-child):not(:last-child)":{borderRadius:0},"&-compact-item:not(:last-child)":{borderInlineEndWidth:0}},(0,c.genCompactItemStyle)(e,{focus:!1})]}})(e)]);var u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let g=t.default.forwardRef((e,n)=>{let{className:a,children:i,style:c,prefixCls:d}=e,g=u(e,["className","children","style","prefixCls"]),{getPrefixCls:m,direction:p}=t.default.useContext(l.ConfigContext),h=m("space-addon",d),[f,b,$]=s(h),{compactItemClassnames:v,compactSize:y}=(0,o.useCompactItemContext)(h,p),C=(0,r.default)(h,b,v,$,{[`${h}-${y}`]:y},a);return f(t.default.createElement("div",Object.assign({ref:n,className:C,style:c},g),i))}),m=t.default.createContext({latestIndex:0}),p=m.Provider,h=({className:e,index:r,children:n,split:a,style:i})=>{let{latestIndex:l}=t.useContext(m);return null==n?null:t.createElement(t.Fragment,null,t.createElement("div",{className:e,style:i},n),r{let t=(0,f.mergeToken)(e,{spaceGapSmallSize:e.paddingXS,spaceGapMiddleSize:e.padding,spaceGapLargeSize:e.paddingLG});return[(e=>{let{componentCls:t,antCls:r}=e;return{[t]:{display:"inline-flex","&-rtl":{direction:"rtl"},"&-vertical":{flexDirection:"column"},"&-align":{flexDirection:"column","&-center":{alignItems:"center"},"&-start":{alignItems:"flex-start"},"&-end":{alignItems:"flex-end"},"&-baseline":{alignItems:"baseline"}},[`${t}-item:empty`]:{display:"none"},[`${t}-item > ${r}-badge-not-a-wrapper:only-child`]:{display:"block"}}}})(t),(e=>{let{componentCls:t}=e;return{[t]:{"&-gap-row-small":{rowGap:e.spaceGapSmallSize},"&-gap-row-middle":{rowGap:e.spaceGapMiddleSize},"&-gap-row-large":{rowGap:e.spaceGapLargeSize},"&-gap-col-small":{columnGap:e.spaceGapSmallSize},"&-gap-col-middle":{columnGap:e.spaceGapMiddleSize},"&-gap-col-large":{columnGap:e.spaceGapLargeSize}}}})(t)]},()=>({}),{resetStyle:!1});var $=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let v=t.forwardRef((e,o)=>{var c;let{getPrefixCls:d,direction:s,size:u,className:g,style:m,classNames:f,styles:v}=(0,l.useComponentConfig)("space"),{size:y=null!=u?u:"small",align:C,className:S,rootClassName:k,children:w,direction:x="horizontal",prefixCls:I,split:O,style:E,wrap:N=!1,classNames:z,styles:j}=e,P=$(e,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[T,M]=Array.isArray(y)?y:[y,y],B=a(M),q=a(T),H=i(M),R=i(T),L=(0,n.default)(w,{keepEmpty:!0}),G=void 0===C&&"horizontal"===x?"center":C,A=d("space",I),[W,D,X]=b(A),F=(0,r.default)(A,g,D,`${A}-${x}`,{[`${A}-rtl`]:"rtl"===s,[`${A}-align-${G}`]:G,[`${A}-gap-row-${M}`]:B,[`${A}-gap-col-${T}`]:q},S,k,X),V=(0,r.default)(`${A}-item`,null!=(c=null==z?void 0:z.item)?c:f.item),_=Object.assign(Object.assign({},v.item),null==j?void 0:j.item),K=L.map((e,r)=>{let n=(null==e?void 0:e.key)||`${V}-${r}`;return t.createElement(h,{className:V,key:n,index:r,split:O,style:_},e)}),U=t.useMemo(()=>({latestIndex:L.reduce((e,t,r)=>null!=t?r:e,0)}),[L]);if(0===L.length)return null;let Q={};return N&&(Q.flexWrap="wrap"),!q&&R&&(Q.columnGap=T),!B&&H&&(Q.rowGap=M),W(t.createElement("div",Object.assign({ref:o,className:F,style:Object.assign(Object.assign(Object.assign({},Q),m),E)},P),t.createElement(p,{value:U},K)))});v.Compact=o.default,v.Addon=g,e.s(["default",0,v],38243)},312361,e=>{"use strict";e.i(247167);var t=e.i(271645),r=e.i(343794),n=e.i(242064),a=e.i(517455);e.i(296059);var i=e.i(915654),l=e.i(183293),o=e.i(246422),c=e.i(838378);let d=(0,o.genStyleHooks)("Divider",e=>{let t=(0,c.mergeToken)(e,{dividerHorizontalWithTextGutterMargin:e.margin,sizePaddingEdgeHorizontal:0});return[(e=>{let{componentCls:t,sizePaddingEdgeHorizontal:r,colorSplit:n,lineWidth:a,textPaddingInline:o,orientationMargin:c,verticalMarginInline:d}=e;return{[t]:Object.assign(Object.assign({},(0,l.resetComponent)(e)),{borderBlockStart:`${(0,i.unit)(a)} solid ${n}`,"&-vertical":{position:"relative",top:"-0.06em",display:"inline-block",height:"0.9em",marginInline:d,marginBlock:0,verticalAlign:"middle",borderTop:0,borderInlineStart:`${(0,i.unit)(a)} solid ${n}`},"&-horizontal":{display:"flex",clear:"both",width:"100%",minWidth:"100%",margin:`${(0,i.unit)(e.marginLG)} 0`},[`&-horizontal${t}-with-text`]:{display:"flex",alignItems:"center",margin:`${(0,i.unit)(e.dividerHorizontalWithTextGutterMargin)} 0`,color:e.colorTextHeading,fontWeight:500,fontSize:e.fontSizeLG,whiteSpace:"nowrap",textAlign:"center",borderBlockStart:`0 ${n}`,"&::before, &::after":{position:"relative",width:"50%",borderBlockStart:`${(0,i.unit)(a)} solid transparent`,borderBlockStartColor:"inherit",borderBlockEnd:0,transform:"translateY(50%)",content:"''"}},[`&-horizontal${t}-with-text-start`]:{"&::before":{width:`calc(${c} * 100%)`},"&::after":{width:`calc(100% - ${c} * 100%)`}},[`&-horizontal${t}-with-text-end`]:{"&::before":{width:`calc(100% - ${c} * 100%)`},"&::after":{width:`calc(${c} * 100%)`}},[`${t}-inner-text`]:{display:"inline-block",paddingBlock:0,paddingInline:o},"&-dashed":{background:"none",borderColor:n,borderStyle:"dashed",borderWidth:`${(0,i.unit)(a)} 0 0`},[`&-horizontal${t}-with-text${t}-dashed`]:{"&::before, &::after":{borderStyle:"dashed none none"}},[`&-vertical${t}-dashed`]:{borderInlineStartWidth:a,borderInlineEnd:0,borderBlockStart:0,borderBlockEnd:0},"&-dotted":{background:"none",borderColor:n,borderStyle:"dotted",borderWidth:`${(0,i.unit)(a)} 0 0`},[`&-horizontal${t}-with-text${t}-dotted`]:{"&::before, &::after":{borderStyle:"dotted none none"}},[`&-vertical${t}-dotted`]:{borderInlineStartWidth:a,borderInlineEnd:0,borderBlockStart:0,borderBlockEnd:0},[`&-plain${t}-with-text`]:{color:e.colorText,fontWeight:"normal",fontSize:e.fontSize},[`&-horizontal${t}-with-text-start${t}-no-default-orientation-margin-start`]:{"&::before":{width:0},"&::after":{width:"100%"},[`${t}-inner-text`]:{paddingInlineStart:r}},[`&-horizontal${t}-with-text-end${t}-no-default-orientation-margin-end`]:{"&::before":{width:"100%"},"&::after":{width:0},[`${t}-inner-text`]:{paddingInlineEnd:r}}})}})(t),(e=>{let{componentCls:t}=e;return{[t]:{"&-horizontal":{[`&${t}`]:{"&-sm":{marginBlock:e.marginXS},"&-md":{marginBlock:e.margin}}}}}})(t)]},e=>({textPaddingInline:"1em",orientationMargin:.05,verticalMarginInline:e.marginXS}),{unitless:{orientationMargin:!0}});var s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);at.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};let u={small:"sm",middle:"md"};e.s(["Divider",0,e=>{let{getPrefixCls:i,direction:l,className:o,style:c}=(0,n.useComponentConfig)("divider"),{prefixCls:g,type:m="horizontal",orientation:p="center",orientationMargin:h,className:f,rootClassName:b,children:$,dashed:v,variant:y="solid",plain:C,style:S,size:k}=e,w=s(e,["prefixCls","type","orientation","orientationMargin","className","rootClassName","children","dashed","variant","plain","style","size"]),x=i("divider",g),[I,O,E]=d(x),N=u[(0,a.default)(k)],z=!!$,j=t.useMemo(()=>"left"===p?"rtl"===l?"end":"start":"right"===p?"rtl"===l?"start":"end":p,[l,p]),P="start"===j&&null!=h,T="end"===j&&null!=h,M=(0,r.default)(x,o,O,E,`${x}-${m}`,{[`${x}-with-text`]:z,[`${x}-with-text-${j}`]:z,[`${x}-dashed`]:!!v,[`${x}-${y}`]:"solid"!==y,[`${x}-plain`]:!!C,[`${x}-rtl`]:"rtl"===l,[`${x}-no-default-orientation-margin-start`]:P,[`${x}-no-default-orientation-margin-end`]:T,[`${x}-${N}`]:!!N},f,b),B=t.useMemo(()=>"number"==typeof h?h:/^\d+$/.test(h)?Number(h):h,[h]);return I(t.createElement("div",Object.assign({className:M,style:Object.assign(Object.assign({},c),S)},w,{role:"separator"}),$&&"vertical"!==m&&t.createElement("span",{className:`${x}-inner-text`,style:{marginInlineStart:P?B:void 0,marginInlineEnd:T?B:void 0}},$)))}],312361)},801312,e=>{"use strict";e.i(247167);var t=e.i(931067),r=e.i(271645);let n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"}}]},name:"left",theme:"outlined"};var a=e.i(9583),i=r.forwardRef(function(e,i){return r.createElement(a.default,(0,t.default)({},e,{ref:i,icon:n}))});e.s(["default",0,i],801312)}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/b83ca9892d2d63cf.js b/litellm/proxy/_experimental/out/_next/static/chunks/0606c92ecd600e0c.js similarity index 53% rename from litellm/proxy/_experimental/out/_next/static/chunks/b83ca9892d2d63cf.js rename to litellm/proxy/_experimental/out/_next/static/chunks/0606c92ecd600e0c.js index fe2c03f466..4d144c04ad 100644 --- a/litellm/proxy/_experimental/out/_next/static/chunks/b83ca9892d2d63cf.js +++ b/litellm/proxy/_experimental/out/_next/static/chunks/0606c92ecd600e0c.js @@ -1,4 +1,4 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,596239,e=>{"use strict";e.i(247167);var t=e.i(931067),i=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M574 665.4a8.03 8.03 0 00-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 00-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 000 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 000 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 00-11.3 0L372.3 598.7a8.03 8.03 0 000 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z"}}]},name:"link",theme:"outlined"};var o=e.i(9583),r=i.forwardRef(function(e,r){return i.createElement(o.default,(0,t.default)({},e,{ref:r,icon:a}))});e.s(["LinkOutlined",0,r],596239)},190272,785913,e=>{"use strict";var t,i,a=((t={}).AUDIO_SPEECH="audio_speech",t.AUDIO_TRANSCRIPTION="audio_transcription",t.IMAGE_GENERATION="image_generation",t.VIDEO_GENERATION="video_generation",t.CHAT="chat",t.RESPONSES="responses",t.IMAGE_EDITS="image_edits",t.ANTHROPIC_MESSAGES="anthropic_messages",t.EMBEDDING="embedding",t),o=((i={}).IMAGE="image",i.VIDEO="video",i.CHAT="chat",i.RESPONSES="responses",i.IMAGE_EDITS="image_edits",i.ANTHROPIC_MESSAGES="anthropic_messages",i.EMBEDDINGS="embeddings",i.SPEECH="speech",i.TRANSCRIPTION="transcription",i.A2A_AGENTS="a2a_agents",i.MCP="mcp",i.REALTIME="realtime",i);let r={image_generation:"image",video_generation:"video",chat:"chat",responses:"responses",image_edits:"image_edits",anthropic_messages:"anthropic_messages",audio_speech:"speech",audio_transcription:"transcription",embedding:"embeddings"};e.s(["EndpointType",()=>o,"getEndpointType",0,e=>{if(console.log("getEndpointType:",e),Object.values(a).includes(e)){let t=r[e];return console.log("endpointType:",t),t}return"chat"}],785913),e.s(["generateCodeSnippet",0,e=>{let t,{apiKeySource:i,accessToken:a,apiKey:r,inputMessage:n,chatHistory:s,selectedTags:l,selectedVectorStores:p,selectedGuardrails:d,selectedPolicies:c,selectedMCPServers:g,mcpServers:m,mcpServerToolRestrictions:u,selectedVoice:f,endpointType:_,selectedModel:h,selectedSdk:A,proxySettings:x}=e,b="session"===i?a:r,y=window.location.origin,I=x?.LITELLM_UI_API_DOC_BASE_URL;I&&I.trim()?y=I:x?.PROXY_BASE_URL&&(y=x.PROXY_BASE_URL);let v=n||"Your prompt here",C=v.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n"),E=s.filter(e=>!e.isImage).map(({role:e,content:t})=>({role:e,content:t})),O={};l.length>0&&(O.tags=l),p.length>0&&(O.vector_stores=p),d.length>0&&(O.guardrails=d),c.length>0&&(O.policies=c);let T=h||"your-model-name",S="azure"===A?`import openai +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,492030,e=>{"use strict";var t=e.i(121229);e.s(["CheckOutlined",()=>t.default])},166406,e=>{"use strict";var t=e.i(190144);e.s(["CopyOutlined",()=>t.default])},447566,e=>{"use strict";e.i(247167);var t=e.i(931067),i=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M872 474H286.9l350.2-304c5.6-4.9 2.2-14-5.2-14h-88.5c-3.9 0-7.6 1.4-10.5 3.9L155 487.8a31.96 31.96 0 000 48.3L535.1 866c1.5 1.3 3.3 2 5.2 2h91.5c7.4 0 10.8-9.2 5.2-14L286.9 550H872c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"arrow-left",theme:"outlined"};var o=e.i(9583),r=i.forwardRef(function(e,r){return i.createElement(o.default,(0,t.default)({},e,{ref:r,icon:a}))});e.s(["ArrowLeftOutlined",0,r],447566)},596239,e=>{"use strict";e.i(247167);var t=e.i(931067),i=e.i(271645);let a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M574 665.4a8.03 8.03 0 00-11.3 0L446.5 781.6c-53.8 53.8-144.6 59.5-204 0-59.5-59.5-53.8-150.2 0-204l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3l-39.8-39.8a8.03 8.03 0 00-11.3 0L191.4 526.5c-84.6 84.6-84.6 221.5 0 306s221.5 84.6 306 0l116.2-116.2c3.1-3.1 3.1-8.2 0-11.3L574 665.4zm258.6-474c-84.6-84.6-221.5-84.6-306 0L410.3 307.6a8.03 8.03 0 000 11.3l39.7 39.7c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c53.8-53.8 144.6-59.5 204 0 59.5 59.5 53.8 150.2 0 204L665.3 562.6a8.03 8.03 0 000 11.3l39.8 39.8c3.1 3.1 8.2 3.1 11.3 0l116.2-116.2c84.5-84.6 84.5-221.5 0-306.1zM610.1 372.3a8.03 8.03 0 00-11.3 0L372.3 598.7a8.03 8.03 0 000 11.3l39.6 39.6c3.1 3.1 8.2 3.1 11.3 0l226.4-226.4c3.1-3.1 3.1-8.2 0-11.3l-39.5-39.6z"}}]},name:"link",theme:"outlined"};var o=e.i(9583),r=i.forwardRef(function(e,r){return i.createElement(o.default,(0,t.default)({},e,{ref:r,icon:a}))});e.s(["LinkOutlined",0,r],596239)},190272,785913,e=>{"use strict";var t,i,a=((t={}).AUDIO_SPEECH="audio_speech",t.AUDIO_TRANSCRIPTION="audio_transcription",t.IMAGE_GENERATION="image_generation",t.VIDEO_GENERATION="video_generation",t.CHAT="chat",t.RESPONSES="responses",t.IMAGE_EDITS="image_edits",t.ANTHROPIC_MESSAGES="anthropic_messages",t.EMBEDDING="embedding",t),o=((i={}).IMAGE="image",i.VIDEO="video",i.CHAT="chat",i.RESPONSES="responses",i.IMAGE_EDITS="image_edits",i.ANTHROPIC_MESSAGES="anthropic_messages",i.EMBEDDINGS="embeddings",i.SPEECH="speech",i.TRANSCRIPTION="transcription",i.A2A_AGENTS="a2a_agents",i.MCP="mcp",i.REALTIME="realtime",i);let r={image_generation:"image",video_generation:"video",chat:"chat",responses:"responses",image_edits:"image_edits",anthropic_messages:"anthropic_messages",audio_speech:"speech",audio_transcription:"transcription",embedding:"embeddings"};e.s(["EndpointType",()=>o,"getEndpointType",0,e=>{if(console.log("getEndpointType:",e),Object.values(a).includes(e)){let t=r[e];return console.log("endpointType:",t),t}return"chat"}],785913),e.s(["generateCodeSnippet",0,e=>{let t,{apiKeySource:i,accessToken:a,apiKey:r,inputMessage:n,chatHistory:s,selectedTags:l,selectedVectorStores:p,selectedGuardrails:d,selectedPolicies:c,selectedMCPServers:g,mcpServers:m,mcpServerToolRestrictions:u,selectedVoice:f,endpointType:_,selectedModel:h,selectedSdk:A,proxySettings:x}=e,b="session"===i?a:r,y=window.location.origin,I=x?.LITELLM_UI_API_DOC_BASE_URL;I&&I.trim()?y=I:x?.PROXY_BASE_URL&&(y=x.PROXY_BASE_URL);let v=n||"Your prompt here",C=v.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n"),E=s.filter(e=>!e.isImage).map(({role:e,content:t})=>({role:e,content:t})),O={};l.length>0&&(O.tags=l),p.length>0&&(O.vector_stores=p),d.length>0&&(O.guardrails=d),c.length>0&&(O.policies=c);let T=h||"your-model-name",S="azure"===A?`import openai client = openai.AzureOpenAI( api_key="${b||"YOUR_LITELLM_API_KEY"}", @@ -417,4 +417,4 @@ print(f"Audio saved to {output_filename}") # ) # response.stream_to_file("output_speech.mp3") `;break;default:t="\n# Code generation for this endpoint is not implemented yet."}return`${S} -${t}`}],190272)},652272,209261,e=>{"use strict";var t=e.i(843476),i=e.i(271645),a=e.i(447566),o=e.i(166406),r=e.i(492030),n=e.i(596239);let s=e=>"github"===e.source.source&&e.source.repo?`/plugin marketplace add ${e.source.repo}`:"url"===e.source.source&&e.source.url?`/plugin marketplace add ${e.source.url}`:`/plugin marketplace add ${e.name}`;e.s(["formatInstallCommand",0,s,"getCategoryBadgeColor",0,e=>{if(!e)return"gray";let t=e.toLowerCase();if(t.includes("development")||t.includes("dev"))return"blue";if(t.includes("productivity")||t.includes("workflow"))return"green";if(t.includes("learning")||t.includes("education"))return"purple";if(t.includes("security")||t.includes("safety"))return"red";if(t.includes("data")||t.includes("analytics"))return"orange";else if(t.includes("integration")||t.includes("api"))return"yellow";return"gray"},"isValidEmail",0,e=>!e||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"isValidSemanticVersion",0,e=>!e||/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(e),"isValidUrl",0,e=>{if(!e)return!0;try{return new URL(e),!0}catch{return!1}},"parseKeywords",0,e=>e&&""!==e.trim()?e.split(",").map(e=>e.trim()).filter(e=>""!==e):[],"validatePluginName",0,e=>!!e&&""!==e.trim()&&/^[a-z0-9-]+$/.test(e)],209261),e.s(["default",0,({skill:e,onBack:l})=>{let p,[d,c]=(0,i.useState)("overview"),[g,m]=(0,i.useState)(null),u=(e,t)=>{navigator.clipboard.writeText(e),m(t),setTimeout(()=>m(null),2e3)},f="github"===(p=e.source).source&&p.repo?`https://github.com/${p.repo}`:"git-subdir"===p.source&&p.url?p.path?`${p.url}/tree/main/${p.path}`:p.url:"url"===p.source&&p.url?p.url:null,_=s(e),h=[...e.category?[{property:"Category",value:e.category}]:[],...e.domain?[{property:"Domain",value:e.domain}]:[],...e.namespace?[{property:"Namespace",value:e.namespace}]:[],...e.version?[{property:"Version",value:e.version}]:[],...e.author?.name?[{property:"Author",value:e.author.name}]:[],...e.created_at?[{property:"Added",value:new Date(e.created_at).toLocaleDateString()}]:[]];return(0,t.jsxs)("div",{style:{padding:"24px 32px 24px 0"},children:[(0,t.jsxs)("div",{onClick:l,style:{display:"inline-flex",alignItems:"center",gap:6,color:"#5f6368",cursor:"pointer",fontSize:14,marginBottom:24},children:[(0,t.jsx)(a.ArrowLeftOutlined,{style:{fontSize:11}}),(0,t.jsx)("span",{children:"Skills"})]}),(0,t.jsxs)("div",{style:{marginBottom:8},children:[(0,t.jsx)("h1",{style:{fontSize:28,fontWeight:400,color:"#202124",margin:0,lineHeight:1.2},children:e.name}),e.description&&(0,t.jsx)("p",{style:{fontSize:14,color:"#5f6368",margin:"8px 0 0 0",lineHeight:1.6},children:e.description})]}),(0,t.jsx)("div",{style:{borderBottom:"1px solid #dadce0",marginBottom:28,marginTop:24},children:(0,t.jsx)("div",{style:{display:"flex",gap:0},children:[{key:"overview",label:"Overview"},{key:"usage",label:"How to Use"}].map(e=>(0,t.jsx)("div",{onClick:()=>c(e.key),style:{padding:"12px 20px",fontSize:14,color:d===e.key?"#1a73e8":"#5f6368",borderBottom:d===e.key?"3px solid #1a73e8":"3px solid transparent",cursor:"pointer",fontWeight:d===e.key?500:400,marginBottom:-1},children:e.label},e.key))})}),"overview"===d&&(0,t.jsxs)("div",{style:{display:"flex",gap:64},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 4px 0"},children:"Skill Details"}),(0,t.jsx)("p",{style:{fontSize:13,color:"#5f6368",margin:"0 0 16px 0"},children:"Metadata registered with this skill"}),(0,t.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:14},children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500,width:160},children:"Property"}),(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500},children:e.name})]})}),(0,t.jsx)("tbody",{children:h.map((e,i)=>(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #f1f3f4"},children:[(0,t.jsx)("td",{style:{padding:"12px 0",color:"#3c4043"},children:e.property}),(0,t.jsx)("td",{style:{padding:"12px 0",color:"#202124"},children:e.value})]},i))})]})]}),(0,t.jsxs)("div",{style:{width:240,flexShrink:0},children:[(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Status"}),(0,t.jsx)("span",{style:{fontSize:12,padding:"3px 10px",borderRadius:12,backgroundColor:e.enabled?"#e6f4ea":"#f1f3f4",color:e.enabled?"#137333":"#5f6368",fontWeight:500},children:e.enabled?"Public":"Draft"})]}),f&&(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Source"}),(0,t.jsxs)("a",{href:f,target:"_blank",rel:"noopener noreferrer",style:{fontSize:13,color:"#1a73e8",wordBreak:"break-all",display:"flex",alignItems:"center",gap:4},children:[f.replace("https://",""),(0,t.jsx)(n.LinkOutlined,{style:{fontSize:11,flexShrink:0}})]})]}),e.keywords&&e.keywords.length>0&&(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:8},children:"Tags"}),(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.keywords.map(e=>(0,t.jsx)("span",{style:{fontSize:12,padding:"4px 12px",borderRadius:16,border:"1px solid #dadce0",color:"#3c4043",backgroundColor:"#fff"},children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Skill ID"}),(0,t.jsx)("div",{style:{fontSize:12,fontFamily:"monospace",color:"#3c4043",wordBreak:"break-all"},children:e.id})]})]})]}),"usage"===d&&(0,t.jsxs)("div",{style:{maxWidth:640},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 8px 0"},children:"Using this skill"}),(0,t.jsx)("p",{style:{fontSize:14,color:"#5f6368",margin:"0 0 24px 0",lineHeight:1.6},children:"Once your proxy is set as a marketplace, enable this skill in Claude Code with one command:"}),(0,t.jsxs)("div",{style:{border:"1px solid #dadce0",borderRadius:8,overflow:"hidden",marginBottom:24},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",backgroundColor:"#f8f9fa",borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("span",{style:{fontSize:13,color:"#3c4043",fontWeight:500},children:"Run in Claude Code"}),(0,t.jsxs)("button",{onClick:()=>u(_,"install"),style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"install"===g?"#137333":"#1a73e8",background:"none",border:"none",cursor:"pointer",padding:0},children:["install"===g?(0,t.jsx)(r.CheckOutlined,{}):(0,t.jsx)(o.CopyOutlined,{}),"install"===g?"Copied":"Copy"]})]}),(0,t.jsx)("pre",{style:{margin:0,padding:"14px 16px",fontSize:14,fontFamily:"monospace",color:"#202124",backgroundColor:"#fff"},children:_})]}),(0,t.jsxs)("p",{style:{fontSize:13,color:"#5f6368",lineHeight:1.6,margin:0},children:["Don't have the marketplace configured yet?"," ",(0,t.jsx)("span",{onClick:()=>c("setup"),style:{color:"#1a73e8",cursor:"pointer"},children:"See one-time setup →"})]})]}),"setup"===d&&(0,t.jsxs)("div",{style:{maxWidth:640},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 8px 0"},children:"One-time marketplace setup"}),(0,t.jsxs)("p",{style:{fontSize:14,color:"#5f6368",margin:"0 0 24px 0",lineHeight:1.6},children:["Add this to ",(0,t.jsx)("code",{style:{fontSize:13,backgroundColor:"#f1f3f4",padding:"1px 6px",borderRadius:4},children:"~/.claude/settings.json"})," to point Claude Code at your proxy:"]}),(0,t.jsxs)("div",{style:{border:"1px solid #dadce0",borderRadius:8,overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",backgroundColor:"#f8f9fa",borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("span",{style:{fontSize:13,color:"#3c4043",fontWeight:500},children:"~/.claude/settings.json"}),(0,t.jsxs)("button",{onClick:()=>{u(JSON.stringify({extraKnownMarketplaces:{"my-org":{source:"url",url:`${window.location.origin}/claude-code/marketplace.json`}}},null,2),"settings")},style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"settings"===g?"#137333":"#1a73e8",background:"none",border:"none",cursor:"pointer",padding:0},children:["settings"===g?(0,t.jsx)(r.CheckOutlined,{}):(0,t.jsx)(o.CopyOutlined,{}),"settings"===g?"Copied":"Copy"]})]}),(0,t.jsx)("pre",{style:{margin:0,padding:"14px 16px",fontSize:13,fontFamily:"monospace",color:"#202124",backgroundColor:"#fff"},children:JSON.stringify({extraKnownMarketplaces:{"my-org":{source:"url",url:`${window.location.origin}/claude-code/marketplace.json`}}},null,2)})]})]})]})}],652272)},94629,e=>{"use strict";var t=e.i(271645);let i=t.forwardRef(function(e,i){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:i},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"}))});e.s(["SwitchVerticalIcon",0,i],94629)},991124,e=>{"use strict";let t=(0,e.i(475254).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["default",()=>t])},879664,e=>{"use strict";let t=(0,e.i(475254).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);e.s(["default",()=>t])},916925,e=>{"use strict";var t,i=((t={}).A2A_Agent="A2A Agent",t.AI21="Ai21",t.AI21_CHAT="Ai21 Chat",t.AIML="AI/ML API",t.AIOHTTP_OPENAI="Aiohttp Openai",t.Anthropic="Anthropic",t.ANTHROPIC_TEXT="Anthropic Text",t.AssemblyAI="AssemblyAI",t.AUTO_ROUTER="Auto Router",t.Bedrock="Amazon Bedrock",t.BedrockMantle="Amazon Bedrock Mantle",t.SageMaker="AWS SageMaker",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Foundry (Studio)",t.AZURE_TEXT="Azure Text",t.BASETEN="Baseten",t.BYTEZ="Bytez",t.Cerebras="Cerebras",t.CLARIFAI="Clarifai",t.CLOUDFLARE="Cloudflare",t.CODESTRAL="Codestral",t.Cohere="Cohere",t.COHERE_CHAT="Cohere Chat",t.COMETAPI="Cometapi",t.COMPACTIFAI="Compactifai",t.Cursor="Cursor",t.Dashscope="Dashscope",t.Databricks="Databricks (Qwen API)",t.DATAROBOT="Datarobot",t.DeepInfra="DeepInfra",t.Deepgram="Deepgram",t.Deepseek="Deepseek",t.DOCKER_MODEL_RUNNER="Docker Model Runner",t.DOTPROMPT="Dotprompt",t.ElevenLabs="ElevenLabs",t.EMPOWER="Empower",t.FalAI="Fal AI",t.FEATHERLESS_AI="Featherless Ai",t.FireworksAI="Fireworks AI",t.FRIENDLIAI="Friendliai",t.GALADRIEL="Galadriel",t.GITHUB_COPILOT="Github Copilot",t.Google_AI_Studio="Google AI Studio",t.GradientAI="GradientAI",t.Groq="Groq",t.HEROKU="Heroku",t.Hosted_Vllm="vllm",t.HUGGINGFACE="Huggingface",t.HYPERBOLIC="Hyperbolic",t.Infinity="Infinity",t.JinaAI="Jina AI",t.LAMBDA_AI="Lambda Ai",t.LEMONADE="Lemonade",t.LLAMAFILE="Llamafile",t.LM_STUDIO="Lm Studio",t.LLAMA="Meta Llama",t.MARITALK="Maritalk",t.MiniMax="MiniMax",t.MistralAI="Mistral AI",t.MOONSHOT="Moonshot",t.MORPH="Morph",t.NEBIUS="Nebius",t.NLP_CLOUD="Nlp Cloud",t.NOVITA="Novita",t.NSCALE="Nscale",t.NVIDIA_NIM="Nvidia Nim",t.Ollama="Ollama",t.OLLAMA_CHAT="Ollama Chat",t.OOBABOOGA="Oobabooga",t.OpenAI="OpenAI",t.OPENAI_LIKE="Openai Like",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.OpenAI_Text="OpenAI Text Completion",t.OpenAI_Text_Compatible="OpenAI-Compatible Text Completion Models (Together AI, etc.)",t.Openrouter="Openrouter",t.Oracle="Oracle Cloud Infrastructure (OCI)",t.OVHCLOUD="Ovhcloud",t.Perplexity="Perplexity",t.PETALS="Petals",t.PG_VECTOR="Pg Vector",t.PREDIBASE="Predibase",t.RECRAFT="Recraft",t.REPLICATE="Replicate",t.RunwayML="RunwayML",t.SAGEMAKER_LEGACY="Sagemaker",t.Sambanova="Sambanova",t.SAP="SAP Generative AI Hub",t.Snowflake="Snowflake",t.TEXT_COMPLETION_CODESTRAL="Text-Completion-Codestral",t.TogetherAI="TogetherAI",t.TOPAZ="Topaz",t.Triton="Triton",t.V0="V0",t.VERCEL_AI_GATEWAY="Vercel Ai Gateway",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.VERTEX_AI_BETA="Vertex Ai Beta",t.VLLM="Vllm",t.VolcEngine="VolcEngine",t.Voyage="Voyage AI",t.WANDB="Wandb",t.WATSONX="Watsonx",t.WATSONX_TEXT="Watsonx Text",t.xAI="xAI",t.XINFERENCE="Xinference",t);let a={A2A_Agent:"a2a_agent",AI21:"ai21",AI21_CHAT:"ai21_chat",AIML:"aiml",AIOHTTP_OPENAI:"aiohttp_openai",Anthropic:"anthropic",ANTHROPIC_TEXT:"anthropic_text",AssemblyAI:"assemblyai",AUTO_ROUTER:"auto_router",Azure:"azure",Azure_AI_Studio:"azure_ai",AZURE_TEXT:"azure_text",BASETEN:"baseten",Bedrock:"bedrock",BedrockMantle:"bedrock_mantle",BYTEZ:"bytez",Cerebras:"cerebras",CLARIFAI:"clarifai",CLOUDFLARE:"cloudflare",CODESTRAL:"codestral",Cohere:"cohere",COHERE_CHAT:"cohere_chat",COMETAPI:"cometapi",COMPACTIFAI:"compactifai",Cursor:"cursor",Dashscope:"dashscope",Databricks:"databricks",DATAROBOT:"datarobot",DeepInfra:"deepinfra",Deepgram:"deepgram",Deepseek:"deepseek",DOCKER_MODEL_RUNNER:"docker_model_runner",DOTPROMPT:"dotprompt",ElevenLabs:"elevenlabs",EMPOWER:"empower",FalAI:"fal_ai",FEATHERLESS_AI:"featherless_ai",FireworksAI:"fireworks_ai",FRIENDLIAI:"friendliai",GALADRIEL:"galadriel",GITHUB_COPILOT:"github_copilot",Google_AI_Studio:"gemini",GradientAI:"gradient_ai",Groq:"groq",HEROKU:"heroku",Hosted_Vllm:"hosted_vllm",HUGGINGFACE:"huggingface",HYPERBOLIC:"hyperbolic",Infinity:"infinity",JinaAI:"jina_ai",LAMBDA_AI:"lambda_ai",LEMONADE:"lemonade",LLAMAFILE:"llamafile",LLAMA:"meta_llama",LM_STUDIO:"lm_studio",MARITALK:"maritalk",MiniMax:"minimax",MistralAI:"mistral",MOONSHOT:"moonshot",MORPH:"morph",NEBIUS:"nebius",NLP_CLOUD:"nlp_cloud",NOVITA:"novita",NSCALE:"nscale",NVIDIA_NIM:"nvidia_nim",Ollama:"ollama",OLLAMA_CHAT:"ollama_chat",OOBABOOGA:"oobabooga",OpenAI:"openai",OPENAI_LIKE:"openai_like",OpenAI_Compatible:"openai",OpenAI_Text:"text-completion-openai",OpenAI_Text_Compatible:"text-completion-openai",Openrouter:"openrouter",Oracle:"oci",OVHCLOUD:"ovhcloud",Perplexity:"perplexity",PETALS:"petals",PG_VECTOR:"pg_vector",PREDIBASE:"predibase",RECRAFT:"recraft",REPLICATE:"replicate",RunwayML:"runwayml",SAGEMAKER_LEGACY:"sagemaker",SageMaker:"sagemaker_chat",Sambanova:"sambanova",SAP:"sap",Snowflake:"snowflake",TEXT_COMPLETION_CODESTRAL:"text-completion-codestral",TogetherAI:"together_ai",TOPAZ:"topaz",Triton:"triton",V0:"v0",VERCEL_AI_GATEWAY:"vercel_ai_gateway",Vertex_AI:"vertex_ai",VERTEX_AI_BETA:"vertex_ai_beta",VLLM:"vllm",VolcEngine:"volcengine",Voyage:"voyage",WANDB:"wandb",WATSONX:"watsonx",WATSONX_TEXT:"watsonx_text",xAI:"xai",XINFERENCE:"xinference"},o="../ui/assets/logos/",r={"A2A Agent":`${o}a2a_agent.png`,Ai21:`${o}ai21.svg`,"Ai21 Chat":`${o}ai21.svg`,"AI/ML API":`${o}aiml_api.svg`,"Aiohttp Openai":`${o}openai_small.svg`,Anthropic:`${o}anthropic.svg`,"Anthropic Text":`${o}anthropic.svg`,AssemblyAI:`${o}assemblyai_small.png`,Azure:`${o}microsoft_azure.svg`,"Azure AI Foundry (Studio)":`${o}microsoft_azure.svg`,"Azure Text":`${o}microsoft_azure.svg`,Baseten:`${o}baseten.svg`,"Amazon Bedrock":`${o}bedrock.svg`,"Amazon Bedrock Mantle":`${o}bedrock.svg`,"AWS SageMaker":`${o}bedrock.svg`,Cerebras:`${o}cerebras.svg`,Cloudflare:`${o}cloudflare.svg`,Codestral:`${o}mistral.svg`,Cohere:`${o}cohere.svg`,"Cohere Chat":`${o}cohere.svg`,Cometapi:`${o}cometapi.svg`,Cursor:`${o}cursor.svg`,"Databricks (Qwen API)":`${o}databricks.svg`,Dashscope:`${o}dashscope.svg`,Deepseek:`${o}deepseek.svg`,Deepgram:`${o}deepgram.png`,DeepInfra:`${o}deepinfra.png`,ElevenLabs:`${o}elevenlabs.png`,"Fal AI":`${o}fal_ai.jpg`,"Featherless Ai":`${o}featherless.svg`,"Fireworks AI":`${o}fireworks.svg`,Friendliai:`${o}friendli.svg`,"Github Copilot":`${o}github_copilot.svg`,"Google AI Studio":`${o}google.svg`,GradientAI:`${o}gradientai.svg`,Groq:`${o}groq.svg`,vllm:`${o}vllm.png`,Huggingface:`${o}huggingface.svg`,Hyperbolic:`${o}hyperbolic.svg`,Infinity:`${o}infinity.png`,"Jina AI":`${o}jina.png`,"Lambda Ai":`${o}lambda.svg`,"Lm Studio":`${o}lmstudio.svg`,"Meta Llama":`${o}meta_llama.svg`,MiniMax:`${o}minimax.svg`,"Mistral AI":`${o}mistral.svg`,Moonshot:`${o}moonshot.svg`,Morph:`${o}morph.svg`,Nebius:`${o}nebius.svg`,Novita:`${o}novita.svg`,"Nvidia Nim":`${o}nvidia_nim.svg`,Ollama:`${o}ollama.svg`,"Ollama Chat":`${o}ollama.svg`,Oobabooga:`${o}openai_small.svg`,OpenAI:`${o}openai_small.svg`,"Openai Like":`${o}openai_small.svg`,"OpenAI Text Completion":`${o}openai_small.svg`,"OpenAI-Compatible Text Completion Models (Together AI, etc.)":`${o}openai_small.svg`,"OpenAI-Compatible Endpoints (Together AI, etc.)":`${o}openai_small.svg`,Openrouter:`${o}openrouter.svg`,"Oracle Cloud Infrastructure (OCI)":`${o}oracle.svg`,Perplexity:`${o}perplexity-ai.svg`,Recraft:`${o}recraft.svg`,Replicate:`${o}replicate.svg`,RunwayML:`${o}runwayml.png`,Sagemaker:`${o}bedrock.svg`,Sambanova:`${o}sambanova.svg`,"SAP Generative AI Hub":`${o}sap.png`,Snowflake:`${o}snowflake.svg`,"Text-Completion-Codestral":`${o}mistral.svg`,TogetherAI:`${o}togetherai.svg`,Topaz:`${o}topaz.svg`,Triton:`${o}nvidia_triton.png`,V0:`${o}v0.svg`,"Vercel Ai Gateway":`${o}vercel.svg`,"Vertex AI (Anthropic, Gemini, etc.)":`${o}google.svg`,"Vertex Ai Beta":`${o}google.svg`,Vllm:`${o}vllm.png`,VolcEngine:`${o}volcengine.png`,"Voyage AI":`${o}voyage.webp`,Watsonx:`${o}watsonx.svg`,"Watsonx Text":`${o}watsonx.svg`,xAI:`${o}xai.svg`,Xinference:`${o}xinference.svg`};e.s(["Providers",()=>i,"getPlaceholder",0,e=>{if("AI/ML API"===e)return"aiml/flux-pro/v1.1";if("Vertex AI (Anthropic, Gemini, etc.)"===e)return"gemini-pro";if("Anthropic"==e)return"claude-3-opus";if("Amazon Bedrock"==e)return"claude-3-opus";if("AWS SageMaker"==e)return"sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b";else if("Google AI Studio"==e)return"gemini-pro";else if("Azure AI Foundry (Studio)"==e)return"azure_ai/command-r-plus";else if("Azure"==e)return"my-deployment";else if("Oracle Cloud Infrastructure (OCI)"==e)return"oci/xai.grok-4";else if("Snowflake"==e)return"snowflake/mistral-7b";else if("Voyage AI"==e)return"voyage/";else if("Jina AI"==e)return"jina_ai/";else if("VolcEngine"==e)return"volcengine/";else if("DeepInfra"==e)return"deepinfra/";else if("Fal AI"==e)return"fal_ai/fal-ai/flux-pro/v1.1-ultra";else if("RunwayML"==e)return"runwayml/gen4_turbo";else if("Watsonx"===e)return"watsonx/ibm/granite-3-3-8b-instruct";else if("Cursor"===e)return"cursor/claude-4-sonnet";else return"gpt-3.5-turbo"},"getProviderLogoAndName",0,e=>{if(!e)return{logo:"",displayName:"-"};if("gemini"===e.toLowerCase()){let e="Google AI Studio";return{logo:r[e],displayName:e}}let t=Object.keys(a).find(t=>a[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let o=i[t];return{logo:r[o],displayName:o}},"getProviderModels",0,(e,t)=>{console.log(`Provider key: ${e}`);let i=a[e];console.log(`Provider mapped to: ${i}`);let o=[];return e&&"object"==typeof t&&(Object.entries(t).forEach(([e,t])=>{if(null!==t&&"object"==typeof t&&"litellm_provider"in t){let a=t.litellm_provider;(a===i||"string"==typeof a&&a.includes(i))&&o.push(e)}}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(t).forEach(([e,t])=>{null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere_chat"===t.litellm_provider&&o.push(e)})),"AWS SageMaker"==e&&(console.log("Adding sagemaker chat models"),Object.entries(t).forEach(([e,t])=>{null!==t&&"object"==typeof t&&"litellm_provider"in t&&"sagemaker_chat"===t.litellm_provider&&o.push(e)}))),o},"providerLogoMap",0,r,"provider_map",0,a])},798496,e=>{"use strict";var t=e.i(843476),i=e.i(152990),a=e.i(682830),o=e.i(271645),r=e.i(269200),n=e.i(427612),s=e.i(64848),l=e.i(942232),p=e.i(496020),d=e.i(977572),c=e.i(94629),g=e.i(360820),m=e.i(871943);function u({data:e=[],columns:u,isLoading:f=!1,defaultSorting:_=[],pagination:h,onPaginationChange:A,enablePagination:x=!1,onRowClick:b}){let[y,I]=o.default.useState(_),[v]=o.default.useState("onChange"),[C,E]=o.default.useState({}),[O,T]=o.default.useState({}),S=(0,i.useReactTable)({data:e,columns:u,state:{sorting:y,columnSizing:C,columnVisibility:O,...x&&h?{pagination:h}:{}},columnResizeMode:v,onSortingChange:I,onColumnSizingChange:E,onColumnVisibilityChange:T,...x&&A?{onPaginationChange:A}:{},getCoreRowModel:(0,a.getCoreRowModel)(),getSortedRowModel:(0,a.getSortedRowModel)(),...x?{getPaginationRowModel:(0,a.getPaginationRowModel)()}:{},enableSorting:!0,enableColumnResizing:!0,defaultColumn:{minSize:40,maxSize:500}});return(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsx)("div",{className:"relative min-w-full",children:(0,t.jsxs)(r.Table,{className:"[&_td]:py-2 [&_th]:py-2",style:{width:S.getTotalSize(),minWidth:"100%",tableLayout:"fixed"},children:[(0,t.jsx)(n.TableHead,{children:S.getHeaderGroups().map(e=>(0,t.jsx)(p.TableRow,{children:e.headers.map(e=>(0,t.jsxs)(s.TableHeaderCell,{className:`py-1 h-8 relative ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""} ${e.column.columnDef.meta?.className||""}`,style:{width:"actions"===e.id?120:e.getSize(),position:"actions"===e.id?"sticky":"relative",right:"actions"===e.id?0:"auto"},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,i.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&(0,t.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,t.jsx)(g.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,t.jsx)(m.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,t.jsx)(c.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]}),e.column.getCanResize()&&(0,t.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:`absolute right-0 top-0 h-full w-2 cursor-col-resize select-none touch-none ${e.column.getIsResizing()?"bg-blue-500":"hover:bg-blue-200"}`})]},e.id))},e.id))}),(0,t.jsx)(l.TableBody,{children:f?(0,t.jsx)(p.TableRow,{children:(0,t.jsx)(d.TableCell,{colSpan:u.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"🚅 Loading models..."})})})}):S.getRowModel().rows.length>0?S.getRowModel().rows.map(e=>(0,t.jsx)(p.TableRow,{onClick:()=>b?.(e.original),className:b?"cursor-pointer hover:bg-gray-50":"",children:e.getVisibleCells().map(e=>(0,t.jsx)(d.TableCell,{className:`py-0.5 overflow-hidden ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""} ${e.column.columnDef.meta?.className||""}`,style:{width:"actions"===e.column.id?120:e.column.getSize(),position:"actions"===e.column.id?"sticky":"relative",right:"actions"===e.column.id?0:"auto"},children:(0,i.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,t.jsx)(p.TableRow,{children:(0,t.jsx)(d.TableCell,{colSpan:u.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"No models found"})})})})})]})})})})}e.s(["ModelDataTable",()=>u])}]); \ No newline at end of file +${t}`}],190272)},652272,209261,e=>{"use strict";var t=e.i(843476),i=e.i(271645),a=e.i(447566),o=e.i(166406),r=e.i(492030),n=e.i(596239);let s=e=>"github"===e.source.source&&e.source.repo?`/plugin marketplace add ${e.source.repo}`:"url"===e.source.source&&e.source.url?`/plugin marketplace add ${e.source.url}`:`/plugin marketplace add ${e.name}`;e.s(["formatInstallCommand",0,s,"getCategoryBadgeColor",0,e=>{if(!e)return"gray";let t=e.toLowerCase();if(t.includes("development")||t.includes("dev"))return"blue";if(t.includes("productivity")||t.includes("workflow"))return"green";if(t.includes("learning")||t.includes("education"))return"purple";if(t.includes("security")||t.includes("safety"))return"red";if(t.includes("data")||t.includes("analytics"))return"orange";else if(t.includes("integration")||t.includes("api"))return"yellow";return"gray"},"isValidEmail",0,e=>!e||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),"isValidSemanticVersion",0,e=>!e||/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(e),"isValidUrl",0,e=>{if(!e)return!0;try{return new URL(e),!0}catch{return!1}},"parseKeywords",0,e=>e&&""!==e.trim()?e.split(",").map(e=>e.trim()).filter(e=>""!==e):[],"validatePluginName",0,e=>!!e&&""!==e.trim()&&/^[a-z0-9-]+$/.test(e)],209261),e.s(["default",0,({skill:e,onBack:l})=>{let p,[d,c]=(0,i.useState)("overview"),[g,m]=(0,i.useState)(null),u=(e,t)=>{navigator.clipboard.writeText(e),m(t),setTimeout(()=>m(null),2e3)},f="github"===(p=e.source).source&&p.repo?`https://github.com/${p.repo}`:"git-subdir"===p.source&&p.url?p.path?`${p.url}/tree/main/${p.path}`:p.url:"url"===p.source&&p.url?p.url:null,_=s(e),h=[...e.category?[{property:"Category",value:e.category}]:[],...e.domain?[{property:"Domain",value:e.domain}]:[],...e.namespace?[{property:"Namespace",value:e.namespace}]:[],...e.version?[{property:"Version",value:e.version}]:[],...e.author?.name?[{property:"Author",value:e.author.name}]:[],...e.created_at?[{property:"Added",value:new Date(e.created_at).toLocaleDateString()}]:[]];return(0,t.jsxs)("div",{style:{padding:"24px 32px 24px 0"},children:[(0,t.jsxs)("div",{onClick:l,style:{display:"inline-flex",alignItems:"center",gap:6,color:"#5f6368",cursor:"pointer",fontSize:14,marginBottom:24},children:[(0,t.jsx)(a.ArrowLeftOutlined,{style:{fontSize:11}}),(0,t.jsx)("span",{children:"Skills"})]}),(0,t.jsxs)("div",{style:{marginBottom:8},children:[(0,t.jsx)("h1",{style:{fontSize:28,fontWeight:400,color:"#202124",margin:0,lineHeight:1.2},children:e.name}),e.description&&(0,t.jsx)("p",{style:{fontSize:14,color:"#5f6368",margin:"8px 0 0 0",lineHeight:1.6},children:e.description})]}),(0,t.jsx)("div",{style:{borderBottom:"1px solid #dadce0",marginBottom:28,marginTop:24},children:(0,t.jsx)("div",{style:{display:"flex",gap:0},children:[{key:"overview",label:"Overview"},{key:"usage",label:"How to Use"}].map(e=>(0,t.jsx)("div",{onClick:()=>c(e.key),style:{padding:"12px 20px",fontSize:14,color:d===e.key?"#1a73e8":"#5f6368",borderBottom:d===e.key?"3px solid #1a73e8":"3px solid transparent",cursor:"pointer",fontWeight:d===e.key?500:400,marginBottom:-1},children:e.label},e.key))})}),"overview"===d&&(0,t.jsxs)("div",{style:{display:"flex",gap:64},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 4px 0"},children:"Skill Details"}),(0,t.jsx)("p",{style:{fontSize:13,color:"#5f6368",margin:"0 0 16px 0"},children:"Metadata registered with this skill"}),(0,t.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:14},children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500,width:160},children:"Property"}),(0,t.jsx)("th",{style:{textAlign:"left",padding:"12px 0",color:"#5f6368",fontWeight:500},children:e.name})]})}),(0,t.jsx)("tbody",{children:h.map((e,i)=>(0,t.jsxs)("tr",{style:{borderBottom:"1px solid #f1f3f4"},children:[(0,t.jsx)("td",{style:{padding:"12px 0",color:"#3c4043"},children:e.property}),(0,t.jsx)("td",{style:{padding:"12px 0",color:"#202124"},children:e.value})]},i))})]})]}),(0,t.jsxs)("div",{style:{width:240,flexShrink:0},children:[(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Status"}),(0,t.jsx)("span",{style:{fontSize:12,padding:"3px 10px",borderRadius:12,backgroundColor:e.enabled?"#e6f4ea":"#f1f3f4",color:e.enabled?"#137333":"#5f6368",fontWeight:500},children:e.enabled?"Public":"Draft"})]}),f&&(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Source"}),(0,t.jsxs)("a",{href:f,target:"_blank",rel:"noopener noreferrer",style:{fontSize:13,color:"#1a73e8",wordBreak:"break-all",display:"flex",alignItems:"center",gap:4},children:[f.replace("https://",""),(0,t.jsx)(n.LinkOutlined,{style:{fontSize:11,flexShrink:0}})]})]}),e.keywords&&e.keywords.length>0&&(0,t.jsxs)("div",{style:{marginBottom:24},children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:8},children:"Tags"}),(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.keywords.map(e=>(0,t.jsx)("span",{style:{fontSize:12,padding:"4px 12px",borderRadius:16,border:"1px solid #dadce0",color:"#3c4043",backgroundColor:"#fff"},children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:12,color:"#5f6368",marginBottom:4},children:"Skill ID"}),(0,t.jsx)("div",{style:{fontSize:12,fontFamily:"monospace",color:"#3c4043",wordBreak:"break-all"},children:e.id})]})]})]}),"usage"===d&&(0,t.jsxs)("div",{style:{maxWidth:640},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 8px 0"},children:"Using this skill"}),(0,t.jsx)("p",{style:{fontSize:14,color:"#5f6368",margin:"0 0 24px 0",lineHeight:1.6},children:"Once your proxy is set as a marketplace, enable this skill in Claude Code with one command:"}),(0,t.jsxs)("div",{style:{border:"1px solid #dadce0",borderRadius:8,overflow:"hidden",marginBottom:24},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",backgroundColor:"#f8f9fa",borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("span",{style:{fontSize:13,color:"#3c4043",fontWeight:500},children:"Run in Claude Code"}),(0,t.jsxs)("button",{onClick:()=>u(_,"install"),style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"install"===g?"#137333":"#1a73e8",background:"none",border:"none",cursor:"pointer",padding:0},children:["install"===g?(0,t.jsx)(r.CheckOutlined,{}):(0,t.jsx)(o.CopyOutlined,{}),"install"===g?"Copied":"Copy"]})]}),(0,t.jsx)("pre",{style:{margin:0,padding:"14px 16px",fontSize:14,fontFamily:"monospace",color:"#202124",backgroundColor:"#fff"},children:_})]}),(0,t.jsxs)("p",{style:{fontSize:13,color:"#5f6368",lineHeight:1.6,margin:0},children:["Don't have the marketplace configured yet?"," ",(0,t.jsx)("span",{onClick:()=>c("setup"),style:{color:"#1a73e8",cursor:"pointer"},children:"See one-time setup →"})]})]}),"setup"===d&&(0,t.jsxs)("div",{style:{maxWidth:640},children:[(0,t.jsx)("h2",{style:{fontSize:18,fontWeight:400,color:"#202124",margin:"0 0 8px 0"},children:"One-time marketplace setup"}),(0,t.jsxs)("p",{style:{fontSize:14,color:"#5f6368",margin:"0 0 24px 0",lineHeight:1.6},children:["Add this to ",(0,t.jsx)("code",{style:{fontSize:13,backgroundColor:"#f1f3f4",padding:"1px 6px",borderRadius:4},children:"~/.claude/settings.json"})," to point Claude Code at your proxy:"]}),(0,t.jsxs)("div",{style:{border:"1px solid #dadce0",borderRadius:8,overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",backgroundColor:"#f8f9fa",borderBottom:"1px solid #dadce0"},children:[(0,t.jsx)("span",{style:{fontSize:13,color:"#3c4043",fontWeight:500},children:"~/.claude/settings.json"}),(0,t.jsxs)("button",{onClick:()=>{u(JSON.stringify({extraKnownMarketplaces:{"my-org":{source:"url",url:`${window.location.origin}/claude-code/marketplace.json`}}},null,2),"settings")},style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"settings"===g?"#137333":"#1a73e8",background:"none",border:"none",cursor:"pointer",padding:0},children:["settings"===g?(0,t.jsx)(r.CheckOutlined,{}):(0,t.jsx)(o.CopyOutlined,{}),"settings"===g?"Copied":"Copy"]})]}),(0,t.jsx)("pre",{style:{margin:0,padding:"14px 16px",fontSize:13,fontFamily:"monospace",color:"#202124",backgroundColor:"#fff"},children:JSON.stringify({extraKnownMarketplaces:{"my-org":{source:"url",url:`${window.location.origin}/claude-code/marketplace.json`}}},null,2)})]})]})]})}],652272)},879664,e=>{"use strict";let t=(0,e.i(475254).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);e.s(["default",()=>t])},916925,e=>{"use strict";var t,i=((t={}).A2A_Agent="A2A Agent",t.AI21="Ai21",t.AI21_CHAT="Ai21 Chat",t.AIML="AI/ML API",t.AIOHTTP_OPENAI="Aiohttp Openai",t.Anthropic="Anthropic",t.ANTHROPIC_TEXT="Anthropic Text",t.AssemblyAI="AssemblyAI",t.AUTO_ROUTER="Auto Router",t.Bedrock="Amazon Bedrock",t.BedrockMantle="Amazon Bedrock Mantle",t.SageMaker="AWS SageMaker",t.Azure="Azure",t.Azure_AI_Studio="Azure AI Foundry (Studio)",t.AZURE_TEXT="Azure Text",t.BASETEN="Baseten",t.BYTEZ="Bytez",t.Cerebras="Cerebras",t.CLARIFAI="Clarifai",t.CLOUDFLARE="Cloudflare",t.CODESTRAL="Codestral",t.Cohere="Cohere",t.COHERE_CHAT="Cohere Chat",t.COMETAPI="Cometapi",t.COMPACTIFAI="Compactifai",t.Cursor="Cursor",t.Dashscope="Dashscope",t.Databricks="Databricks (Qwen API)",t.DATAROBOT="Datarobot",t.DeepInfra="DeepInfra",t.Deepgram="Deepgram",t.Deepseek="Deepseek",t.DOCKER_MODEL_RUNNER="Docker Model Runner",t.DOTPROMPT="Dotprompt",t.ElevenLabs="ElevenLabs",t.EMPOWER="Empower",t.FalAI="Fal AI",t.FEATHERLESS_AI="Featherless Ai",t.FireworksAI="Fireworks AI",t.FRIENDLIAI="Friendliai",t.GALADRIEL="Galadriel",t.GITHUB_COPILOT="Github Copilot",t.Google_AI_Studio="Google AI Studio",t.GradientAI="GradientAI",t.Groq="Groq",t.HEROKU="Heroku",t.Hosted_Vllm="vllm",t.HUGGINGFACE="Huggingface",t.HYPERBOLIC="Hyperbolic",t.Infinity="Infinity",t.JinaAI="Jina AI",t.LAMBDA_AI="Lambda Ai",t.LEMONADE="Lemonade",t.LLAMAFILE="Llamafile",t.LM_STUDIO="Lm Studio",t.LLAMA="Meta Llama",t.MARITALK="Maritalk",t.MiniMax="MiniMax",t.MistralAI="Mistral AI",t.MOONSHOT="Moonshot",t.MORPH="Morph",t.NEBIUS="Nebius",t.NLP_CLOUD="Nlp Cloud",t.NOVITA="Novita",t.NSCALE="Nscale",t.NVIDIA_NIM="Nvidia Nim",t.Ollama="Ollama",t.OLLAMA_CHAT="Ollama Chat",t.OOBABOOGA="Oobabooga",t.OpenAI="OpenAI",t.OPENAI_LIKE="Openai Like",t.OpenAI_Compatible="OpenAI-Compatible Endpoints (Together AI, etc.)",t.OpenAI_Text="OpenAI Text Completion",t.OpenAI_Text_Compatible="OpenAI-Compatible Text Completion Models (Together AI, etc.)",t.Openrouter="Openrouter",t.Oracle="Oracle Cloud Infrastructure (OCI)",t.OVHCLOUD="Ovhcloud",t.Perplexity="Perplexity",t.PETALS="Petals",t.PG_VECTOR="Pg Vector",t.PREDIBASE="Predibase",t.RECRAFT="Recraft",t.REPLICATE="Replicate",t.RunwayML="RunwayML",t.SAGEMAKER_LEGACY="Sagemaker",t.Sambanova="Sambanova",t.SAP="SAP Generative AI Hub",t.Snowflake="Snowflake",t.TEXT_COMPLETION_CODESTRAL="Text-Completion-Codestral",t.TogetherAI="TogetherAI",t.TOPAZ="Topaz",t.Triton="Triton",t.V0="V0",t.VERCEL_AI_GATEWAY="Vercel Ai Gateway",t.Vertex_AI="Vertex AI (Anthropic, Gemini, etc.)",t.VERTEX_AI_BETA="Vertex Ai Beta",t.VLLM="Vllm",t.VolcEngine="VolcEngine",t.Voyage="Voyage AI",t.WANDB="Wandb",t.WATSONX="Watsonx",t.WATSONX_TEXT="Watsonx Text",t.xAI="xAI",t.XINFERENCE="Xinference",t.ZAI="Z.AI (Zhipu AI)",t);let a={A2A_Agent:"a2a_agent",AI21:"ai21",AI21_CHAT:"ai21_chat",AIML:"aiml",AIOHTTP_OPENAI:"aiohttp_openai",Anthropic:"anthropic",ANTHROPIC_TEXT:"anthropic_text",AssemblyAI:"assemblyai",AUTO_ROUTER:"auto_router",Azure:"azure",Azure_AI_Studio:"azure_ai",AZURE_TEXT:"azure_text",BASETEN:"baseten",Bedrock:"bedrock",BedrockMantle:"bedrock_mantle",BYTEZ:"bytez",Cerebras:"cerebras",CLARIFAI:"clarifai",CLOUDFLARE:"cloudflare",CODESTRAL:"codestral",Cohere:"cohere",COHERE_CHAT:"cohere_chat",COMETAPI:"cometapi",COMPACTIFAI:"compactifai",Cursor:"cursor",Dashscope:"dashscope",Databricks:"databricks",DATAROBOT:"datarobot",DeepInfra:"deepinfra",Deepgram:"deepgram",Deepseek:"deepseek",DOCKER_MODEL_RUNNER:"docker_model_runner",DOTPROMPT:"dotprompt",ElevenLabs:"elevenlabs",EMPOWER:"empower",FalAI:"fal_ai",FEATHERLESS_AI:"featherless_ai",FireworksAI:"fireworks_ai",FRIENDLIAI:"friendliai",GALADRIEL:"galadriel",GITHUB_COPILOT:"github_copilot",Google_AI_Studio:"gemini",GradientAI:"gradient_ai",Groq:"groq",HEROKU:"heroku",Hosted_Vllm:"hosted_vllm",HUGGINGFACE:"huggingface",HYPERBOLIC:"hyperbolic",Infinity:"infinity",JinaAI:"jina_ai",LAMBDA_AI:"lambda_ai",LEMONADE:"lemonade",LLAMAFILE:"llamafile",LLAMA:"meta_llama",LM_STUDIO:"lm_studio",MARITALK:"maritalk",MiniMax:"minimax",MistralAI:"mistral",MOONSHOT:"moonshot",MORPH:"morph",NEBIUS:"nebius",NLP_CLOUD:"nlp_cloud",NOVITA:"novita",NSCALE:"nscale",NVIDIA_NIM:"nvidia_nim",Ollama:"ollama",OLLAMA_CHAT:"ollama_chat",OOBABOOGA:"oobabooga",OpenAI:"openai",OPENAI_LIKE:"openai_like",OpenAI_Compatible:"openai",OpenAI_Text:"text-completion-openai",OpenAI_Text_Compatible:"text-completion-openai",Openrouter:"openrouter",Oracle:"oci",OVHCLOUD:"ovhcloud",Perplexity:"perplexity",PETALS:"petals",PG_VECTOR:"pg_vector",PREDIBASE:"predibase",RECRAFT:"recraft",REPLICATE:"replicate",RunwayML:"runwayml",SAGEMAKER_LEGACY:"sagemaker",SageMaker:"sagemaker_chat",Sambanova:"sambanova",SAP:"sap",Snowflake:"snowflake",TEXT_COMPLETION_CODESTRAL:"text-completion-codestral",TogetherAI:"together_ai",TOPAZ:"topaz",Triton:"triton",V0:"v0",VERCEL_AI_GATEWAY:"vercel_ai_gateway",Vertex_AI:"vertex_ai",VERTEX_AI_BETA:"vertex_ai_beta",VLLM:"vllm",VolcEngine:"volcengine",Voyage:"voyage",WANDB:"wandb",WATSONX:"watsonx",WATSONX_TEXT:"watsonx_text",xAI:"xai",XINFERENCE:"xinference",ZAI:"zai"},o="../ui/assets/logos/",r={"A2A Agent":`${o}a2a_agent.png`,Ai21:`${o}ai21.svg`,"Ai21 Chat":`${o}ai21.svg`,"AI/ML API":`${o}aiml_api.svg`,"Aiohttp Openai":`${o}openai_small.svg`,Anthropic:`${o}anthropic.svg`,"Anthropic Text":`${o}anthropic.svg`,AssemblyAI:`${o}assemblyai_small.png`,Azure:`${o}microsoft_azure.svg`,"Azure AI Foundry (Studio)":`${o}microsoft_azure.svg`,"Azure Text":`${o}microsoft_azure.svg`,Baseten:`${o}baseten.svg`,"Amazon Bedrock":`${o}bedrock.svg`,"Amazon Bedrock Mantle":`${o}bedrock.svg`,"AWS SageMaker":`${o}bedrock.svg`,Cerebras:`${o}cerebras.svg`,Cloudflare:`${o}cloudflare.svg`,Codestral:`${o}mistral.svg`,Cohere:`${o}cohere.svg`,"Cohere Chat":`${o}cohere.svg`,Cometapi:`${o}cometapi.svg`,Cursor:`${o}cursor.svg`,"Databricks (Qwen API)":`${o}databricks.svg`,Dashscope:`${o}dashscope.svg`,Deepseek:`${o}deepseek.svg`,Deepgram:`${o}deepgram.png`,DeepInfra:`${o}deepinfra.png`,ElevenLabs:`${o}elevenlabs.png`,"Fal AI":`${o}fal_ai.jpg`,"Featherless Ai":`${o}featherless.svg`,"Fireworks AI":`${o}fireworks.svg`,Friendliai:`${o}friendli.svg`,"Github Copilot":`${o}github_copilot.svg`,"Google AI Studio":`${o}google.svg`,GradientAI:`${o}gradientai.svg`,Groq:`${o}groq.svg`,vllm:`${o}vllm.png`,Huggingface:`${o}huggingface.svg`,Hyperbolic:`${o}hyperbolic.svg`,Infinity:`${o}infinity.png`,"Jina AI":`${o}jina.png`,"Lambda Ai":`${o}lambda.svg`,"Lm Studio":`${o}lmstudio.svg`,"Meta Llama":`${o}meta_llama.svg`,MiniMax:`${o}minimax.svg`,"Mistral AI":`${o}mistral.svg`,Moonshot:`${o}moonshot.svg`,Morph:`${o}morph.svg`,Nebius:`${o}nebius.svg`,Novita:`${o}novita.svg`,"Nvidia Nim":`${o}nvidia_nim.svg`,Ollama:`${o}ollama.svg`,"Ollama Chat":`${o}ollama.svg`,Oobabooga:`${o}openai_small.svg`,OpenAI:`${o}openai_small.svg`,"Openai Like":`${o}openai_small.svg`,"OpenAI Text Completion":`${o}openai_small.svg`,"OpenAI-Compatible Text Completion Models (Together AI, etc.)":`${o}openai_small.svg`,"OpenAI-Compatible Endpoints (Together AI, etc.)":`${o}openai_small.svg`,Openrouter:`${o}openrouter.svg`,"Oracle Cloud Infrastructure (OCI)":`${o}oracle.svg`,Perplexity:`${o}perplexity-ai.svg`,Recraft:`${o}recraft.svg`,Replicate:`${o}replicate.svg`,RunwayML:`${o}runwayml.png`,Sagemaker:`${o}bedrock.svg`,Sambanova:`${o}sambanova.svg`,"SAP Generative AI Hub":`${o}sap.png`,Snowflake:`${o}snowflake.svg`,"Text-Completion-Codestral":`${o}mistral.svg`,TogetherAI:`${o}togetherai.svg`,Topaz:`${o}topaz.svg`,Triton:`${o}nvidia_triton.png`,V0:`${o}v0.svg`,"Vercel Ai Gateway":`${o}vercel.svg`,"Vertex AI (Anthropic, Gemini, etc.)":`${o}google.svg`,"Vertex Ai Beta":`${o}google.svg`,Vllm:`${o}vllm.png`,VolcEngine:`${o}volcengine.png`,"Voyage AI":`${o}voyage.webp`,Watsonx:`${o}watsonx.svg`,"Watsonx Text":`${o}watsonx.svg`,xAI:`${o}xai.svg`,Xinference:`${o}xinference.svg`};e.s(["Providers",()=>i,"getPlaceholder",0,e=>{if("AI/ML API"===e)return"aiml/flux-pro/v1.1";if("Vertex AI (Anthropic, Gemini, etc.)"===e)return"gemini-pro";if("Anthropic"==e)return"claude-3-opus";if("Amazon Bedrock"==e)return"claude-3-opus";if("AWS SageMaker"==e)return"sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b";else if("Google AI Studio"==e)return"gemini-pro";else if("Azure AI Foundry (Studio)"==e)return"azure_ai/command-r-plus";else if("Azure"==e)return"my-deployment";else if("Oracle Cloud Infrastructure (OCI)"==e)return"oci/xai.grok-4";else if("Snowflake"==e)return"snowflake/mistral-7b";else if("Voyage AI"==e)return"voyage/";else if("Jina AI"==e)return"jina_ai/";else if("VolcEngine"==e)return"volcengine/";else if("DeepInfra"==e)return"deepinfra/";else if("Fal AI"==e)return"fal_ai/fal-ai/flux-pro/v1.1-ultra";else if("RunwayML"==e)return"runwayml/gen4_turbo";else if("Watsonx"===e)return"watsonx/ibm/granite-3-3-8b-instruct";else if("Cursor"===e)return"cursor/claude-4-sonnet";else if("Z.AI (Zhipu AI)"===e)return"zai/glm-4.5";else return"gpt-3.5-turbo"},"getProviderLogoAndName",0,e=>{if(!e)return{logo:"",displayName:"-"};if("gemini"===e.toLowerCase()){let e="Google AI Studio";return{logo:r[e],displayName:e}}let t=Object.keys(a).find(t=>a[t].toLowerCase()===e.toLowerCase());if(!t)return{logo:"",displayName:e};let o=i[t];return{logo:r[o],displayName:o}},"getProviderModels",0,(e,t)=>{console.log(`Provider key: ${e}`);let i=a[e];console.log(`Provider mapped to: ${i}`);let o=[];return e&&"object"==typeof t&&(Object.entries(t).forEach(([e,t])=>{if(null!==t&&"object"==typeof t&&"litellm_provider"in t){let a=t.litellm_provider;(a===i||"string"==typeof a&&a.includes(i))&&o.push(e)}}),"Cohere"==e&&(console.log("Adding cohere chat models"),Object.entries(t).forEach(([e,t])=>{null!==t&&"object"==typeof t&&"litellm_provider"in t&&"cohere_chat"===t.litellm_provider&&o.push(e)})),"AWS SageMaker"==e&&(console.log("Adding sagemaker chat models"),Object.entries(t).forEach(([e,t])=>{null!==t&&"object"==typeof t&&"litellm_provider"in t&&"sagemaker_chat"===t.litellm_provider&&o.push(e)}))),o},"providerLogoMap",0,r,"provider_map",0,a])},798496,e=>{"use strict";var t=e.i(843476),i=e.i(152990),a=e.i(682830),o=e.i(271645),r=e.i(269200),n=e.i(427612),s=e.i(64848),l=e.i(942232),p=e.i(496020),d=e.i(977572),c=e.i(94629),g=e.i(360820),m=e.i(871943);function u({data:e=[],columns:u,isLoading:f=!1,defaultSorting:_=[],pagination:h,onPaginationChange:A,enablePagination:x=!1,onRowClick:b}){let[y,I]=o.default.useState(_),[v]=o.default.useState("onChange"),[C,E]=o.default.useState({}),[O,T]=o.default.useState({}),S=(0,i.useReactTable)({data:e,columns:u,state:{sorting:y,columnSizing:C,columnVisibility:O,...x&&h?{pagination:h}:{}},columnResizeMode:v,onSortingChange:I,onColumnSizingChange:E,onColumnVisibilityChange:T,...x&&A?{onPaginationChange:A}:{},getCoreRowModel:(0,a.getCoreRowModel)(),getSortedRowModel:(0,a.getSortedRowModel)(),...x?{getPaginationRowModel:(0,a.getPaginationRowModel)()}:{},enableSorting:!0,enableColumnResizing:!0,defaultColumn:{minSize:40,maxSize:500}});return(0,t.jsx)("div",{className:"rounded-lg custom-border relative",children:(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsx)("div",{className:"relative min-w-full",children:(0,t.jsxs)(r.Table,{className:"[&_td]:py-2 [&_th]:py-2",style:{width:S.getTotalSize(),minWidth:"100%",tableLayout:"fixed"},children:[(0,t.jsx)(n.TableHead,{children:S.getHeaderGroups().map(e=>(0,t.jsx)(p.TableRow,{children:e.headers.map(e=>(0,t.jsxs)(s.TableHeaderCell,{className:`py-1 h-8 relative ${"actions"===e.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""} ${e.column.columnDef.meta?.className||""}`,style:{width:"actions"===e.id?120:e.getSize(),position:"actions"===e.id?"sticky":"relative",right:"actions"===e.id?0:"auto"},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex items-center",children:e.isPlaceholder?null:(0,i.flexRender)(e.column.columnDef.header,e.getContext())}),"actions"!==e.id&&e.column.getCanSort()&&(0,t.jsx)("div",{className:"w-4",children:e.column.getIsSorted()?({asc:(0,t.jsx)(g.ChevronUpIcon,{className:"h-4 w-4 text-blue-500"}),desc:(0,t.jsx)(m.ChevronDownIcon,{className:"h-4 w-4 text-blue-500"})})[e.column.getIsSorted()]:(0,t.jsx)(c.SwitchVerticalIcon,{className:"h-4 w-4 text-gray-400"})})]}),e.column.getCanResize()&&(0,t.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:`absolute right-0 top-0 h-full w-2 cursor-col-resize select-none touch-none ${e.column.getIsResizing()?"bg-blue-500":"hover:bg-blue-200"}`})]},e.id))},e.id))}),(0,t.jsx)(l.TableBody,{children:f?(0,t.jsx)(p.TableRow,{children:(0,t.jsx)(d.TableCell,{colSpan:u.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"🚅 Loading models..."})})})}):S.getRowModel().rows.length>0?S.getRowModel().rows.map(e=>(0,t.jsx)(p.TableRow,{onClick:()=>b?.(e.original),className:b?"cursor-pointer hover:bg-gray-50":"",children:e.getVisibleCells().map(e=>(0,t.jsx)(d.TableCell,{className:`py-0.5 overflow-hidden ${"actions"===e.column.id?"sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)] w-[120px] ml-8":""} ${e.column.columnDef.meta?.className||""}`,style:{width:"actions"===e.column.id?120:e.column.getSize(),position:"actions"===e.column.id?"sticky":"relative",right:"actions"===e.column.id?0:"auto"},children:(0,i.flexRender)(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,t.jsx)(p.TableRow,{children:(0,t.jsx)(d.TableCell,{colSpan:u.length,className:"h-8 text-center",children:(0,t.jsx)("div",{className:"text-center text-gray-500",children:(0,t.jsx)("p",{children:"No models found"})})})})})]})})})})}e.s(["ModelDataTable",()=>u])}]); \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/_next/static/chunks/06b2ea8c776c2e9b.js b/litellm/proxy/_experimental/out/_next/static/chunks/06b2ea8c776c2e9b.js new file mode 100644 index 0000000000..fe571604a7 --- /dev/null +++ b/litellm/proxy/_experimental/out/_next/static/chunks/06b2ea8c776c2e9b.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,233538,e=>{"use strict";function t(e){let t=e.parentElement,r=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(r=t),t=t.parentElement;let l=(null==t?void 0:t.getAttribute("disabled"))==="";return!(l&&function(e){if(!e)return!1;let t=e.previousElementSibling;for(;null!==t;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}(r))&&l}e.s(["isDisabledReactIssue7711",()=>t])},220508,e=>{"use strict";var t=e.i(271645);let r=t.forwardRef(function(e,r){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:r},e),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"}))});e.s(["CheckCircleIcon",0,r],220508)},503269,214520,601893,694421,140721,942803,35889,722678,e=>{"use strict";var t=e.i(271645),r=e.i(914189);function l(e,l,s){let[a,n]=(0,t.useState)(s),i=void 0!==e,o=(0,t.useRef)(i),c=(0,t.useRef)(!1),d=(0,t.useRef)(!1);return!i||o.current||c.current?i||!o.current||d.current||(d.current=!0,o.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")):(c.current=!0,o.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")),[i?e:a,(0,r.useEvent)(e=>(i||n(e),null==l?void 0:l(e)))]}function s(e){let[r]=(0,t.useState)(e);return r}e.s(["useControllable",()=>l],503269),e.s(["useDefaultValue",()=>s],214520);let a=(0,t.createContext)(void 0);function n(){return(0,t.useContext)(a)}e.s(["useDisabled",()=>n],601893);var i=e.i(174080),o=e.i(746725);function c(e={},t=null,r=[]){for(let[l,s]of Object.entries(e))!function e(t,r,l){if(Array.isArray(l))for(let[s,a]of l.entries())e(t,d(r,s.toString()),a);else l instanceof Date?t.push([r,l.toISOString()]):"boolean"==typeof l?t.push([r,l?"1":"0"]):"string"==typeof l?t.push([r,l]):"number"==typeof l?t.push([r,`${l}`]):null==l?t.push([r,""]):c(l,r,t)}(r,d(t,l),s);return r}function d(e,t){return e?e+"["+t+"]":t}function u(e){var t,r;let l=null!=(t=null==e?void 0:e.form)?t:e.closest("form");if(l){for(let t of l.elements)if(t!==e&&("INPUT"===t.tagName&&"submit"===t.type||"BUTTON"===t.tagName&&"submit"===t.type||"INPUT"===t.nodeName&&"image"===t.type))return void t.click();null==(r=l.requestSubmit)||r.call(l)}}e.s(["attemptSubmit",()=>u,"objectToFormEntries",()=>c],694421);var m=e.i(700020),f=e.i(2788);let h=(0,t.createContext)(null);function g({children:e}){let r=(0,t.useContext)(h);if(!r)return t.default.createElement(t.default.Fragment,null,e);let{target:l}=r;return l?(0,i.createPortal)(t.default.createElement(t.default.Fragment,null,e),l):null}function p({data:e,form:r,disabled:l,onReset:s,overrides:a}){let[n,i]=(0,t.useState)(null),d=(0,o.useDisposables)();return(0,t.useEffect)(()=>{if(s&&n)return d.addEventListener(n,"reset",s)},[n,r,s]),t.default.createElement(g,null,t.default.createElement(x,{setForm:i,formId:r}),c(e).map(([e,s])=>t.default.createElement(f.Hidden,{features:f.HiddenFeatures.Hidden,...(0,m.compact)({key:e,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:r,disabled:l,name:e,value:s,...a})})))}function x({setForm:e,formId:r}){return(0,t.useEffect)(()=>{if(r){let t=document.getElementById(r);t&&e(t)}},[e,r]),r?null:t.default.createElement(f.Hidden,{features:f.HiddenFeatures.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:t=>{if(!t)return;let r=t.closest("form");r&&e(r)}})}e.s(["FormFields",()=>p],140721);let b=(0,t.createContext)(void 0);function y(){return(0,t.useContext)(b)}e.s(["useProvidedId",()=>y],942803);var v=e.i(835696),j=e.i(294316);let k=(0,t.createContext)(null);function N(){var e,r;return null!=(r=null==(e=(0,t.useContext)(k))?void 0:e.value)?r:void 0}function w(){let[e,l]=(0,t.useState)([]);return[e.length>0?e.join(" "):void 0,(0,t.useMemo)(()=>function(e){let s=(0,r.useEvent)(e=>(l(t=>[...t,e]),()=>l(t=>{let r=t.slice(),l=r.indexOf(e);return -1!==l&&r.splice(l,1),r}))),a=(0,t.useMemo)(()=>({register:s,slot:e.slot,name:e.name,props:e.props,value:e.value}),[s,e.slot,e.name,e.props,e.value]);return t.default.createElement(k.Provider,{value:a},e.children)},[l])]}k.displayName="DescriptionContext";let S=Object.assign((0,m.forwardRefWithAs)(function(e,r){let l=(0,t.useId)(),s=n(),{id:a=`headlessui-description-${l}`,...i}=e,o=function e(){let r=(0,t.useContext)(k);if(null===r){let t=Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}return r}(),c=(0,j.useSyncRefs)(r);(0,v.useIsoMorphicEffect)(()=>o.register(a),[a,o.register]);let d=s||!1,u=(0,t.useMemo)(()=>({...o.slot,disabled:d}),[o.slot,d]),f={ref:c,...o.props,id:a};return(0,m.useRender)()({ourProps:f,theirProps:i,slot:u,defaultTag:"p",name:o.name||"Description"})}),{});e.s(["Description",()=>S,"useDescribedBy",()=>N,"useDescriptions",()=>w],35889);let C=(0,t.createContext)(null);function M(e){var r,l,s;let a=null!=(l=null==(r=(0,t.useContext)(C))?void 0:r.value)?l:void 0;return(null!=(s=null==e?void 0:e.length)?s:0)>0?[a,...e].filter(Boolean).join(" "):a}function O({inherit:e=!1}={}){let l=M(),[s,a]=(0,t.useState)([]),n=e?[l,...s].filter(Boolean):s;return[n.length>0?n.join(" "):void 0,(0,t.useMemo)(()=>function(e){let l=(0,r.useEvent)(e=>(a(t=>[...t,e]),()=>a(t=>{let r=t.slice(),l=r.indexOf(e);return -1!==l&&r.splice(l,1),r}))),s=(0,t.useMemo)(()=>({register:l,slot:e.slot,name:e.name,props:e.props,value:e.value}),[l,e.slot,e.name,e.props,e.value]);return t.default.createElement(C.Provider,{value:s},e.children)},[a])]}C.displayName="LabelContext";let E=Object.assign((0,m.forwardRefWithAs)(function(e,l){var s;let a=(0,t.useId)(),i=function e(){let r=(0,t.useContext)(C);if(null===r){let t=Error("You used a