{"record":{"id":"4268b41a739ee55e","repo":"microsoft/semantic-kernel","slug":"item-is-required-for-conversationitemcreateevent","errorCode":null,"errorMessage":"Item is required for ConversationItemCreateEvent","messagePattern":"Item is required for ConversationItemCreateEvent","errorType":"exception","errorClass":"ContentException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/_open_ai_realtime.py","lineNumber":199,"sourceCode":"            if \"audio\" not in kwargs:\n                raise ContentException(\"Audio is required for InputAudioBufferAppendEvent\")\n            return InputAudioBufferAppendEvent(\n                type=event_type.value,\n                **kwargs,\n            )\n        case SendEvents.INPUT_AUDIO_BUFFER_COMMIT:\n            return InputAudioBufferCommitEvent(\n                type=event_type.value,\n                **kwargs,\n            )\n        case SendEvents.INPUT_AUDIO_BUFFER_CLEAR:\n            return InputAudioBufferClearEvent(\n                type=event_type.value,\n                **kwargs,\n            )\n        case SendEvents.CONVERSATION_ITEM_CREATE:\n            if \"item\" not in kwargs:\n                raise ContentException(\"Item is required for ConversationItemCreateEvent\")\n            kwargs[\"type\"] = event_type.value\n            return ConversationItemCreateEvent(**kwargs)\n        case SendEvents.CONVERSATION_ITEM_TRUNCATE:\n            if \"content_index\" not in kwargs:\n                kwargs[\"content_index\"] = 0\n            return ConversationItemTruncateEvent(\n                type=event_type.value,\n                **kwargs,\n            )\n        case SendEvents.CONVERSATION_ITEM_DELETE:\n            if \"item_id\" not in kwargs:\n                raise ContentException(\"Item ID is required for ConversationItemDeleteEvent\")\n            return ConversationItemDeleteEvent(\n                type=event_type.value,\n                **kwargs,\n            )\n        case SendEvents.RESPONSE_CREATE:\n            if \"response\" in kwargs:","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/_open_ai_realtime.py#L181-L217","documentation":"The OpenAI Realtime API's conversation.item.create event requires an 'item' object describing the conversation item (message, function call, etc.). The event factory raises ContentException if 'item' is not in kwargs when event_type is SendEvents.CONVERSATION_ITEM_CREATE.","triggerScenarios":"Calling send(SendEvents.CONVERSATION_ITEM_CREATE) without an 'item' kwarg — e.g. providing the message content directly at the top level instead of nested under 'item'.","commonSituations":"Confusing the flat vs nested API shape — putting role/content at the kwargs root instead of inside an item dict; building the event from a partial payload that omitted item due to a conditional.","solutions":["Nest the conversation item properly: send(SendEvents.CONVERSATION_ITEM_CREATE, item={'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'hello'}]}).","Use the SDK's helper or the high-level API if available to construct the item automatically.","Validate that 'item' key exists before calling send."],"exampleFix":"// before\nawait service.send(SendEvents.CONVERSATION_ITEM_CREATE, type='message', role='user', content='hello')\n// after\nawait service.send(SendEvents.CONVERSATION_ITEM_CREATE, item={'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'hello'}]})","handlingStrategy":"validation","validationCode":"def validate_conversation_item_create_kwargs(kwargs: dict) -> None:\n    if 'item' not in kwargs:\n        raise ValueError('CONVERSATION_ITEM_CREATE requires an item kwarg')\n    item = kwargs['item']\n    if not isinstance(item, dict) or 'type' not in item:\n        raise ValueError('item must be a dict with at least a type key')","typeGuard":"def has_valid_item_kwarg(kwargs: dict) -> bool:\n    return 'item' in kwargs and isinstance(kwargs['item'], dict) and 'type' in kwargs['item']","tryCatchPattern":"from semantic_kernel.exceptions import ContentException\n\ntry:\n    await service.send(SendEvents.CONVERSATION_ITEM_CREATE, **kwargs)\nexcept ContentException as e:\n    if 'Item is required' in str(e):\n        kwargs['item'] = {'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': kwargs.pop('text', '')}]}\n        await service.send(SendEvents.CONVERSATION_ITEM_CREATE, **kwargs)","preventionTips":["Always nest conversation item data under the 'item' key.","Use a factory function to build well-formed item dicts.","Validate item structure before sending."],"tags":["openai","realtime","conversation","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}