Skip to content

Conversation

@mfittko
Copy link

@mfittko mfittko commented Nov 26, 2025

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)

  • Added Conversation, ConversationItem, ConversationContentItem TypedDicts
  • Added ConversationCreateParams, ConversationUpdateParams, ConversationDeletedResource
  • Added ConversationItemCreateParams, ConversationItemListParams, ConversationItemList

OpenAI Provider Implementation (litellm/llms/openai/conversations.py)

  • New OpenAIConversationsAPI class with sync and async methods
  • Handles all conversation and conversation item operations

Core Module (litellm/conversations/main.py)

  • 9 async API functions for conversation operations
  • Accessible via litellm.acreate_conversation(), etc.

Router Integration (litellm/router.py)

  • Added 8 conversation methods using the factory pattern
  • Consistent with existing router implementation

Proxy Endpoints (litellm/proxy/conversation_endpoints/)

  • 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.

Route Mapping

  • Updated ROUTE_ENDPOINT_MAPPING with conversation routes
  • Updated Literal types in common_request_processing.py

Tests (tests/local_testing/test_conversations_api.py)

  • Import tests for types, functions, and classes
  • Route mapping verification
  • Router method verification

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:

tests/local_testing/test_conversations_api.py::TestConversationsAPIImports::test_import_conversation_functions PASSED
tests/local_testing/test_conversations_api.py::TestConversationsAPIImports::test_import_conversation_types PASSED
tests/local_testing/test_conversations_api.py::TestConversationsAPIImports::test_import_openai_conversations_api PASSED
tests/local_testing/test_conversations_api.py::TestConversationsAPIImports::test_import_proxy_endpoints PASSED
tests/local_testing/test_conversations_api.py::TestConversationsAPIRouteMapping::test_route_endpoint_mapping PASSED
tests/local_testing/test_conversations_api.py::TestConversationsAPIRouter::test_router_conversation_methods PASSED

Commits

  1. feat(conversations): add type definitions for Conversations API
  2. feat(conversations): add OpenAI provider implementation
  3. feat(conversations): add core conversations module
  4. feat(conversations): export conversation functions from litellm
  5. feat(conversations): add router methods for conversations
  6. feat(conversations): add route types for proxy endpoints
  7. feat(conversations): add proxy server endpoints
  8. test(conversations): add unit tests for Conversations API

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
@mfittko mfittko self-assigned this Nov 26, 2025
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.

2 participants