Client Wrappers

Sagewai ships client libraries for 17 programming languages. Each wrapper covers the same API surface — Harness, Registry, Observatory, and Gateway — and supports the same three authentication methods.

Supported Languages

LanguagePackageStatusInstall
Pythonsagewai-clientStablepip install sagewai-client
TypeScriptsagewaiStablenpm install sagewai
Gosagewai-goStablego get github.com/sagewai/sagewai-go
RustsagewaiStablecargo add sagewai
Javacom.sagecurator:sagewaiIn developmentMaven / Gradle
C# / .NETSagewaiIn developmentdotnet add package Sagewai
Kotlincom.sagecurator:sagewaiIn developmentGradle
RubysagewaiIn developmentgem install sagewai
SwiftSagewaiIn developmentSwift Package Manager
C++sagewaiIn developmentCMake FetchContent
PHPsagecurator/sagewaiIn developmentcomposer require sagecurator/sagewai
DartsagewaiIn developmentdart pub add sagewai
Scalacom.sagecurator:sagewaiIn developmentSBT
PerlSagewaiIn developmentcpanm Sagewai
ElixirsagewaiIn developmentMix
React NativesagewaiMobilenpm install sagewai
FluttersagewaiMobiledart pub add sagewai

Stable wrappers are fully implemented, tested, and published to their package registries. In development wrappers follow the same API surface — install commands will work once those packages are published. Mobile wrappers share their base language (TypeScript for React Native, Dart for Flutter).

Quick Start by Language

Python

from sagewai_client import SagewaiClient

client = SagewaiClient(
    base_url="http://localhost:8100",
    api_key="sk-harness-...",
)

response = client.chat("gpt-4o", "What is Sagewai?")
print(response.content)

TypeScript / JavaScript

import { SagewaiClient } from "sagewai";

const client = new SagewaiClient({
  baseUrl: "http://localhost:8100",
  apiKey: "sk-harness-...",
});

const response = await client.chat({
  model: "gpt-4o",
  messages: [{ role: "user", content: "What is Sagewai?" }],
});
console.log(response.content);

Go

package main

import (
    "context"
    "fmt"
    sagewai "github.com/sagewai/sagewai-go"
)

func main() {
    client := sagewai.NewClient(
        sagewai.WithBaseURL("http://localhost:8100"),
        sagewai.WithAPIKey("sk-harness-..."),
    )

    ctx := context.Background()
    response, err := client.Chat(ctx, &sagewai.ChatRequest{
        Model:    "gpt-4o",
        Messages: []sagewai.Message{{Role: "user", Content: "What is Sagewai?"}},
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(response.Content)
}

Rust

use sagewai::SagewaiClient;

#[tokio::main]
async fn main() -> Result<(), sagewai::Error> {
    let client = SagewaiClient::builder()
        .base_url("http://localhost:8100")
        .api_key("sk-harness-...")
        .build()?;

    let response = client
        .chat("gpt-4o")
        .message("user", "What is Sagewai?")
        .send()
        .await?;

    println!("{}", response.content);
    Ok(())
}

Java

import com.sagecurator.sagewai.SagewaiClient;

var client = SagewaiClient.builder()
    .baseUrl("http://localhost:8100")
    .apiKey("sk-harness-...")
    .build();

var response = client.chat("gpt-4o", "What is Sagewai?");
System.out.println(response.content());

C# / .NET

using Sagewai;

var client = new SagewaiClient("http://localhost:8100", "sk-harness-...");
var response = await client.ChatAsync("gpt-4o", "What is Sagewai?");
Console.WriteLine(response.Content);

Kotlin

import com.sagecurator.sagewai.SagewaiClient

val client = SagewaiClient(
    baseUrl = "http://localhost:8100",
    apiKey = "sk-harness-..."
)

val response = client.chat("gpt-4o", "What is Sagewai?")
println(response.content)

Ruby

require "sagewai"

client = Sagewai::Client.new(
  base_url: "http://localhost:8100",
  api_key: "sk-harness-..."
)

response = client.chat("gpt-4o", "What is Sagewai?")
puts response.content

Swift

import Sagewai

let client = SagewaiClient(
    baseURL: "http://localhost:8100",
    apiKey: "sk-harness-..."
)

let response = try await client.chat(model: "gpt-4o", message: "What is Sagewai?")
print(response.content)

PHP

use Sagewai\Client;

$client = new Client("http://localhost:8100", "sk-harness-...");
$response = $client->chat("gpt-4o", "What is Sagewai?");
echo $response->content;

Dart / Flutter

import 'package:sagewai/sagewai.dart';

final client = SagewaiClient(
  baseUrl: 'http://localhost:8100',
  apiKey: 'sk-harness-...',
);

final response = await client.chat('gpt-4o', 'What is Sagewai?');
print(response.content);

Elixir

client = Sagewai.Client.new(
  base_url: "http://localhost:8100",
  api_key: "sk-harness-..."
)

{:ok, response} = Sagewai.chat(client, "gpt-4o", "What is Sagewai?")
IO.puts(response.content)

Unified API Surface

Every wrapper exposes the same operations:

Harness (LLM Proxy)

MethodDescription
chat(model, messages)Send a chat completion request
chatStream(model, messages)Stream responses via Server-Sent Events
listModels()List available models on the harness

Registry (Agent Governance)

MethodDescription
listAgents()List all registered agents
getAgent(name)Get agent details (model, tools, strategy, run count)

Observatory (Cost Tracking)

MethodDescription
getSpend(orgId?)Get spend summary (daily, monthly, total USD)
getSpendBreakdown(orgId?)Cost breakdown by model

Gateway (Token Management)

MethodDescription
createToken(agentName, grantorId)Create an access token
listTokens(agentName?)List tokens
revokeToken(tokenId)Revoke a token

Health

MethodDescription
health()Check harness health status

Authentication

All wrappers support three authentication methods.

API Key

Best for scripts, services, and development. Sends X-API-Key with every request.

# Python
client = SagewaiClient(base_url="...", api_key="sk-harness-...")
// TypeScript
const client = new SagewaiClient({ baseUrl: "...", apiKey: "sk-harness-..." });
// Go
client := sagewai.NewClient(sagewai.WithAPIKey("sk-harness-..."))

JWT

Best for authenticated users and service-to-service calls. Sends Authorization: Bearer.

# Python
client = SagewaiClient(base_url="...", jwt="eyJhbGciOi...")
// TypeScript
const client = new SagewaiClient({ baseUrl: "...", auth: { type: "jwt", token: "eyJ..." } });
// Go
client := sagewai.NewClient(sagewai.WithJWT("eyJ..."))

OAuth

Supports automatic token refresh for long-lived applications.

// TypeScript — with auto-refresh
const client = new SagewaiClient({
  baseUrl: "http://localhost:8100",
  auth: {
    type: "oauth",
    accessToken: "ya29...",
    refreshToken: "1//0...",
    refreshUrl: "https://auth.sagewai.ai/token",
  },
});

Response Types

ChatResponse

FieldTypeDescription
idstringUnique response ID
modelstringModel used
contentstringResponse text
usage.prompt_tokensintInput tokens
usage.completion_tokensintOutput tokens
usage.total_tokensintTotal tokens

AgentSummary

FieldTypeDescription
namestringAgent name
modelstringDefault model
capabilitiesstring[]Agent capabilities
strategystringExecution strategy

SpendSummary

FieldTypeDescription
daily_usdnumberToday's spend
monthly_usdnumberThis month's spend
total_usdnumberAll-time spend
total_requestsintTotal request count
total_tokensintTotal tokens used

Python SDK vs Client Wrappers

Python SDK (sagewai)Client Wrappers
Installpip install sagewaiLanguage-specific package
PurposeBuild agents, define tools, create workflowsCall agents from any language
RunsAgent code executes locallyHTTP calls to harness/gateway
Use whenDefining agent behaviorIntegrating with existing apps, CI/CD, mobile
FeaturesFull SDK (memory, directives, fleet, admin)Harness + Registry + Observatory + Gateway APIs

In a typical setup: the Python SDK defines and runs your agents on the server; client wrappers let your TypeScript frontend, Go microservice, or Rust CLI call those agents over HTTP.