@mymagicpencil/ai-sdk
v1.0.6
Published
Vercel AI SDK Tool Provider for My Magic Pencil
Downloads
804
Readme
@mymagicpencil/ai-sdk
A Vercel AI SDK tool provider for the My Magic Pencil API. Drop it into any AI SDK project to let your LLM generate live visual lessons.
Installation
npm install @mymagicpencil/ai-sdkUsage
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { myMagicPencil } from '@mymagicpencil/ai-sdk';
const result = await generateText({
model: openai('gpt-4o'),
tools: {
generateLesson: myMagicPencil({
apiKey: process.env.MYMAGICPENCIL_API_KEY, // or set env var
}),
},
prompt: 'Explain how gravity works with a visual lesson',
});
console.log(result.toolResults);Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
| MYMAGICPENCIL_API_KEY | Yes | Your API key from mymagicpencil.com |
The API key can be passed directly via myMagicPencil({ apiKey: '...' }) or set as the MYMAGICPENCIL_API_KEY environment variable.
Parameters
The myMagicPencil tool accepts the following parameters (provided by the LLM at call time):
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Yes | — | The topic or concept to explain visually |
| language | string | No | "en" | Language code (e.g., en, es, hi) |
| theme | "dark" | "light" | No | "dark" | Visual theme |
| voice_enabled | boolean | No | true | Whether to include TTS voice output |
| voice_tone | number | No | 50 | Voice tone from 0 to 100 |
| output_type | "embed" | "mp4" | No | "embed" | Output format |
| drawing_style | "default" | "sketch" | "blueprint" | "neon" | No | "default" | Drawing style |
| thinking_level | "low" | "medium" | "high" | No | "low" | Level of AI reasoning |
| age_group | "child" | "teen" | "adult" | No | "adult" | Target age group |
Response
On success, the tool returns:
{
"success": true,
"embed_url": "https://...",
"session_id": "...",
"message": "Present this embed_url in an iframe to the user to show the visual explanation."
}Development
npm install
npm run buildLicense
MIT
