from tools.anki.client import anki_request
async def add_flashcard(
front: str,
back: str,
deck_name: str = "Default",
tags: list[str] | None = None,
) -> int | None:
"""
Add a new flashcard to Anki.
Args:
front: The front/question side of the card (supports HTML/markdown)
back: The back/answer side of the card (supports HTML/markdown)
deck_name: The deck to add the card to (default: 'Default')
tags: Optional list of tags for the card
Returns:
The note ID of the created card, or None if duplicate
"""
note = {
"deckName": deck_name,
"modelName": "Basic",
"fields": {
"Front": front,
"Back": back,
},
"options": {
"allowDuplicate": False,
},
"tags": tags or [],
}
return await anki_request("addNote", note=note)