SDKs
Client and authentication
Create a client in each SDK, give it an API key, and set the base URL, timeout and retries.
The key
Every SDK authenticates the same way the API does: Authorization: Bearer uarp_<prefix>_<secret>. Create a key in your company's settings at https://snaga.ai.
The secret half is shown once and never again, so store it right away. Give each key the
narrowest set of scopes that does its job; Authentication
covers keys and scopes in detail.
Environment variables
Each SDK can build a client from the environment, which keeps the key out of your source:
| Variable | Used for |
|---|---|
UARP_API_KEY | The API key. Read first. |
SNAGA_API_KEY | The API key, if UARP_API_KEY is not set. |
UARP_BASE_URL | The API address. Defaults to https://api.snaga.ai. |
An explicit argument always wins over the environment.
Create a client
TypeScript
import { UarpClient } from 'uarp-sdk';
const client = new UarpClient({ apiKey: process.env.UARP_API_KEY });
// The platform selects the model itself, so a create is just a name.
const agent = await client.agents.create({ name: 'demo' });
Python
from uarp_sdk import Client
from uarp_sdk.models import CreateAgentRequest
with Client() as client: # UARP_API_KEY (or SNAGA_API_KEY), UARP_BASE_URL
# The platform selects the model itself, so a create is just a name.
agent = client.agents.create(CreateAgentRequest(name="demo"))
print(agent.agent_id, agent.name)
AsyncClient has the same surface, awaited. An omitted key raises ConfigError.
Rust
let client = uarp_sdk::Client::from_env()?; // UARP_API_KEY (or SNAGA_API_KEY), UARP_BASE_URL
Client is cheap to clone; every clone shares one connection pool.
Kotlin
val client = UarpClient.builder()
.apiKey(BuildConfig.UARP_API_KEY)
.build()
UarpClient.fromEnvironment() reads the environment, which suits server-side use. On
Android, pass the key explicitly, and provide it through a backend token exchange or
BuildConfig rather than a string literal in a shipped APK. Every call is a suspend
function.
Swift
import UARPSDK
let client = try UARPClient.fromEnvironment() // UARP_API_KEY (or SNAGA_API_KEY), UARP_BASE_URL
// or: UARPClient(apiKey: "uarp_...")
Ada
Client : constant UARP.Client.Client_Type := UARP.Client.From_Environment;
UARP.Client.Create takes the key and base URL directly.
Operations are grouped by the tags of the API description: client.agents,
client.runs, client.sessions and so on in TypeScript, Python, Kotlin and Swift;
client.agents() in Rust; one child package per tag (UARP.API.Agents) in Ada.
Base URL, timeout and retries
All six default to https://api.snaga.ai, a 60-second timeout per request and 2
retries. Change them when you build the client:
const client = new UarpClient({
apiKey: '...',
timeout: 30_000, // per request, ms
maxRetries: 3,
});
client = Client(
api_key="uarp_...", # else UARP_API_KEY / SNAGA_API_KEY
base_url="https://api.snaga.ai", # else UARP_BASE_URL
timeout=60.0, # seconds, per request
max_retries=2,
)
let client = uarp_sdk::Client::builder()
.api_key(key)
.timeout(std::time::Duration::from_secs(30))
.max_retries(3)
.build()?;
val client = UarpClient.builder()
.apiKey(key)
.timeoutMillis(30_000)
.maxRetries(3)
.build()
var configuration = Configuration(apiKey: key)
configuration.timeout = 30
configuration.maxRetries = 3
let client = UARPClient(configuration: configuration, session: .shared)
In Ada, pass Timeout_Ms => 30_000 and Max_Retries => 3 to UARP.Client.Create;
Timeout_Ms => 0 disables the timeout.
You can also pass your own HTTP client for proxies, custom TLS or tracing: fetch in
TypeScript, http_client=httpx.Client(...) in Python, .http_client(...) in Rust,
.httpClient(...) in Kotlin.
Per-call overrides
Timeout, retry budget, idempotency key and extra headers can also be set for a single call.
Five SDKs take them as a trailing argument (request_options= in Python, options: in
Swift); Rust sets them on a cheap clone of the client, such as
client.with_timeout(..).agents().get(id). Errors and retries
shows them in use.