Skip to content

Commit 26360d5

Browse files
committed
Allow openai 3.x in llama-index-llms-openai
The `openai<3` cap was added in 0.7.0 (March 2026), five months before openai 3.0.0 shipped, so it was a routine next-major cap rather than a reaction to a known incompatibility. openai 3.x has been out since August 2026 and the package still works against it. Testing against openai 3.7.0 with the cap removed: * The full package suite passes on both openai 2.54.0 and 3.7.0, including the API-backed tests, which cover streaming, async streaming, structured prediction, built-in tools and file upload. * All type and client import paths the package uses still resolve, and no parameter it passes has been removed. * openai 3.0.0's one documented breaking change is the move to HTTPX2. The package never constructs a transport itself, it only forwards an optional `http_client`, and openai 3 accepts both client families. Requests, including streaming, succeed either way. One test needed updating. `ResponseOutputTextAnnotationAddedEvent.annotation` was typed as a bare `object` in openai 2 and is a discriminated union in openai 3, so the fixture's placeholder payload no longer validates. It now uses a real annotation and normalises the stored value, which works on both majors. No library code required changes. Claude-Session: https://claude.ai/code/session_01YDFeREeB9bZQ3aeuKfJses
1 parent 56beedf commit 26360d5

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ dev = [
2727

2828
[project]
2929
name = "llama-index-llms-openai"
30-
version = "0.8.0"
30+
version = "0.9.0"
3131
description = "llama-index llms openai integration"
3232
authors = [{name = "llama-index"}]
3333
requires-python = ">=3.10,<4.0"
3434
readme = "README.md"
3535
license = "MIT"
36-
dependencies = ["openai>=1.108.1,<3", "llama-index-core>=0.14.5,<0.15"]
36+
dependencies = ["openai>=1.108.1", "llama-index-core>=0.14.5,<0.15"]
3737

3838
[tool.codespell]
3939
check-filenames = true

‎llama-index-integrations/llms/llama-index-llms-openai/tests/test_openai_responses.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,13 @@ def test_process_response_event_with_text_annotation():
292292
content_index=0,
293293
annotation_index=0,
294294
type="response.output_text.annotation.added",
295-
annotation={"type": "test_annotation", "value": 42},
295+
annotation={
296+
"type": "url_citation",
297+
"start_index": 0,
298+
"end_index": 5,
299+
"title": "Example",
300+
"url": "https://example.com",
301+
},
296302
sequence_number=1,
297303
)
298304

@@ -307,9 +313,13 @@ def test_process_response_event_with_text_annotation():
307313
# The annotation should be added to additional_kwargs["annotations"]
308314
_, _, updated_additional_kwargs, _, _, _ = result
309315
assert "annotations" in updated_additional_kwargs
310-
assert updated_additional_kwargs["annotations"] == [
311-
{"type": "test_annotation", "value": 42}
312-
]
316+
assert len(updated_additional_kwargs["annotations"]) == 1
317+
stored = updated_additional_kwargs["annotations"][0]
318+
# openai<3 types this field as bare ``object`` and leaves the dict alone;
319+
# openai>=3 parses it into a discriminated annotation model.
320+
stored = stored if isinstance(stored, dict) else stored.model_dump()
321+
assert stored["type"] == "url_citation"
322+
assert stored["url"] == "https://example.com"
313323

314324

315325
def test_get_tool_calls_from_response():

0 commit comments

Comments
 (0)