add_note
Create a new flashcard in Anki by specifying the deck, note type, field content, tags, and optional images. Supports code formatting with tags and MathJax equations with tags.
Instructions
Add a flashcard to Anki. Ensure you have looked at examples before you do this, and that you have got approval from the user to add the flashcard.
For code examples, use <code> tags to format your code.
e.g. <code>def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)</code>
For MathJax, use the <math> tag to format your math equations. This will automatically render the math equations in Anki.
# e.g. <math>\frac{d}{dx}[3\sin(5x)] = 15\cos(5x)</math>
To attach images to a card, use the picture parameter. Each picture object must have a filename
and exactly one source (url, data, or path). The fields list specifies which card fields get the <img> tag inserted.
## How to attach images based on the source:
**User provides a URL:**
[{"url": "https://example.com/photo.jpg", "filename": "photo.jpg", "fields": ["Back"]}]
**User provides a local file (e.g. screenshot, downloaded image):**
[{"path": "/absolute/path/to/image.png", "filename": "image.png", "fields": ["Back"]}]
**Base64-encoded data (for small images only):**
[{"data": "iVBORw0KGgo...", "filename": "diagram.png", "fields": ["Back"]}]
IMPORTANT: When a user shares an image file or screenshot, prefer using "path" with the absolute
file path rather than trying to base64-encode the image contents. AnkiConnect reads the file directly
from disk which is faster and more reliable.
Args:
deckName: str - The target deck name.
modelName: str - The note type (model) name.
fields: dict - Dictionary of field names and their string content.
tags: List[str] - Optional list of tags.
picture: List[dict] - Optional list of picture attachments. Each dict should have:
- filename (str): Name for the stored image file.
- url (str, optional): URL to download the image from.
- path (str, optional): Absolute file path to a local image. Preferred for user-shared files.
- data (str, optional): Base64-encoded image data.
- fields (List[str]): Card field names where the <img> tag will be inserted.
- skipHash (str, optional): MD5 hash to skip if file matches.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deckName | Yes | ||
| modelName | Yes | ||
| fields | Yes | ||
| tags | No | ||
| picture | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |