Implement Assistants to Responses API migration - #163
Open
joacir wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The OpenAI Assistants beta API is scheduled to shut down on August 26, 2026 in favor of the Responses + Conversations stack (official migration guide). This PR brings full SDK support for the new stack so users can migrate before the sunset.
What's added (25 new public methods, 4 new URL helpers)
Responses API (
/v1/responses)response()with streaming callback support,retrieveResponse(),deleteResponse(),cancelResponse(),listResponseInputItems().response()follows the same($opts, $stream = null)signature aschat()/completion()so existing streaming patterns transfer over.Conversations API (
/v1/conversations)createConversation(),retrieveConversation(),modifyConversation(),deleteConversation(),createConversationItems(),listConversationItems(),retrieveConversationItem(),deleteConversationItem(). Used as the stateful replacement for Threads.Vector Stores API (
/v1/vector_stores)16 methods covering stores (
createVectorStore,searchVectorStore, …), files (createVectorStoreFile,updateVectorStoreFileAttributes, …) and file batches (createVectorStoreFileBatch, …). Required for thefile_searchtool in Responses.Prompts API (
/v1/prompts)retrievePrompt()for dashboard-managed prompt templates that can be referenced fromresponse()viaprompt => ['id' => 'pmpt_…'].What's deprecated
All 28 methods in the Assistants/Threads/Messages/Runs/RunSteps families (
createAssistant,createThread,createThreadMessage,createRun,submitToolOutputs,retrieveRunStep, etc.) get an@deprecatedPHPDoc tag pointing at the new replacement method. No behavior change — they keep working until OpenAI shuts them down.The README has a deprecation banner with a legacy→new mapping table at the top of the Assistants beta section.
Bug fixes
chat()andresponse()now correctly throw'Please provide a stream function…'whenstream => trueis passed without a callback. Previously the missing callback fell through tosendRequest()and triggered a fatalTyped property OpenAi::$stream_method must not be accessed before initialization. The fix mirrors the existing — and correct — logic already incompletion().The pre-existing
should handle simple chat completion using the new endpointtest was asserting on the obsolete"text"key; updated to"object": "chat.completion"+"content"to match the current Chat Completions response shape.Compatibility
ext-curl+ext-jsonlike the rest of the SDK.setBaseURL/setCustomURLcontinue to work for Azure OpenAI / self-hosted gateways — the new methods all route through the existingbaseUrl($url)rewrite.OpenAI-Betaheader.Test plan
12 new tests added to the
workinggroup covering create / retrieve / list / delete / stream-throw across the new families. All 13 (including the updated chat assertion) pass against the live OpenAI API:Additional verification:
php -lclean onsrc/Url.php,src/OpenAi.php,tests/OpenAiTest.phpvendor/bin/php-cs-fixer fix --dry-run --allow-risky=yesreports zero changes neededmain(4ba9c70)addAssistantsBetaHeader()refactorFiles
src/Url.phpresponsesUrl,conversationsUrl,vectorStoresUrl,promptsUrl)src/OpenAi.php@deprecatedtags, 2 bug fixes)tests/OpenAiTest.phpREADME.mdHappy to address feedback or split into multiple PRs if preferred.