AI SDK

This plugin provides a unified AI model configuration center, supporting all major mainstream AI models. Configure once, use everywhere, without the need to repeatedly set API Keys.


Introduction to AI SDK Dependency Plugin

The "AI SDK Dependency Plugin" is a development toolkit for browser plugin developers, providing a unified AI model configuration center that supports all major mainstream AI models. Configure once, use everywhere. This toolkit allows developers to easily implement AI functions such as text generation, structured object generation, and streaming processing in their own plugins. By integrating the "AI SDK Dependency Plugin", developers can seamlessly expand their plugin's AI processing capabilities, bringing more intelligent and practical features to users.

Unified Configuration Center: Configure Once, Use Everywhere

The AI SDK plugin provides a unified AI model configuration center, supporting:

Commercial Models:

  • OpenAI (GPT-4, GPT-4 Vision)

  • Anthropic Claude (Claude 3 Opus, Claude 3.5 Sonnet)

  • Google Gemini (Gemini Pro, Gemini Ultra)

  • DeepSeek (DeepSeek Chat, DeepSeek Coder)

  • Alibaba Qwen (Tongyi Qianwen)

Local Models (completely offline operation):

  • Ollama (supporting Llama 3, Mistral, Phi-3, etc.)

  • LM Studio (graphical interface, beginner-friendly)

After configuring once, all AI-related plugins can use it directly without repeated settings. For example: if you install "AI Translation" and "AI Rename" plugins today, they will automatically share the configuration you filled in the SDK, and can even choose different models individually, without requiring you to enter API Keys again.

Open Development Environment

Based on ai-sdk.dev standards (AI SDK v5), the AI SDK plugin provides developers with a set of clean and stable infrastructure. Developers no longer need to spend effort handling basic configurations such as API Key storage, model switching, and error retry, and can focus on plugin innovation. The only difference is in Provider acquisition - we use our own developed Providers to ensure better stability and user experience.


Installing the AI SDK Dependency Plugin

  1. Enter the plugin center

  2. Search and find the AI SDK plugin

  3. Click to install the AI SDK plugin

Please note that when users install plugins with AI SDK dependencies, Eagle will automatically prompt users to install the "AI SDK Dependency Plugin". Therefore, developers do not need to specifically write code for users to install, as the system will automatically ensure related dependencies are installed before allowing plugins to run.


How to Use the AI SDK Dependency Plugin

If you want to use AI SDK related functions in your plugin, you need to add a dependencies definition in the plugin's manifest.json file, so that the Eagle system knows this plugin needs additional extension functions, as shown below:

{
    "id": "LBCZE8V6LPCKD",
    "version": "1.0.0",
    "platform": "all",
    "arch": "all",
    "name": "Window Plugin",
    "logo": "/logo.png",
    "keywords": [],
    "dependencies": ["ai-sdk"],
    "devTools": false,
    "main":
    {
        "url": "index.html",
        "width": 640,
        "height": 480,
    }
}

Window Plugin Example

You can use eagle.extraModule.ai to call the functions provided by the AI SDK dependency plugin. Here are examples of various usage methods:

generateText() - Basic Text Generation

eagle.onPluginCreate(async (plugin) => {
    // Get AI module and Provider
    const ai = eagle.extraModule.ai;
    const { openai, anthropic, gemini, deepseek, qwen, ollama, lmstudio } = await ai.getProviders();
    const { generateText } = ai;

    // Basic text generation
    const result = await generateText({
        model: openai("gpt-5"),
        prompt: "Please help me write a creative introduction about digital art",
    });

    console.log(result.text);
});

generateObject() - Structured Object Generation

eagle.onPluginCreate(async (plugin) => {
    const ai = eagle.extraModule.ai;
    const { openai } = await ai.getProviders();
    const { generateObject } = ai;

    // Generate structured data
    const result = await generateObject({
        model: anthropic("claude-4-sonnet"),
        schema: {
            type: "object",
            properties: {
                tags: {
                    type: "array",
                    items: {
                        type: "object",
                        properties: {
                            name: { type: "string" },
                            reason: { type: "string" },
                        },
                    },
                },
                description: { type: "string" },
            },
        },
        messages: [
            {
                role: "system",
                content: "You are a professional image analysis expert who can accurately identify image content and provide appropriate tags and descriptions.",
            },
            {
                role: "user",
                content: [
                    {
                        type: "text",
                        text: "Please analyze this image and provide 5 related tags, each tag needs to explain the reason, and provide a concise image description.",
                    },
                    {
                        type: "image",
                        image: "https://example.com/sample-image.jpg",
                    },
                ],
            },
        ],
    });

    console.log("Tags:", result.object.tags);
    console.log("Description:", result.object.description);
});

streamText() - Streaming Text Generation

eagle.onPluginCreate(async (plugin) => {
    const ai = eagle.extraModule.ai;
    const { openai } = await ai.getProviders();
    const { streamText } = ai;

    // Stream text generation, suitable for real-time display
    const { textStream } = await streamText({
        model: gemini("gemini-2.0-flash-exp"),
        prompt: "Please provide a detailed introduction to the development history and main characteristics of digital art",
    });

    // Gradually receive and display generated text
    for await (const textPart of textStream) {
        console.log(textPart);
    }
});

streamObject() - Streaming Object Generation

eagle.onPluginCreate(async (plugin) => {
    const ai = eagle.extraModule.ai;
    const { openai } = await ai.getProviders();
    const { streamObject } = ai;

    // Stream structured object generation
    const { partialObjectStream } = await streamObject({
        model: deepseek("deepseek-chat"),
        schema: {
            type: "object",
            properties: {
                analysis: {
                    type: "object",
                    properties: {
                        colors: {
                            type: "array",
                            items: { type: "string" }
                        },
                        style: { type: "string" },
                        mood: { type: "string" },
                        suggestions: {
                            type: "array",
                            items: { type: "string" }
                        }
                    }
                }
            },
        },
        messages: [
            {
                role: "system",
                content: "You are an art critic who can deeply analyze artworks' colors, styles, emotions, and improvement suggestions.",
            },
            {
                role: "user",
                content: "Please analyze this artwork's color combinations, artistic style, emotions conveyed, and provide improvement suggestions.",
            },
        ],
    });

    // Gradually receive partial objects
    for await (const partialObject of partialObjectStream) {
        console.log("Current analysis result:", partialObject);
    }
});

Important Reminder: AI SDK is fully compatible with all APIs and usage methods of ai-sdk.dev v5. The above examples only show basic usage. The only difference is in Provider acquisition - please use eagle.extraModule.ai.getProviders() to get configured AI providers. The system will automatically handle API Keys and related configurations, so developers don't need to worry about these details.

For more detailed usage methods and advanced features, please refer to the AI SDK v5 Official Documentation. Note that newer versions of AI SDK may have different APIs or features.

Last updated