-
-
Notifications
You must be signed in to change notification settings - Fork 659
feat(OpenAI): add Conversation API #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I originally designed this under Response API, because this is all its used for at present, but the URL structure of the endpoints does not sit under |
Isn't this the replacement of the old Threads API ? I believe the Conversations API is required to be able to migrate from Assistants/Threads/Runs API to the Response API |
23418cf to
c6d9924
Compare
c6d9924 to
84dc326
Compare
84dc326 to
41ec95c
Compare
|
There is a lot of overlap, but not perfect with Response API. Once I peeked official JS SDK I noticed. /**
* A single item within a conversation. The set of possible types are the same as
* the `output` type of a
* [Response object](https://platform.openai.com/docs/api-reference/responses/object#responses/object-output).
*/
export type ConversationItem =
| ConversationsAPI.Message
| ResponsesAPI.ResponseFunctionToolCallItem
| ResponsesAPI.ResponseFunctionToolCallOutputItem
| ResponsesAPI.ResponseFileSearchToolCall
| ResponsesAPI.ResponseFunctionWebSearch
| ConversationItem.ImageGenerationCall
| ResponsesAPI.ResponseComputerToolCall
| ResponsesAPI.ResponseComputerToolCallOutputItem
| ResponsesAPI.ResponseReasoningItem
| ResponsesAPI.ResponseCodeInterpreterToolCall
| ConversationItem.LocalShellCall
| ConversationItem.LocalShellCallOutput
| ConversationItem.McpListTools
| ConversationItem.McpApprovalRequest
| ConversationItem.McpApprovalResponse
| ConversationItem.McpCall
| ResponsesAPI.ResponseCustomToolCall
| ResponsesAPI.ResponseCustomToolCallOutput;So my changes to the Response InputMessage is invalid as that does not stay true for the Response InputMessages, my indicator is all the classes the official SDK duplicated above instead of re-using the Response API iteration. There must be a reason for each one. I'll revert changes for Message since I can't unify Response/Conversation into one singular message class. I wish I could, but noticing how official SDK duplicates so many types they must fear the same problem - tiny breaking changes. |
|
Okay I believe is done now. I'll do some code review on it to double check, but I believe after battle testing it with my own little scripts - its ready. In this journey I found a few new properties, events in Responses that I need to port over. I'll do those in another PR. This brings in a lot of support for Local Shell & Custom Tool which were not yet typed in Responses or Conversation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the OpenAI Conversation API, providing functionality to create and manage conversations that can store and retrieve conversation state across Response API calls. The implementation includes comprehensive test coverage and adds support for new message types and tool call outputs.
- Adds Conversation and ConversationItems API endpoints with full CRUD operations
- Introduces new input/output types for local shell calls, custom tool calls, and MCP approval responses
- Includes comprehensive test coverage, fixtures, and documentation updates
Reviewed Changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Client.php | Adds conversations() method to main client |
| src/Resources/Conversations.php | Implements conversation CRUD operations |
| src/Resources/ConversationsItems.php | Implements conversation items management |
| src/Responses/Conversations/ | Response classes for conversation API endpoints |
| src/Responses/Responses/Input/ | New input types for shell calls, custom tools, and MCP responses |
| src/Responses/Responses/Output/ | New output types for shell calls and custom tools |
| src/Actions/ | Parser classes for handling new object types |
| tests/ | Comprehensive test coverage for all new functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@iBotPeaches I was trying to upgrade my project to migrate from Assistants to Prompts + Conversations by using your latest changes I got this error however
|
Hmm that would be problematic - since that header is applied by default here - https://github.com/openai-php/client/blob/main/src/OpenAI.php#L19 Not sure why I'm not replicating, but I'll dig into this |
yeah when I comment this line, it works. |
thanks. Still researching, but started this - #688 |

What:
Tasks
Migrate Response Items (Retrieve, ListInputItems, Create) into Actions to be re-usable for Conversation ItemsMigrate Response Output into ActionMigrate Response Tool Choice into ActionMigrate Response Tools into ActionMigrate Response Output Text into ActionCrossed off things being handled in #671
Description:
Adds Conversation API and Conversation Item API. All endpoints were tested via this sample script.