Noukai Client
Main client for interacting with Noukai flows.
Noukai (Sync Client)
Main synchronous client for executing flows.
Constructor
Parameters:
api_key(str, optional): API key starting withnk_. Falls back toNOUKAI_API_KEYenv var.org(str, optional): Default organization name for flow lookups. Must be paired withproject. If set,client.flow("slug")uses the defaults; if omitted,client.flow("org/project/slug")is required.project(str, optional): Default project name for flow lookups. Must be paired withorg. If set,client.flow("slug")uses the defaults; if omitted,client.flow("org/project/slug")is required.env(str, optional): Environment for base URL resolution. Accepts"dev"/"development"(→http://localhost:8080/api/v1) or"production"(default →https://api.noukai.xyz/api/v1). Falls back toNOUKAI_ENVenv var.timeout(int, optional): Request timeout in milliseconds. Default: 300000 (5 minutes).max_retries(int, optional): Number of retries on 5xx errors. Default: 1.onLog(callable, optional): Logging hook that receivesLogEventobjects.logPayloads(bool, optional): If True, include request/response bodies in log events. Default: False.
Raises:
AuthenticationError: If no API key is provided or the prefix is invalid.ValueError: If only one oforgorprojectis provided (both required together).
Example:
Methods
flow(identifier) -> Flow
Get a flow proxy for executing a specific flow.
Parameters:
identifier(str | dict): Flow identifier in one of three forms:- Single-segment slug (e.g.,
"grade-3") — only valid if the client was constructed withorgandprojectdefaults - Three-segment path (e.g.,
"org/project/slug") — fully-qualified, works regardless of defaults - Dictionary (e.g.,
{"org": "acme", "project": "spelling", "slug": "grade-3"}) — kwargs form, overrides defaults if provided
- Single-segment slug (e.g.,
Returns: Flow proxy object.
Raises:
ValueError: If a single-segment slug is given without client-level defaults, or if the identifier format is invalid.
Example:
close() -> None
Close the client and clean up resources. Called automatically with context manager.
Example:
Properties
default_org (read-only)
Returns the organization name passed to the constructor, or None if not set.
default_project (read-only)
Returns the project name passed to the constructor, or None if not set.
Context Manager
Use with to automatically close the client:
AsyncNoukai (Async Client)
Asynchronous client for non-blocking flow execution. Same API as Noukai but with async/await.
Constructor
Same as Noukai, but used with async with:
Methods
async flow(identifier) -> AsyncFlow
Same as sync Flow.flow() but returns AsyncFlow.
async aclose() -> None
Async equivalent of close().
Properties
Same as Noukai:
default_org(read-only): Organization name from constructor, orNonedefault_project(read-only): Project name from constructor, orNone
Context Manager
LogEvent (Type)
Structured logging event passed to onLog hook.
Attributes:
phase(str): One of"request","response","retry"method(str): HTTP method (GET, POST, etc.)path(str): Request pathattempt(int): Attempt number (1 for first try, 2+ for retries)statusCode(int, optional): HTTP status code (only on response)requestId(str, optional): Request ID from response headersrequestBody(any, optional): Request body (iflogPayloads=True)responseBody(any, optional): Response body (iflogPayloads=True)
Example:
FlowIdentifier (Type)
Flow identifier can be a string or dict:
String format: "org/project/slug"
Dict format: {"org": "acme", "project": "spelling", "slug": "grade-3"}
Both refer to the same flow.