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]

rename folder to test openai endpoints

Ishaan Jaff08f4a6844b6e
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 8a02a41633f..9f412cbc29e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1474,7 +1474,7 @@ jobs:
command: |
pwd
ls
- python -m pytest -s -vv tests/openai_misc_endpoints_tests --junitxml=test-results/junit.xml --durations=5
+ python -m pytest -s -vv tests/openai_endpoints_tests --junitxml=test-results/junit.xml --durations=5
no_output_timeout: 120m
# Store test results
diff --git a/tests/openai_misc_endpoints_tests/input.jsonl b/tests/openai_endpoints_tests/input.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/input.jsonl
rename to tests/openai_endpoints_tests/input.jsonl
diff --git a/tests/openai_misc_endpoints_tests/input_azure.jsonl b/tests/openai_endpoints_tests/input_azure.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/input_azure.jsonl
rename to tests/openai_endpoints_tests/input_azure.jsonl
diff --git a/tests/openai_misc_endpoints_tests/openai_batch_completions.jsonl b/tests/openai_endpoints_tests/openai_batch_completions.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/openai_batch_completions.jsonl
rename to tests/openai_endpoints_tests/openai_batch_completions.jsonl
diff --git a/tests/openai_misc_endpoints_tests/openai_fine_tuning.jsonl b/tests/openai_endpoints_tests/openai_fine_tuning.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/openai_fine_tuning.jsonl
rename to tests/openai_endpoints_tests/openai_fine_tuning.jsonl
diff --git a/tests/openai_misc_endpoints_tests/out.jsonl b/tests/openai_endpoints_tests/out.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/out.jsonl
rename to tests/openai_endpoints_tests/out.jsonl
diff --git a/tests/openai_misc_endpoints_tests/out_azure.jsonl b/tests/openai_endpoints_tests/out_azure.jsonl
similarity index 100%
rename from tests/openai_misc_endpoints_tests/out_azure.jsonl
rename to tests/openai_endpoints_tests/out_azure.jsonl
diff --git a/tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py b/tests/openai_endpoints_tests/test_openai_batches_endpoint.py
similarity index 100%
rename from tests/openai_misc_endpoints_tests/test_openai_batches_endpoint.py
rename to tests/openai_endpoints_tests/test_openai_batches_endpoint.py
diff --git a/tests/openai_misc_endpoints_tests/test_openai_files_endpoints.py b/tests/openai_endpoints_tests/test_openai_files_endpoints.py
similarity index 100%
rename from tests/openai_misc_endpoints_tests/test_openai_files_endpoints.py
rename to tests/openai_endpoints_tests/test_openai_files_endpoints.py
diff --git a/tests/openai_misc_endpoints_tests/test_openai_fine_tuning.py b/tests/openai_endpoints_tests/test_openai_fine_tuning.py
similarity index 100%
rename from tests/openai_misc_endpoints_tests/test_openai_fine_tuning.py
rename to tests/openai_endpoints_tests/test_openai_fine_tuning.py
diff --git a/tests/openai_endpoints_tests/test_openai_responses_api.py b/tests/openai_endpoints_tests/test_openai_responses_api.py
new file mode 100644
index 00000000000..4b628ae3955
--- /dev/null
+++ b/tests/openai_endpoints_tests/test_openai_responses_api.py
@@ -0,0 +1,70 @@
+import httpx
+from openai import OpenAI, BadRequestError
+import pytest
+
+
+def generate_key():
+ """Generate a key for testing"""
+ url = "http://0.0.0.0:4000/key/generate"
+ headers = {
+ "Authorization": "Bearer sk-1234",
+ "Content-Type": "application/json",
+ }
+ data = {}
+
+ response = httpx.post(url, headers=headers, json=data)
+ if response.status_code != 200:
+ raise Exception(f"Key generation failed with status: {response.status_code}")
+ return response.json()["key"]
+
+
+def get_test_client():
+ """Create OpenAI client with generated key"""
+ key = generate_key()
+ return OpenAI(api_key=key, base_url="http://0.0.0.0:4000")
+
+
+def validate_response(response):
+ """
+ Validate basic response structure from OpenAI responses API
+ """
+ assert response is not None
+ assert isinstance(response.choices[0].message.content, str)
+ assert len(response.choices) > 0
+
+
+def validate_stream_chunk(chunk):
+ """
+ Validate streaming chunk structure from OpenAI responses API
+ """
+ assert chunk is not None
+ assert isinstance(chunk.choices[0].delta.content, str)
+
+
+def test_basic_response():
+ client = get_test_client()
+ response = client.responses.create(
+ model="gpt-4", input="Tell me a three sentence bedtime story about a unicorn."
+ )
+ validate_response(response)
+
+
+def test_streaming_response():
+ client = get_test_client()
+ stream = client.responses.create(
+ model="gpt-4", input="Tell me a story", stream=True
+ )
+
+ collected_chunks = []
+ for chunk in stream:
+ validate_stream_chunk(chunk)
+ collected_chunks.append(chunk)
+
+ assert len(collected_chunks) > 0
+
+
+def test_bad_request_error():
+ client = get_test_client()
+ with pytest.raises(BadRequestError):
+ # Trigger error with invalid model name
+ client.responses.create(model="non-existent-model", input="This should fail")