feat: Implement OpenAI Conversations API endpoints#7
Open
mfittko wants to merge 8 commits intosofatutor-tweaksfrom
Open
feat: Implement OpenAI Conversations API endpoints#7mfittko wants to merge 8 commits intosofatutor-tweaksfrom
mfittko wants to merge 8 commits intosofatutor-tweaksfrom
Conversation
Add TypedDict classes for the OpenAI Conversations API: - Conversation, ConversationItem, ConversationContentItem - ConversationCreateParams, ConversationUpdateParams - ConversationDeletedResource - ConversationItemCreateParams, ConversationItemListParams - ConversationItemList Part of: BerriAI#15296
Add OpenAIConversationsAPI class with sync and async methods: - create_conversation, get_conversation, update_conversation, delete_conversation - create_conversation_item, list_conversation_items - get_conversation_item, delete_conversation_item This class provides the OpenAI-specific implementation for the Conversations API endpoints. Part of: BerriAI#15296
Add litellm/conversations/main.py with async API functions: - acreate_conversation, aget_conversation, aupdate_conversation, adelete_conversation - acreate_conversation_item, alist_conversation_items - aget_conversation_item, adelete_conversation_item - alist_conversations These functions serve as the main entry points for the Conversations API in litellm. Part of: BerriAI#15296
Add conversation function exports to litellm/__init__.py: - All sync and async conversation operations - Accessible via litellm.acreate_conversation(), etc. Part of: BerriAI#15296
Add conversation methods to Router class using factory pattern: - acreate_conversation, aget_conversation, aupdate_conversation, adelete_conversation - acreate_conversation_item, alist_conversation_items - aget_conversation_item, adelete_conversation_item Part of: BerriAI#15296
Update route type definitions for conversation endpoints: - Add conversation routes to ROUTE_ENDPOINT_MAPPING - Update Literal types in common_request_processing.py - Update route_type in route_llm_request.py Part of: BerriAI#15296
Add FastAPI endpoints for Conversations API:
- POST /v1/conversations - Create conversation
- GET /v1/conversations/{id} - Get conversation
- POST /v1/conversations/{id} - Update conversation
- DELETE /v1/conversations/{id} - Delete conversation
- POST /v1/conversations/{id}/items - Create item
- GET /v1/conversations/{id}/items - List items
- GET /v1/conversations/{id}/items/{item_id} - Get item
- DELETE /v1/conversations/{id}/items/{item_id} - Delete item
All endpoints support /v1/, /, and /openai/v1/ prefixes.
Part of: BerriAI#15296
Add tests for the Conversations API implementation: - Import tests for types, functions, and classes - Route mapping verification - Router method verification Part of: BerriAI#15296
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.
Summary
This PR implements the OpenAI Conversations API endpoints in LiteLLM, resolving the 404 error when calling
client.conversations.create().Fixes: BerriAI#15296
Changes
Type Definitions (
litellm/types/llms/openai.py)Conversation,ConversationItem,ConversationContentItemTypedDictsConversationCreateParams,ConversationUpdateParams,ConversationDeletedResourceConversationItemCreateParams,ConversationItemListParams,ConversationItemListOpenAI Provider Implementation (
litellm/llms/openai/conversations.py)OpenAIConversationsAPIclass with sync and async methodsCore Module (
litellm/conversations/main.py)litellm.acreate_conversation(), etc.Router Integration (
litellm/router.py)Proxy Endpoints (
litellm/proxy/conversation_endpoints/)POST /v1/conversations- Create conversationGET /v1/conversations/{id}- Get conversationPOST /v1/conversations/{id}- Update conversationDELETE /v1/conversations/{id}- Delete conversationPOST /v1/conversations/{id}/items- Create itemGET /v1/conversations/{id}/items- List itemsGET /v1/conversations/{id}/items/{item_id}- Get itemDELETE /v1/conversations/{id}/items/{item_id}- Delete itemAll endpoints support
/v1/,/, and/openai/v1/prefixes.Route Mapping
ROUTE_ENDPOINT_MAPPINGwith conversation routescommon_request_processing.pyTests (
tests/local_testing/test_conversations_api.py)Background
The Conversations API is part of OpenAI's new Responses API ecosystem, which is replacing the Assistants API (deprecated mid-2026). It provides stateful multi-turn conversation management.
Testing
All 6 unit tests pass:
Commits
feat(conversations): add type definitions for Conversations APIfeat(conversations): add OpenAI provider implementationfeat(conversations): add core conversations modulefeat(conversations): export conversation functions from litellmfeat(conversations): add router methods for conversationsfeat(conversations): add route types for proxy endpointsfeat(conversations): add proxy server endpointstest(conversations): add unit tests for Conversations API