mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
* test(e2e): cover credential-backed /v1/messages request Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com> * test(e2e): use runtime Anthropic credential Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
"""Live e2e: stored credentials resolve into a deployment serving /v1/messages."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from e2e_config import unique_marker
|
|
from e2e_http import require_successful_call
|
|
from endpoints_client import EndpointsClient, MessagesResult
|
|
from lifecycle import ResourceManager
|
|
from models import CredentialCreateBody, LiteLLMParamsBody
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
|
|
class TestCredentialBackedMessages:
|
|
@pytest.mark.covers("mgmt.credential.new.serves_request")
|
|
def test_credential_backed_messages(self, endpoints_client: EndpointsClient, resources: ResourceManager) -> None:
|
|
marker = unique_marker()
|
|
credential_name = f"e2e-cred-{marker}"
|
|
model = f"e2e-cred-messages-{marker}"
|
|
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
assert anthropic_api_key, "ANTHROPIC_API_KEY must be set for this live e2e test"
|
|
|
|
endpoints_client.proxy.create_credential(
|
|
CredentialCreateBody(
|
|
credential_name=credential_name,
|
|
credential_values={"api_key": anthropic_api_key},
|
|
)
|
|
)
|
|
resources.defer(lambda: endpoints_client.proxy.delete_credential(credential_name))
|
|
|
|
model_id = endpoints_client.create_model(
|
|
model,
|
|
LiteLLMParamsBody(
|
|
model="anthropic/claude-haiku-4-5",
|
|
litellm_credential_name=credential_name,
|
|
),
|
|
)
|
|
resources.defer(lambda: endpoints_client.delete_model(model_id))
|
|
|
|
key = resources.key()
|
|
result = endpoints_client.messages(key, model, "reply with one word")
|
|
require_successful_call(result)
|
|
parsed = MessagesResult.model_validate_json(result.body)
|
|
assert parsed.role == "assistant", f"unexpected role: {result.body[:300]}"
|
|
assert parsed.text.strip(), f"/v1/messages returned no text: {result.body[:300]}"
|