Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(fine_tuning): stop forwarding api_version to the OpenAI client (#44995)

devin-ai-integration[bot]cc156a73b860
diff --git a/tests/unit/fine_tuning/test_main.py b/tests/unit/fine_tuning/test_main.py
index 57c845c6e1a..89f51d2e74a 100644
--- a/tests/unit/fine_tuning/test_main.py
+++ b/tests/unit/fine_tuning/test_main.py
@@ -1,11 +1,12 @@
import json
-from typing import Final
+from typing import Final, Literal
import httpx
import pytest
import respx
import litellm
+from litellm.types.utils import LiteLLMFineTuningJob
API_BASE: Final = "https://fine-tuning.test"
BASE_MODEL: Final = "gpt-4.1-nano-2025-04-14"
@@ -52,3 +53,42 @@ async def test_create_sends_the_model_without_the_provider_prefix(
)
assert json.loads(sent.calls.last.request.content)["model"] == BASE_MODEL
+
+
+ ("custom_llm_provider", "api_base", "route", "sent_api_version"),
+ [
+ ("openai", f"{API_BASE}/v1", f"{API_BASE}/v1/fine_tuning/jobs", None),
+ ("azure", API_BASE, f"{API_BASE}/openai/fine_tuning/jobs", "2024-10-21"),
+ ],
+)
[email protected]("is_async", [True, False], ids=["async", "sync"])
+async def test_create_with_api_version_reaches_the_provider_and_only_azure_gets_it(
+ monkeypatch: pytest.MonkeyPatch,
+ custom_llm_provider: Literal["openai", "azure"],
+ api_base: str,
+ route: str,
+ sent_api_version: str | None,
+ is_async: bool,
+) -> None:
+ sent: Final = respx.post(url__startswith=route).mock(return_value=httpx.Response(200, json=PROVIDER_JOB))
+ request: Final = {
+ "model": BASE_MODEL,
+ "training_file": "file-abc123",
+ "custom_llm_provider": custom_llm_provider,
+ "api_key": "sk-test",
+ "api_base": api_base,
+ "api_version": "2024-10-21",
+ }
+
+ async with httpx.AsyncClient() as session:
+ monkeypatch.setattr(litellm, "aclient_session", session)
+ job: Final = (
+ await litellm.acreate_fine_tuning_job(**request) if is_async else litellm.create_fine_tuning_job(**request)
+ )
+
+ assert isinstance(job, LiteLLMFineTuningJob)
+ assert job.id == PROVIDER_JOB["id"]
+ assert sent.calls.last.request.url.params.get("api-version") == sent_api_version