VoyageAI.Sdk
1.0.1
dotnet add package VoyageAI.Sdk --version 1.0.1
NuGet\Install-Package VoyageAI.Sdk -Version 1.0.1
<PackageReference Include="VoyageAI.Sdk" Version="1.0.1" />
<PackageVersion Include="VoyageAI.Sdk" Version="1.0.1" />
<PackageReference Include="VoyageAI.Sdk" />
paket add VoyageAI.Sdk --version 1.0.1
#r "nuget: VoyageAI.Sdk, 1.0.1"
#:package VoyageAI.Sdk@1.0.1
#addin nuget:?package=VoyageAI.Sdk&version=1.0.1
#tool nuget:?package=VoyageAI.Sdk&version=1.0.1
VoyageAI.Sdk
Enterprise .NET SDK for the Voyage AI REST API — text
embeddings, multimodal (text + image) embeddings, and reranking. Built on
HttpClientFactory, Polly v8 resilience, client-side rate limiting, and
System.Text.Json source generation (AOT/trim safe).
Targets .NET 10 and .NET 8 (LTS).
Installation
dotnet add package VoyageAI.Sdk
Quick start (ASP.NET Core)
appsettings.json:
{
"VoyageAI": {
"ApiKey": "pa-...",
"MaxRetryAttempts": 3,
"ClientSideRpmLimit": 1900
}
}
Program.cs:
builder.Services.AddVoyageAI();
public class MyService(IEmbeddingsClient embeddings)
{
public async Task<float[]> EmbedAsync(string text, CancellationToken ct)
{
var response = await embeddings.EmbedAsync(
new EmbeddingRequest { Model = VoyageAIModels.Voyage3, Input = text },
ct);
return response.Data[0].Embedding.ToArray();
}
}
If ApiKey is omitted from configuration it is read from the VOYAGE_API_KEY
environment variable.
Quick Start (console / standalone host)
var host = Host.CreateApplicationBuilder();
host.Services.AddVoyageAI(opts =>
{
opts.ApiKey = Environment.GetEnvironmentVariable("VOYAGE_API_KEY")!;
opts.MaxRetryAttempts = 5;
});
var app = host.Build();
var embeddings = app.Services.GetRequiredService<IEmbeddingsClient>();
Text Embeddings
var req = new EmbeddingRequest
{
Model = VoyageAIModels.Voyage3Large,
Input = new[] { "I like cats", "I also like dogs" },
InputType = InputType.Document,
OutputDimension = 1024,
};
var res = await embeddings.EmbedAsync(req, ct);
foreach (var item in res.Data)
{
Console.WriteLine($"#{item.Index}: {item.Embedding.Count} dims");
}
Pass a single string via the implicit conversion (Input = "hello") or build a batch
explicitly (EmbeddingInput.From(...)). The API allows up to 128 inputs per request; the
SDK enforces this client-side.
Multimodal Embeddings
var req = new MultimodalEmbeddingRequest
{
Model = VoyageAIModels.VoyageMultimodal3,
Inputs = new[]
{
MultimodalInput.From(
new TextContentPart("This is a banana."),
new ImageUrlContentPart("https://example.com/banana.jpg")),
},
};
var res = await multimodal.EmbedAsync(req, ct);
Use ImageBase64ContentPart with a data:image/jpeg;base64,... data URL to send image
bytes directly.
Reranking
var req = new RerankRequest
{
Model = VoyageAIModels.Rerank2,
Query = "When was the UN founded?",
Documents = new[] { "The UN was founded in 1945.", "Cats are mammals." },
TopK = 1,
ReturnDocuments = true,
};
var res = await rerank.RerankAsync(req, ct);
foreach (var r in res.Data)
{
Console.WriteLine($"#{r.Index} score={r.RelevanceScore:0.000}: {r.Document}");
}
Configuration Reference
| Property | Default | Description |
|---|---|---|
ApiKey |
(env fallback) | Bearer token; falls back to VOYAGE_API_KEY. |
BaseAddress |
https://api.voyageai.com/v1/ |
API base URL. |
RequestTimeout |
00:01:40 |
Per-request HTTP timeout. |
MaxRetryAttempts |
3 |
Retries on 429 / 5xx (0–10). |
ClientSideRpmLimit |
1900 |
Client-side requests-per-minute guard. |
CircuitBreakerFailureRatio |
0.5 |
5xx failure ratio that opens the breaker. |
CircuitBreakerDuration |
00:00:30 |
How long the breaker stays open. |
Resilience & Rate Limiting
Two complementary layers (per the design spec):
- Client-side RPM guard — a
SlidingWindowRateLimiter(six 10-second segments) rejects outbound traffic aboveClientSideRpmLimitwithVoyageAIRateLimitException. - Server-side 429 back-off — the Polly retry pipeline honours the
Retry-Afterheader (delta-seconds or HTTP-date), falling back to exponential backoff with jitter. The circuit breaker trips only on 5xx, never on 429.
Error Handling
VoyageAIException (base — catch for any SDK failure)
├── VoyageAIAuthException (HTTP 401)
├── VoyageAIRateLimitException (HTTP 429 / client guard; exposes RetryAfter)
└── VoyageAIValidationException (HTTP 400 / client-side Guard)
try { await embeddings.EmbedAsync(req, ct); }
catch (VoyageAIRateLimitException ex) when (ex.RetryAfter is { } wait)
{
await Task.Delay(wait, ct);
}
AOT & Trimming
All serialization goes through the source-generated VoyageAIJsonContext. The project is
IsAotCompatible with full trimming on .NET 10; no reflection-based JSON or validation.
License
MIT — see LICENSE.
| Product | Versions 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 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.9)
- VoyageAI.Sdk.Abstractions (>= 1.0.1)
-
net8.0
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.9)
- System.Text.Json (>= 10.0.9)
- VoyageAI.Sdk.Abstractions (>= 1.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on VoyageAI.Sdk:
| Package | Downloads |
|---|---|
|
VoyageAI.AgentFramework
Microsoft Agent Framework integration for the Voyage AI .NET SDK. Composes a search stage (IVoyageRagSearcher<T>) with the Voyage reranker and wires the result into TextSearchProvider for RAG on ChatClientAgentOptions, AIAgentBuilder, and ChatClientBuilder. |
|
|
VoyageAI.Microsoft.Extensions.AI
Microsoft.Extensions.AI integration for the Voyage AI .NET SDK. Implements IEmbeddingGenerator<string, Embedding<float>> over Voyage text embeddings, so Voyage plugs into the standard .NET AI composition model (caching, batching, logging, OpenTelemetry, MongoDB auto-embedding, VectorData). |
GitHub repositories
This package is not used by any popular GitHub repositories.