Skip to main content
The Figranium class is a final class with two initializers: a designated initializer that accepts a URL and an authentication enum, and a convenience initializer that accepts a String base URL and an optional API key. Every option is optional, and the SDK falls back to sensible defaults so a local install works with Figranium().

Initializers

Designated initializer

Client.swift
URL
Absolute URL of your Figranium server. Must use http or https (enforced with a precondition). Defaults to http://localhost:11345.
FigraniumAuthentication
Authentication strategy. Defaults to .none. See Authentication for details.
[String: String]
Default headers merged into every request. Per-call RequestOptions.headers override these.
TimeInterval
Client-wide default timeout for non-stream requests, in seconds. Defaults to 30.
URLSession
The URLSession used for all network requests. Defaults to .shared. The SDK never replaces a caller-supplied session.

Convenience initializer

Client.swift
String
Absolute URL of your Figranium server as a string. Must be a valid URL (enforced with a precondition). Defaults to "http://localhost:11345".
String?
API key sent as Authorization: Bearer <key> by default. When nil, authentication is .none.
String
Header name for the API key. Defaults to "authorization". Set to "x-api-key" if your deployment expects that header.
TimeInterval
Client-wide default timeout for non-stream requests, in seconds. Defaults to 30.

Option details

baseURL

example.swift

authentication

The FigraniumAuthentication enum has three cases:
  • .apiKey(String, header: String = "authorization") sends the key as Authorization: Bearer <key> when the header is "authorization", or as the raw key for any other header name.
  • .session sends no auth header and relies on URLSession cookies.
  • .none sends no auth header.
example.swift
See Authentication for how to create and manage API keys.

timeout

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

session

Provide a preconfigured URLSession for custom delegate behavior, certificate pinning, or test doubles. The SDK never replaces a caller-supplied session.
example.swift

headers

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

Complete example

example.swift

Client resources

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