Skip to content

EdenAI

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official EdenAI OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using EdenAI;

using var client = new EdenAIClient(apiKey);

MeaiTools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
var apiKey =
    Environment.GetEnvironmentVariable("EDENAI_API_KEY") is { Length: > 0 } value
        ? value
        : throw new AssertInconclusiveException("EDENAI_API_KEY environment variable is not found.");

using var client = new EdenAIClient(apiKey);

// Create tools for chat, translation, image generation, summarization,
// sentiment analysis, and language detection.
var chatTool = client.AsChatTool();
var translateTool = client.AsTranslateTool();
var generateImageTool = client.AsGenerateImageTool();
var summarizeTool = client.AsSummarizeTool();
var sentimentTool = client.AsSentimentAnalysisTool();
var detectLanguageTool = client.AsDetectLanguageTool();

// These tools can be passed to any IChatClient that supports function calling.
var tools = new[] { chatTool, translateTool, generateImageTool, summarizeTool, sentimentTool, detectLanguageTool };

Chat

Shows how to send a chat message to an AI provider via EdenAI.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new EdenAIClient(apiKey);

// Send a chat message through the EdenAI unified API,
// specifying one or more providers to route the request to.
var response = await client.Chat.TextTextChatCreateAsync(
    request: new TextchatChatRequest
    {
        Providers = ["openai"],
        Text = "What is the capital of France?",
        ChatbotGlobalAction = "You are a helpful geography assistant.",
        MaxTokens = 100,
    });

Translation

Shows how to translate text between languages via EdenAI.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new EdenAIClient(apiKey);

// Translate text using the EdenAI unified API.
// Multiple providers are supported including Google, Amazon, Microsoft, and DeepL.
var response = await client.AutomaticTranslation
    .TranslationTranslationAutomaticTranslationCreateAsync(
        request: new TranslationautomaticTranslationAutomaticTranslationRequest
        {
            Providers = ["google"],
            Text = "Hello, how are you?",
            TargetLanguage = "fr",
        });

Image Generation

Shows how to generate images from text descriptions via EdenAI.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new EdenAIClient(apiKey);

// Generate images from text descriptions using the EdenAI unified API.
// Supported providers include OpenAI (DALL-E), Stability AI, and Amazon.
var response = await client.Generation.ImageImageGenerationCreateAsync(
    request: new ImagegenerationGenerationRequest
    {
        Providers = ["openai"],
        Text = "A serene mountain landscape at sunset",
        Resolution = "1024x1024",
        NumImages = 1,
    });

Support

Priority place for bugs: https://github.com/tryAGI/EdenAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/EdenAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.