Skip to content

fix: OpenAI 1:1 spec-compat reconciliation (interfaze#218)#16

Merged
Khurdhula-Harshavardhan merged 4 commits into
mainfrom
fix/openai-spec-compat-218
Jul 22, 2026
Merged

fix: OpenAI 1:1 spec-compat reconciliation (interfaze#218)#16
Khurdhula-Harshavardhan merged 4 commits into
mainfrom
fix/openai-spec-compat-218

Conversation

@Abhinavexist

Copy link
Copy Markdown
Collaborator

Closes #14. Consolidates the SDK-side reconciliation against server PR InterfazeAI/interfaze#218 (OpenAI 1:1 spec-compat, deploying). Supersedes #13 and #15.

Full audit: interfaze-py was checked against all six #218 fixes. Most SDK workarounds are backward-compat that no-op post-deploy (kept, not removed). Two items needed SDK changes:

1. Streaming json_object fence (deploy-independent bug)

Non-stream create() unwraps the ```json fence Interfaze wraps json_object output in, but the streaming path didn't: stream() discarded the strip flag and _State.build() never unwrapped it, so get_final_completion() leaked the fence.

Fix: thread the strip flag from stream() into InterfazeStream/AsyncInterfazeStream and apply strip_json_fence in build(); scoped to the aggregated result (live-delta path untouched — incrementally-fenced JSON isn't a real usage). Moved strip_json_fence into _stream.py to avoid a circular import. Pre-#218 this fixes the current leak; post-#218 it no-ops on already-bare JSON.

2. max_completion_tokens + models endpoints (#218 deploying)

  • max_completion_tokens — #218 honors it as an alias for max_tokens (max_tokens wins if both set). Updated the README "Good to know" bullet that said to avoid it. No code change (params pass through); ChatInterfaze's ChatOpenAI rename is now honored, not a silent no-op.
  • models — #218 gives GET /v1/models the OpenAI envelope and adds GET /v1/models/{id}. Added tests/test_models.py locking in models.list() (with owned_by), models.retrieve(), and the spec-shaped model_not_found 404.

Not changed (verified non-findings for Python)

  • Streaming delta.role: the accumulator already tolerates missing role; kept.
  • choice.logprobs: openai-python defaults it to None — never broke parsing.
  • models.list() shape: openai-python parsed the old OpenRouter shape fine; #218 just enriches it.

Tests

30 passing (streaming fence: stripped in json_object, preserved otherwise, async; models: list/retrieve/not-found). ruff + mypy --strict clean.

@Khurdhula-Harshavardhan Khurdhula-Harshavardhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please help resolve the following.

@Abhinavexist
Abhinavexist force-pushed the fix/openai-spec-compat-218 branch from 823eb46 to b7b4643 Compare July 21, 2026 00:07
@Abhinavexist

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (post #7#11). ⚠️ Note: #16 and #20 both touch src/interfaze/_stream.py; whichever merges second needs a quick re-rebase (see #20 for detail).

@Khurdhula-Harshavardhan Khurdhula-Harshavardhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please help resolve the following.

Comment thread README.md
@Abhinavexist

Copy link
Copy Markdown
Collaborator Author

Nit addressed in a835bb4: .text now strips the json_object fence too (matching get_final_completion()), with a test.

@Khurdhula-Harshavardhan
Khurdhula-Harshavardhan merged commit cf14ffa into main Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK follow-ups when server PR interfaze#218 (OpenAI spec-compat) deploys

2 participants