Skip to main content
The Figranium class is the coroutine-first entry point for the Kotlin SDK. It is created with a single constructor that accepts every configuration option as an optional argument, so a local install works with Figranium(). The constructor uses @JvmOverloads for clean Java interop.

Constructor

Figranium.kt
String
Absolute URL of your Figranium server. Trailing slashes are trimmed automatically. Defaults to http://localhost:11345.
FigraniumAuthentication
Authentication strategy. Defaults to FigraniumAuthentication.None. See Authentication for details.
Map<String, String>
Default headers merged into every request. Per-call RequestOptions.headers override these.
Long
Client-wide default timeout for non-stream requests, in milliseconds. Defaults to 30_000.
OkHttpClient
The underlying OkHttpClient used for all network requests. Defaults to a new OkHttpClient(). The SDK never replaces a caller-supplied client.
kotlinx.serialization.json.Json
kotlinx-serialization Json instance used for encoding and decoding. Defaults to Json { ignoreUnknownKeys = true; explicitNulls = false; encodeDefaults = false }.

Option details

baseUrl

Pass the absolute URL of your Figranium server. The constructor trims any trailing slash before converting it to okhttp3.HttpUrl.
example.kt

authentication

The FigraniumAuthentication sealed interface has three implementations:
  • FigraniumAuthentication.ApiKey(value, header = "authorization") sends the key as Authorization: Bearer <key> when the header is "authorization", or as the raw key for any other header name.
  • FigraniumAuthentication.Session sends no auth header and relies on OkHttpClient cookies.
  • FigraniumAuthentication.None sends no auth header.
example.kt
See Authentication for how to create and manage API keys.

timeoutMillis

Client-wide default timeout for non-stream requests, in milliseconds. Defaults to 30_000. Streams have no default timeout; set a per-call timeoutMillis in RequestOptions if you want a terminal deadline.
example.kt
Individual requests can override this per call with options = RequestOptions(timeoutMillis = 5_000). See Request options.

httpClient

Provide a preconfigured OkHttpClient for custom interceptors, certificate pinning, timeouts, or test doubles. The SDK never replaces a caller-supplied client.
example.kt

headers

Default headers merged into every request. Per-call headers override these.
example.kt

Complete example

example.kt

Client resources

The Figranium instance exposes one property per resource, plus a few top-level convenience helpers. Top-level shortcuts:
  • client.runTask(id, input, options) proxies to tasks.run.
  • client.scrape(input, options) proxies to execution.scrape.
  • client.agent(input, options) proxies to execution.agent.
  • client.headful(input, options) proxies to execution.headful.

Authentication

How to authenticate with API keys, sessions, or no auth.

Request Options

Override timeouts and headers on individual requests.