Universal.Databricks.Client
1.2.0
dotnet add package Universal.Databricks.Client --version 1.2.0
NuGet\Install-Package Universal.Databricks.Client -Version 1.2.0
<PackageReference Include="Universal.Databricks.Client" Version="1.2.0" />
<PackageVersion Include="Universal.Databricks.Client" Version="1.2.0" />
<PackageReference Include="Universal.Databricks.Client" />
paket add Universal.Databricks.Client --version 1.2.0
#r "nuget: Universal.Databricks.Client, 1.2.0"
#:package Universal.Databricks.Client@1.2.0
#addin nuget:?package=Universal.Databricks.Client&version=1.2.0
#tool nuget:?package=Universal.Databricks.Client&version=1.2.0
Universal.Databricks.Client
.NET client for the Databricks Unity Gateway, Unity Catalog service APIs, and Genie conversations.
Quick start
dotnet add package Universal.Databricks.Client
using Universal.Databricks.Client;
using Universal.Databricks.Client.AIGateway.OpenAI.V1.Chat;
using DatabricksClient databricks = new DatabricksClient(
Environment.GetEnvironmentVariable("DATABRICKS_HOST"),
Environment.GetEnvironmentVariable("DATABRICKS_TOKEN"));
CreateCompletionResponse response = await databricks.AIGateway.Mlflow.Chat.CreateCompletionAsync(new CreateCompletionRequest
{
Model = Environment.GetEnvironmentVariable("DATABRICKS_MODEL"),
MaxTokens = 256,
Messages = [new UserMessage("Hello")],
});
Set DATABRICKS_HOST and DATABRICKS_TOKEN through your local configuration. Set DATABRICKS_MODEL to a model service available in your workspace; AIGateway.Models.ListModelsAsync lists the models the caller can query. Use DatabricksClient.FromServicePrincipal for OAuth machine-to-machine authentication. Failed calls throw DatabricksException.
API map
| Property | Path |
|---|---|
AIGateway.Mlflow |
/ai-gateway/mlflow/v1: Chat Completions, Responses, Embeddings |
AIGateway.NativeOpenAI |
/ai-gateway/openai/v1: Chat Completions, Responses, Embeddings, Completions |
AIGateway.NativeAnthropic |
/ai-gateway/anthropic/v1: Messages, models |
AIGateway.NativeGemini |
/ai-gateway/gemini/v1beta: generateContent |
AIGateway.Cursor, AIGateway.Codex |
/ai-gateway/cursor/v1, /ai-gateway/codex/v1 |
AIGateway.SystemOne |
/ai-gateway/typesafe/v1/systemone |
AIGateway.Mcp |
/ai-gateway/mcp-services/{name}, /ai-gateway/skills/ |
AIGateway.Models |
/ai-gateway/v1/models |
AIGateway.ProviderPassthrough |
/ai-gateway/* through a model provider service |
UnityCatalog.* |
/api/2.1/unity-catalog: model services, model provider services, MCP services, skills, agent services, permissions |
Genie |
/api/2.0/genie: space discovery, conversations, messages, feedback, query results and re-execution; SQL result chunks through /api/2.0/sql/statements |
AIGateway.RequestOptions sets request tags, a model provider service, and coding agent mode for every gateway request.
Genie conversations
using Universal.Databricks.Client;
using Universal.Databricks.Client.Genie;
using DatabricksClient databricks = DatabricksClient.FromServicePrincipal(
Environment.GetEnvironmentVariable("DATABRICKS_HOST"),
Environment.GetEnvironmentVariable("DATABRICKS_CLIENT_ID"),
Environment.GetEnvironmentVariable("DATABRICKS_CLIENT_SECRET"),
scope: "genie");
string spaceId = Environment.GetEnvironmentVariable("DATABRICKS_GENIE_SPACE_ID");
GenieMessage answer = await databricks.Genie.StartConversationAndWaitAsync(
spaceId, new GenieMessageRequest { Content = "What were total sales last month?" });
foreach (GenieAttachment attachment in answer.Attachments ?? [])
{
if (attachment.Text != null)
{
Console.WriteLine(attachment.Text.Content);
}
if (attachment.Query != null)
{
GenieQueryResult result = await databricks.Genie.GetMessageAttachmentQueryResultAsync(
spaceId, answer.ConversationId, answer.MessageId ?? answer.Id, attachment.AttachmentId);
// result.StatementResponse contains SQL execution status, schema, and the first data chunk.
}
}
GenieMessage followup = await databricks.Genie.CreateConversationMessageAndWaitAsync(
spaceId, answer.ConversationId, new GenieMessageRequest { Content = "Break that down by region." });
OAuth tokens are cached and renewed two minutes before their expires_in lifetime ends. Genie endpoints require genie scope; GetStatementResultChunkAsync also requires sql, so use scope: "genie sql" or all-apis when retrieving subsequent chunks. The service principal also needs access to the space, warehouse, and underlying data.
The wait helpers poll every five seconds for up to ten minutes by default. Both values are configurable, including a 30-second polling interval. Their timeout covers polling after submission; the cancellation token covers both stages. Cancellation stops waiting. It does not cancel server execution. FAILED, CANCELLED, and QUERY_RESULT_EXPIRED throw GenieMessageException, which retains the returned message. HTTP failures throw DatabricksException. Each endpoint call makes one attempt; callers own retry policies. Use ExecuteMessageAttachmentQueryAsync explicitly to rerun an expired query.
List operations return one page and a NextPageToken; pass that token through GenieListOptions for the next page. SQL result data preserves strings and null cells, schema, truncation metadata, and next-chunk identifiers. Full-result downloads, visualization downloads, agent mode, and space administration are outside this client's current coverage.
Official contracts: OAuth M2M, Genie conversations, Genie spaces, and SQL result chunks.
Run local checks with dotnet test --filter "TestCategory!=Live". The opt-in LiveGenieTests workflow uses DATABRICKS_HOST, DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET, DATABRICKS_GENIE_SPACE_ID, and DATABRICKS_GENIE_TEST_QUESTION (a question that produces SQL). Run it with dotnet test --filter "FullyQualifiedName~LiveGenieTests". It creates a conversation and deletes it afterward. Keep credentials in local secret configuration, outside source control.
License
CC0-1.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.14)
- Universal.Common.Json (>= 2.0.1)
- Universal.Common.Net.Http (>= 5.2.0)
- Universal.Common.Serialization (>= 2.4.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Universal.Databricks.Client:
| Package | Downloads |
|---|---|
|
Universal.Operative.Sdk.Discrete.Databricks
Databricks Unity Gateway adapters for Universal.Operative.Sdk.Discrete. |
|
|
Universal.Operative.Sdk.Databricks
REST-backed Databricks Genie tools for Operative, supporting multiple spaces and workspaces. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Adds Genie space discovery, conversations, follow-up messages, polling, query results and re-execution, SQL result chunks, history, and feedback. Supports existing OAuth service principal authentication.