BilberryDB 1.0.0

dotnet add package BilberryDB --version 1.0.0
                    
NuGet\Install-Package BilberryDB -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BilberryDB" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BilberryDB" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BilberryDB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BilberryDB --version 1.0.0
                    
#r "nuget: BilberryDB, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BilberryDB@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BilberryDB&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BilberryDB&version=1.0.0
                    
Install as a Cake Tool

Developer SDK for creating image search engines with BilberryDB in C#.

What it does

This library helps you find images that look similar to a given image. Just provide an image path, and it will return the most similar images from your Bilberry Vector DB.

Installation

Install via NuGet Package Manager:

Install-Package BilberryDB

Or via .NET CLI:

dotnet add package BilberryDB

Or via PackageReference in your .csproj:

<PackageReference Include="BilberryDB" Version="1.0.0" />

Getting API Keys

You need API keys to use BilberryDB:

  1. Visit www.bilberrydb.com
  2. Go to API Key section
  3. Click Create New API Key
  4. Enter API Key Name (like "My image search project")
  5. Click Create Key

Setup

Option 1: Using appsettings.json

Create an appsettings.json file in your project root:

{
  "BilberryDB": {
    "ApiKey": "your_api_key_here",
    "ApiId": "your_registered_email_here"
  }
}
dotnet user-secrets init
dotnet user-secrets set "BilberryDB:ApiKey" "your_api_key_here"
dotnet user-secrets set "BilberryDB:ApiId" "your_registered_email_here"

Option 3: Using Environment Variables

Set these environment variables:

  • BILBERRY_API_KEY: Your API key
  • BILBERRY_API_ID: Your registered email

Usage

using System;
using System.Threading.Tasks;
using BilberryDB;
using Microsoft.Extensions.Configuration;

class Program
{
    static async Task Main(string[] args)
    {
        await SearchSimilarImages();
    }

    static async Task SearchSimilarImages()
    {
        try
        {
            // Load configuration
            var configuration = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json", optional: true)
                .AddUserSecrets<Program>()
                .AddEnvironmentVariables()
                .Build();

            // Get API credentials
            var apiKey = configuration["BilberryDB:ApiKey"] ?? Environment.GetEnvironmentVariable("BILBERRY_API_KEY");
            var apiId = configuration["BilberryDB:ApiId"] ?? Environment.GetEnvironmentVariable("BILBERRY_API_ID");

            // Check if API keys exist
            if (string.IsNullOrEmpty(apiKey) || string.IsNullOrEmpty(apiId))
            {
                throw new InvalidOperationException("Missing API keys. Check your configuration.");
            }

            // Initialize client
            var config = new BilberryConfig
            {
                ApiKey = apiKey,
                ApiId = apiId
            };

            using var client = BilberryClient.Init(config);
            var vector = client.GetVector();

            // Search for similar images
            var results = await vector.SearchAsync("path/to/your/image.jpg", new SearchOptions
            {
                TopK = 5, // Get top 5 similar images
                ContentType = "image"
            });

            // Show results
            Console.WriteLine($"Found {results.Count} similar images:");

            for (int i = 0; i < results.Count; i++)
            {
                var result = results[i];
                var filename = result.FileName ?? $"item_{result.Id}";
                Console.WriteLine($"{i + 1}. Image: {filename}");
                Console.WriteLine($"   Similarity: {result.SimilarityScore:F3}");
                Console.WriteLine($"   File Type: {result.FileType}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Search failed: {ex.Message}");
        }
    }
}

How to use

  1. Replace "path/to/your/image.jpg" with the actual path to your image
  2. Change TopK = 5 to get more or fewer results
  3. Build and run your application:
    dotnet build
    dotnet run
    

What you get back

Each result includes:

  • FileName: Name of the similar image
  • SimilarityScore: How similar it is (higher = more similar)
  • FileType: Type of image file (jpg, png, etc.)
  • Id: Unique ID of the image

Common issues

"Missing API keys": Make sure your configuration has the correct API key and API ID.

"Search failed": Check that:

  • Your image path is correct and the file exists
  • Your API keys are valid
  • You have internet connection
  • The image file format is supported

Project Requirements

Add these NuGet packages to your .csproj:

<PackageReference Include="BilberryDB" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />

Requirements

  • .NET 6.0 or higher
  • Valid BilberryDB account and API keys

License

Check the BilberryDB package license for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 132 8/18/2025