Full reference
Python SDK
Use Stimulir from application code with explicit project context, tagged inference, versioned prompts, data assets and durable Lab workflows.
Updated
Reviewed against Console v0.2.2. Available actions depend on project access and runtime configuration; check your installed CLI version for command differences.
Install in your application
uv add stimulir
# For websocket voice support:
uv add 'stimulir[realtime]'An isolated uv tool install provides a command, not an import in your application environment. Use the installed package’s signatures when working across versions.
Construct the client
import os
from stimulir import StimulirClient
client = StimulirClient(
api_key=os.environ["STIMULIR_API_KEY"],
project_id=os.environ["STIMULIR_PROJECT_ID"],
tags=["support-summary"],
)The default API origin is https://api.stimulir.com. The application key supplies workspace scope. Load your environment through your application’s configuration; constructing a client does not mean a local dotenv file has been read.
Send tagged inference
reply = client.agent(
prompt="Summarise this example request.",
model=os.environ["STIMULIR_MODEL"],
tag="summary-example",
)
if reply.status == "error":
raise RuntimeError(reply.error)
print(reply.content)Use tags=[…] on the client or a single tag="…" on agent(). An untagged SDK LLM action is rejected before sending. agent() returns an error status for request failures; inspect it instead of treating empty content as success.
Render a versioned prompt
prompt = client.prompts.get("support.summary", label="prod")
text = prompt.render({"request": "Example request"})
reply = client.agent(
prompt=text,
model=os.environ["STIMULIR_MODEL"],
metadata=prompt.lineage,
)Create the prompt and label before fetching it. Keep its returned lineage with the request so an evaluation can identify the production prompt. Changing a label affects callers that resolve that label.
Send conversation history
agent() is a single-prompt convenience method. For a conversation, use an OpenAI-compatible client or client.request() with a complete messages array at /api/v1/inference/chat/completions. Preserve the project header and workflow tags. See Inference API.
Use a panel and judge
client.fusion.complete() requests a fused answer. Provide a tag through the call or client. Panel and judge calls can increase usage, so evaluate their quality and cost on your own cases. See Fusion.
Use realtime voice
The optional realtime package exposes a connection lifecycle and typed audio events. Set up each connection once, send supported audio frames, and handle completion and disconnection. See Realtime voice.
Prepare reproducible evidence
Use client.data_assets to register or upload data, curate a trace, update metadata, stage assets and create a snapshot. Registration alone does not upload bytes. Keep the snapshot ID used by an evaluation. See Data assets.
Compare and improve
client.lab_evals manages evaluation runs, results, derivations and promotion proposals. client.improve inspects project evidence, previews a bounded run and starts only from a reviewed runnable preview. client.rsi remains an alias. Never infer completion from the returned creation response.
Evaluation covers comparable experiments. Improve covers preview tokens, cohort fingerprints, cost boundaries and the separate promotion decision.
Manage training and adapters
Use lab_train, lab_jobs, lab_adapters and lab_projectors for their distinct tasks. A training request needs eligible data, a compatible model and configured compute. Creating or loading an adapter does not establish an improvement in production.
Execute a supported capability
client.capabilities.execute() invokes a capability available to the workspace. Supply its typed payload and examine its outcome. Capability execution can incur cost or change state; inspect the specific capability contract first.
Run a stored-input workflow
Upload input through client.storage, import a reviewed skill through client.skills, and pass its storage key to client.sandbox.run(). A sandbox output key is not an object ID; use storage.get_by_key() or read_by_key() to retrieve it. Pipeline execution stops at the first unsuccessful step.
Configure an app integration
Use the CLI Codex integration to preview and apply local configuration. Do not print command-backed bearer tokens into logs or commit generated credentials.
Method catalogue
The catalogue below lists public SDK operations and parameter names. Optional fields and accepted payloads depend on the selected operation. Start with the task-specific reference and inspect a returned typed error before retrying.
SDK method catalogue
Expand a client to inspect public methods and parameter names. Read each operation’s task guide before supplying a payload or starting work. The SDK returns platform responses; handle errors and inspect completion state before using a result.
promptStimulirPrompt
from_payload(payload)- Returns the platform response; inspect its status and error detail.
lineage- Read this property on the object.
render(variables)- Substitute
{{key}}and{key}placeholders incontent.
clientStimulirClient
request(method, path, params, json_body, timeout, trace_context)- Returns the platform response; inspect its status and error detail.
prompt(prompt_key, variables)- Fetch and render a prompt template by key.
agent(prompt, role, tag, model, metadata, trace_context)- Execute a managed agent completion, handling BYOK checks on the backend.
client.privacyPrivacyClient
deidentify(text, method, overrides)- De-identify
text. Returns{text, redactions, entity_types}; the raw input PII is never echoed back. extract(text)- Detect PII entities in
text. Returns the list of entities (each withentity_type/span/text/confidence). capabilities()- Supported anonymization methods + recognizer count.
client.promptsPromptsClient
list(active_only)- Returns the platform response; inspect its status and error detail.
get(key, label, version)- Returns the platform response; inspect its status and error detail.
versions(key)- Returns the platform response; inspect its status and error detail.
create_version(key, content, name, prompt_type, variables, label, tags, change_notes)- Returns the platform response; inspect its status and error detail.
label(key, version, label)- Returns the platform response; inspect its status and error detail.
patch_metadata(key, version)- Returns the platform response; inspect its status and error detail.
archive(key, version)- Returns the platform response; inspect its status and error detail.
client.modelsModelsClient
list()- Returns the platform response; inspect its status and error detail.
client.fusionFusionClient
complete(prompt, panel, judge, max_tier, temperature, max_tokens, tag)- Run one fusion chat completion and return the completion payload.
client.data_assetsDataAssetsClient
list(stage, kind, status, target, tag, limit)- Returns the platform response; inspect its status and error detail.
create(name, kind, stage, target, tags)- Create a new data asset.
upload(file, name, target)- Returns the platform response; inspect its status and error detail.
from_trace(trace_id, source, name, target, payload, tags)- Create a data asset from an existing trace.
patch(asset_id)- Returns the platform response; inspect its status and error detail.
stage(asset_id, stage, status, lineage_event)- Returns the platform response; inspect its status and error detail.
unstage(asset_id)- Returns the platform response; inspect its status and error detail.
bulk_stage(asset_ids, stage, status, target, lineage_event)- Returns the platform response; inspect its status and error detail.
snapshot(asset_id)- Returns the platform response; inspect its status and error detail.
client.improveImproveClient
inspect(source, target, limits, experiments, evaluation)- Read project Improve inventory without selecting or spending on a run.
preview(source_window, source_from, source_to, folder_id, folder_name, trace_tags, prompt_keys, models, limit, sampling, sampling_seed, prompt_ref, max_iterations, budget_gbp, experiment_mode, candidate_models, baseline_model, allow_managed_inference, evaluation)- Resolve cohort, incumbent, evaluator, candidates and cost read-only.
run(source_window, source_from, source_to, folder_id, folder_name, trace_tags, prompt_keys, models, limit, sampling, sampling_seed, normalized_source, preview_token, cohort_fingerprint, prompt_ref, max_iterations, budget_gbp, experiment_mode, candidate_models, baseline_model, allow_managed_inference, evaluation, idempotency_key, tags)- Start one server-owned diagnostic run and return its durable handoff.
get(run_id)- Returns the platform response; inspect its status and error detail.
overview(run_id)- Returns the platform response; inspect its status and error detail.
results(run_id)- Read the durable outcome; this never applies a promotion.
continue_(run_id, instruction, idempotency_key)- Ask the server controller to diagnose and derive one next step.
resume(run_id, rationale, prompt_content, instruction)- Compatibility lane for the explicit-proposer v0.1 controller.
client.lab_evalsLabEvalsClient
list_runs(limit, status, include_archived)- Returns the platform response; inspect its status and error detail.
get_run(run_id)- Returns the platform response; inspect its status and error detail.
get_agent_status(run_id)- Bounded run state without payloads, narratives, steer text, or raw errors.
get_agent_iteration(run_id)- Typed lineage IDs, counts, fingerprints and outcomes only.
list_champions(comparability_key, limit)- Promoted champions, newest
promoted_atfirst. list_rejections(comparability_key, identity_hash, run_id, limit)- The rejection ledger, newest first.
list_evaluators(include_archived)- Evaluators visible to the active workspace.
create_evaluator(name, forbidden_phrases, required_phrases, max_prompt_chars, invariant_key, description)- Create a reusable evaluator whose invariants gate candidates pre-spend.
list_proposals(status, limit)- Promotion proposals from completed runs, newest first.
review_proposal(proposal_id)- Review one explicit proposal through the bounded agent projection.
prepare_promotion_proposal(run_id)- Prepare a human-review proposal for one completed eval; never apply it.
apply_proposal(proposal_id, reason)- Apply a promotion proposal: move the production label, pin the champion.
create_run(tags)- Create an eval run. A faithful mapping of
POST /runs. execute_run(run_id, max_cases, max_candidates)- Returns the platform response; inspect its status and error detail.
run_url(run_id, view)- Console deep link for a run, or None when the console origin is unknown.
get_run_tree(run_id, include_archived)- The whole lineage tree containing
run_id, from any run id in it. derive_run(run_id, rationale, derive_kind, prompt_ref, prompt_content, source_candidate_key, adapter_id, adapter_format, derive_instruction, stop_parent, start, idempotency_key, max_cases, max_candidates)- Branch a child run from one candidate of
run_id. create_steer(run_id, body, kind, idempotency_key)- Attach an instruction to a run for whichever agent polls it next.
list_steers(run_id, pending, include_archived)- Returns the platform response; inspect its status and error detail.
ack_steer(run_id, steer_id, consumed_by, note)- Record that a steer was consumed. Write-once and idempotent.
delete_runs(run_ids, mode, include_descendants)- Archive (default) or hard-delete runs.
score_niah(family, checkpoint_dir, examples, seed, device, model_dir, timeout)- Score a trained checkpoint on held-out NIAH retrieval (vs zero-LoRA).
score_adapter(family, adapter_dir, examples, seed, device, model_dir, timeout)- Score a PEFT LoRA adapter directory on held-out retrieval (vs base).
score_rl(family, environment, policy, checkpoint_dir, tasks, max_new_tokens, temperature, seed, pass_threshold, device, timeout)- Score a policy on an RL environment and report reward statistics.
client.lab_trainLabTrainClient
d2l(family, examples, eval_examples, epochs, lr, seed, checkpoint_dir, device, compute, timeout)- Doc-to-LoRA (hypernetwork context internalisation) training job.
sft(family, lora_rank, init_adapter_dir, examples, epochs, lr, l1_coef, eval_examples, min_blocks, max_blocks, log_every, seed, device, checkpoint_dir, dataset, split_ratio, split_seed, eval_cohort, compute, timeout)- Supervised fine-tuning of a plain PEFT LoRA adapter (sft-peft-lora).
rl(family, environment, prompts, group_size, policy, lora_rank, init_checkpoint_dir, lr, kl_beta, seed, device, checkpoint_dir, compute, timeout)- RL (GRPO-style) training job on an RL environment.
internalize(document_text, compute, name, session_key, ttl_seconds, pin, timeout)- Internalize a document on an explicitly selected managed worker.
client.lab_jobsLabJobsClient
list()- Durable Console jobs plus untracked legacy runtime jobs.
get(job_id)- Returns the platform response; inspect its status and error detail.
cancel(job_id)- Cancel a running job (RL / PEFT SFT; D2L SFT runs to completion).
client.lab_adaptersLabAdaptersClient
list()- Registered adapters (unwrapped from the runtime's
"adapters"/"data"envelope). get(adapter_id)- Returns the platform response; inspect its status and error detail.
load(adapter_id)- Load an adapter into the runtime (hot-swap for inference).
unload(adapter_id)- Returns the platform response; inspect its status and error detail.
client.lab_projectorsLabProjectorsClient
list(modality, status, limit)- Returns the platform response; inspect its status and error detail.
get(run_id)- Returns the platform response; inspect its status and error detail.
create(modality, stages, encoder, lora_rank, lora_alpha, data_asset_id, name)- Create a projector tuning run.
delete(run_id)- Returns the platform response; inspect its status and error detail.
client.capabilitiesCapabilitiesClient
execute(key, scope, args, confirmed)- Returns the platform response; inspect its status and error detail.
client.storageStorageClient
upload(file, workspace_id, filename, content_type)- Upload an input into tenant storage and return its storage key.
list(workspace_id, task_id)- Returns the platform response; inspect its status and error detail.
folders(workspace_id)- Returns the platform response; inspect its status and error detail.
access_url(object_id, expires_in_seconds, download)- Returns the platform response; inspect its status and error detail.
delete(object_id)- Returns the platform response; inspect its status and error detail.
get_by_key(storage_key, workspace_id, expires_in_seconds, download)- Resolve a storage key to its object + a signed access URL.
read_by_key(storage_key, workspace_id)- Download the bytes behind a storage key (upload -> run -> read loop closer).
client.skillsSkillsClient
discover(repo_owner, repo_name, workspace_id, ref)- Returns the platform response; inspect its status and error detail.
import_(repo_owner, repo_name, skill_paths, workspace_id, ref)- Returns the platform response; inspect its status and error detail.
list(workspace_id)- Returns the platform response; inspect its status and error detail.
client.sandboxSandboxClient
list(workspace_id)- Returns the platform response; inspect its status and error detail.
run(skill, workspace_id, input_key, params)- Returns the platform response; inspect its status and error detail.
pipe(steps, input_key, workspace_id)- Run an ordered list of skills, threading each output into the next.
client.tracesTracesClient
export(format, source, status, context, api_key_id, tag, ts_from, ts_to, include_content, limit, output_path)- Export traces as JSONL/JSON/CSV and return the raw body bytes.
client.computeComputeClient
offers(provider, region)- Purchasable GPU configurations.
offer_sources()- Which providers answered the aggregate listing, and why any didn't.
launch(offer_id, region, ssh_key_names, provider, count, use_spot, image, cloud_init, name, extra)- Launch instance(s) from an offer.
launch_worker(offer_id, region, ssh_key_names, model_repo, model_slug, hybrie_ref, provider, count, use_spot, env)- Provision, bootstrap and register a worker from one exact offer.
instances(provider)- Every instance the provider reports, as
{"id", "status"}rows. status(instance_id, provider)- Returns the platform response; inspect its status and error detail.
terminate(instance_id, provider)- Tear an instance down. Idempotent — an already-gone id is success.
peers()- Remote runtime peers currently registered with the control node.
ensure_warm()- Ask the autoscaler to bring the mesh up to its warm floor.
client.compute.realtime_instancesRealtimeInstancesClient
ensure(project_id, name, max_rooms, max_participants)- Returns the platform response; inspect its status and error detail.
list(project_id)- Returns the platform response; inspect its status and error detail.
get(instance_id)- Returns the platform response; inspect its status and error detail.
update(instance_id, max_rooms, max_participants, expected_revision)- Returns the platform response; inspect its status and error detail.
start(instance_id, expected_revision)- Returns the platform response; inspect its status and error detail.
suspend(instance_id, expected_revision)- Returns the platform response; inspect its status and error detail.
delete(instance_id)- Returns the platform response; inspect its status and error detail.
get_application_bootstrap(instance_id)- Read the application test-session bootstrap: URL and secret reference only.
set_application_bootstrap(instance_id, url, secret_id)- Point test sessions at the application;
secret_idis a project agent secret ID. clear_application_bootstrap(instance_id)- Returns the platform response; inspect its status and error detail.
client.roomsRoomsClient
create(instance_id, mode, metadata, key)- Create a room; reuse a stable key when retrying an uncertain outcome.
get(room_id, instance_id)- Returns the platform response; inspect its status and error detail.
grant(room_id, instance_id, participant, name, role, ai_consent, recording_consent, vision_consent, can_publish_video, can_subscribe, ttl)- Issue a short-lived grant. Consent defaults to false; no implicit recording.
command(room_id, instance_id, type, mode, owner, expected_version)- Returns the platform response; inspect its status and error detail.
handoff(room_id, owner, instance_id, expected_version)- Returns the platform response; inspect its status and error detail.
set_mode(room_id, mode, instance_id, expected_version)- Returns the platform response; inspect its status and error detail.
close(room_id, instance_id)- Returns the platform response; inspect its status and error detail.
async_clientAsyncStimulirClient
request(method, path, params, json_body, trace_context, timeout)- Returns the platform response; inspect its status and error detail.
aclose()- Returns the platform response; inspect its status and error detail.
client.imagesImagesClient
generate(model, prompt, n, size, quality, output_format, background, output_compression, moderation, aspect_ratio, image_size, response_format, trace_context, timeout)- Return the gateway's
created,dataand optionalusageJSON.
client.compute.realtime_agentsRealtimeAgentsClient
register(name, version, manifest, project_id)- Returns the platform response; inspect its status and error detail.
list(project_id, name)- Returns the platform response; inspect its status and error detail.
get(agent_version_id)- Returns the platform response; inspect its status and error detail.
client.compute.realtime_agent_deploymentsRealtimeAgentDeploymentsClient
create(instance_id, agent_version_id, name, key)- Reuse key after an uncertain response; changed key reuse is rejected.
list(instance_id)- Returns the platform response; inspect its status and error detail.
get(deployment_id, instance_id)- Returns the platform response; inspect its status and error detail.
suspend(deployment_id, instance_id)- Prevent new dispatches and drain existing workers.
resume(deployment_id, instance_id)- Make a suspended binding available; stopped rooms are not restarted.
delete(deployment_id, instance_id)- Permanently retire this binding and drain workers; retain history.
dispatch(deployment_id, instance_id, room_id, key)- Request attachment to an existing room; no implicit room creation.
stop_dispatch(dispatch_id, instance_id, deployment_id)- Request a stop; execution status remains server-observed.
list_dispatches(deployment_id, instance_id)- Returns the platform response; inspect its status and error detail.
get_dispatch(dispatch_id, instance_id, deployment_id)- Returns the platform response; inspect its status and error detail.
test_session(deployment_id, instance_id)- Ask the instance's configured application for a signed test session link.
client.compute.realtime_agent_secretsRealtimeAgentSecretsClient
set(name, value, project_id)- Returns the platform response; inspect its status and error detail.
list(project_id)- Returns the platform response; inspect its status and error detail.
get(secret_id)- Returns the platform response; inspect its status and error detail.