litellm/litellm/integrations/arize
HUAHAODIA 29cdcf4880 chore(lint): graduate 12 rules from the strict-gate ratchet
Zeroes the remaining violations for 12 rules so they can hard-fail
in the main ruff config instead of being budget-ratcheted, and drops
their strict-gate budgets to 0:

- B021: drop useless f-prefix on the Javelin docstring
- C404 / C419: dict()/any() around unnecessary list comprehension
- PLR0124: replace the 'value == value' NaN idiom (and the separate
  +/-inf exclusion) with math.isfinite in _validate_response_time
- SIM201: 'not X == "function"' -> 'X != "function"'
- SIM211: 'False if x is False else True' -> 'x is not False'
- SIM222: drop literal 'None or' before "success"
- UP036: remove the dead sys.version_info < (3, 8) branch (and the
  now-unused sys import) in the weights_biases TYPE_CHECKING block
- B018 x2: keep the deliberate property side-effect access but assign
  it ('_ = self.prompt_manager') as the rule requires
- PLR0206: the unusable '@property def api_version(self, api_version)'
  (a property getter cannot take extra args) becomes a @staticmethod
  matching its siblings get_api_base/get_api_key; it had no callers
- PLR1704: rename the loop variable (and the nested helper parameter)
  that shadowed abatch_completion_fastest_response's 'model' argument
- B004 x2: scoped noqa with rationale — both sites retrieve __call__
  to unwrap functors for iscoroutinefunction, which is a value use,
  not the callability test B004 assumes; the callable() autofix would
  break them

N999 intentionally stays on the ratchet (limit 1): it flags the
'litellm/proxy/lambda.py' filename, which needs a module rename.

Verified: full-tree 'ruff check litellm' green with the graduated
rules enforced; ruff-strict counts for all 12 rules are 0; budget
JSON regenerated in the gate script's json.dumps style.
2026-09-14 14:04:08 +08:00
..
__init__.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
_utils.py refactor(typing): replace Any with proven types in 42 more backend files 2026-09-02 15:35:01 +00:00
arize.py chore(lint): clear grandfathered over-limit lint drift and ratchet budgets down 2026-08-05 12:18:13 -07:00
arize_phoenix.py fix(arize_phoenix): lowercase OTLP/gRPC auth metadata key (#34883) 2026-08-05 20:57:50 -07:00
arize_phoenix_client.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
arize_phoenix_prompt_manager.py chore(lint): graduate 12 rules from the strict-gate ratchet 2026-09-14 14:04:08 +08:00
README.md Arize Phoenix OSS - Prompt Management Integration (#17750) 2025-12-09 22:53:42 -08:00

Arize Phoenix Prompt Management Integration

This integration enables using prompt versions from Arize Phoenix with LiteLLM's completion function.

Features

  • Fetch prompt versions from Arize Phoenix API
  • Workspace-based access control through Arize Phoenix permissions
  • Mustache/Handlebars-style variable templating ({{variable}})
  • Support for multi-message chat templates
  • Automatic model and parameter configuration from prompt metadata
  • OpenAI and Anthropic provider parameter support

Configuration

Configure Arize Phoenix access in your application:

import litellm

# Configure Arize Phoenix access
# api_base should include your workspace, e.g., "https://app.phoenix.arize.com/s/your-workspace/v1"
api_key = "your-arize-phoenix-token"
api_base = "https://app.phoenix.arize.com/s/krrishdholakia/v1"

Usage

Basic Usage

import litellm

# Use with completion
response = litellm.completion(
    model="arize/gpt-4o",
    prompt_id="UHJvbXB0VmVyc2lvbjox",  # Your prompt version ID
    prompt_variables={"question": "What is artificial intelligence?"},
    api_key="your-arize-phoenix-token",
    api_base="https://app.phoenix.arize.com/s/krrishdholakia/v1",
)

print(response.choices[0].message.content)

With Additional Messages

You can also combine prompt templates with additional messages:

response = litellm.completion(
    model="arize/gpt-4o",
    prompt_id="UHJvbXB0VmVyc2lvbjox",
    prompt_variables={"question": "Explain quantum computing"},
    api_key="your-arize-phoenix-token",
    api_base="https://app.phoenix.arize.com/s/krrishdholakia/v1",
    messages=[
        {"role": "user", "content": "Please keep your response under 100 words."}
    ],
)

Direct Manager Usage

You can also use the prompt manager directly:

from litellm.integrations.arize.arize_phoenix_prompt_manager import ArizePhoenixPromptManager

# Initialize the manager
manager = ArizePhoenixPromptManager(
    api_key="your-arize-phoenix-token",
    api_base="https://app.phoenix.arize.com/s/krrishdholakia/v1",
    prompt_id="UHJvbXB0VmVyc2lvbjox",
)

# Get rendered messages
messages, metadata = manager.get_prompt_template(
    prompt_id="UHJvbXB0VmVyc2lvbjox",
    prompt_variables={"question": "What is machine learning?"}
)

print("Rendered messages:", messages)
print("Metadata:", metadata)

Prompt Format

Arize Phoenix prompts support the following structure:

{
    "data": {
        "description": "A chatbot prompt",
        "model_provider": "OPENAI",
        "model_name": "gpt-4o",
        "template": {
            "type": "chat",
            "messages": [
                {
                    "role": "system",
                    "content": [
                        {
                            "type": "text",
                            "text": "You are a chatbot"
                        }
                    ]
                },
                {
                    "role": "user",
                    "content": [
                        {
                            "type": "text",
                            "text": "{{question}}"
                        }
                    ]
                }
            ]
        },
        "template_type": "CHAT",
        "template_format": "MUSTACHE",
        "invocation_parameters": {
            "type": "openai",
            "openai": {
                "temperature": 1.0
            }
        },
        "id": "UHJvbXB0VmVyc2lvbjox"
    }
}

Variable Substitution

Variables in your prompt templates use Mustache/Handlebars syntax:

  • {{variable_name}} - Simple variable substitution

Example:

Template: "Hello {{name}}, your order {{order_id}} is ready!"
Variables: {"name": "Alice", "order_id": "12345"}
Result: "Hello Alice, your order 12345 is ready!"

API Reference

ArizePhoenixPromptManager

Main class for managing Arize Phoenix prompts.

Methods:

  • get_prompt_template(prompt_id, prompt_variables) - Get and render a prompt template
  • get_available_prompts() - List available prompt IDs
  • reload_prompts() - Reload prompts from Arize Phoenix

ArizePhoenixClient

Low-level client for Arize Phoenix API.

Methods:

  • get_prompt_version(prompt_version_id) - Fetch a prompt version
  • test_connection() - Test API connection

Error Handling

The integration provides detailed error messages:

  • 404: Prompt version not found
  • 401: Authentication failed (check your access token)
  • 403: Access denied (check workspace permissions)

Example:

try:
    response = litellm.completion(
        model="arize/gpt-4o",
        prompt_id="invalid-id",
        arize_config=arize_config,
    )
except Exception as e:
    print(f"Error: {e}")

Getting Your Prompt Version ID and API Base

  1. Log in to Arize Phoenix
  2. Navigate to your workspace
  3. Go to Prompts section
  4. Select a prompt version
  5. The ID will be in the URL: /s/{workspace}/v1/prompt_versions/{PROMPT_VERSION_ID}

Your api_base should be: https://app.phoenix.arize.com/s/{workspace}/v1

For example:

  • Workspace: krrishdholakia
  • API Base: https://app.phoenix.arize.com/s/krrishdholakia/v1
  • Prompt Version ID: UHJvbXB0VmVyc2lvbjox

You can also fetch it via API:

curl -L -X GET 'https://app.phoenix.arize.com/s/krrishdholakia/v1/prompt_versions/UHJvbXB0VmVyc2lvbjox' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Support

For issues or questions: