diff --git a/litellm/constants.py b/litellm/constants.py index 8f236eba327..7086b024a73 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -838,6 +838,7 @@ openai_text_completion_compatible_providers: Final[list] = [ # providers that s "publicai", "synthetic", "tensormesh", + "tiyuvta", "apertis", "nano-gpt", "poe", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 272fbabf807..d134a7d77a9 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3723,6 +3723,7 @@ class LlmProviders(str, Enum): PARASAIL = "parasail" XIAOMI_MIMO = "xiaomi_mimo" TENSORMESH = "tensormesh" + TIYUVTA = "tiyuvta" LIBERTAI = "libertai" PINSTRIPES = "pinstripes" DARKBLOOM = "darkbloom" diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 4530e3716de..99d3fa1ec68 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -2380,7 +2380,8 @@ "moderations": false, "batches": false, "rerank": false, - "a2a": false + "a2a": false, + "text_completion": true } }, "together_ai": { diff --git a/tests/test_litellm/llms/openai_like/test_json_providers.py b/tests/test_litellm/llms/openai_like/test_json_providers.py index c8743e1809d..31e88254b38 100644 --- a/tests/test_litellm/llms/openai_like/test_json_providers.py +++ b/tests/test_litellm/llms/openai_like/test_json_providers.py @@ -5,8 +5,12 @@ Tests for JSON-based provider configuration system. import json import os import sys +from typing import Final from unittest.mock import MagicMock, patch +import httpx +from openai import OpenAI + try: import pytest except ImportError: @@ -20,6 +24,55 @@ sys.path.insert(0, workspace_path) import litellm +@pytest.mark.parametrize("legacy", [True, False]) +def test_tiyuvta_routes_completion_endpoint(legacy: bool) -> None: + def respond(request: httpx.Request) -> httpx.Response: + endpoint: Final = "completions" if legacy else "chat/completions" + assert str(request.url) == f"https://api.tiyuvta.ai/v1/{endpoint}" + assert request.headers["authorization"] == "Bearer test-tiyuvta-key" + payload: Final = json.loads(request.content) + assert payload["model"] == "test-model" + if legacy: + assert payload["prompt"] == "Say hello" + assert "messages" not in payload + else: + assert payload["messages"] == [{"role": "user", "content": "Say hello"}] + assert "prompt" not in payload + return httpx.Response( + 200, + json={ + "id": "completion-test", + "object": "text_completion" if legacy else "chat.completion", + "created": 1, + "model": "test-model", + "choices": [ + { + "index": 0, + "finish_reason": "stop", + **({"text": "hello"} if legacy else {"message": {"role": "assistant", "content": "hello"}}), + } + ], + "usage": {"prompt_tokens": 2, "completion_tokens": 1, "total_tokens": 3}, + }, + ) + + with OpenAI( + api_key="test-tiyuvta-key", + base_url="https://api.tiyuvta.ai/v1", + http_client=httpx.Client(transport=httpx.MockTransport(respond)), + max_retries=0, + ) as client: + response: Final = ( + litellm.text_completion(model="tiyuvta/test-model", prompt="Say hello", client=client) + if legacy + else litellm.completion( + model="tiyuvta/test-model", messages=[{"role": "user", "content": "Say hello"}], client=client + ) + ) + assert response.choices[0].finish_reason == "stop" + assert (response.choices[0].text if legacy else response.choices[0].message.content) == "hello" + + class TestJSONProviderLoader: """Test JSON provider loading and configuration"""