STAN
STAN sessions: start one, send it messages, follow its runs, and undo what it made.
Access it as client.stan on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.
Methods
All methods
cancel_run
cancel_run(run_id: str) -> StanRun
Stop a STAN run; returns the run.
The run is cancelled at once, queued or running (run_status
cancelled): a running run's in-flight model call is aborted.
Parameters
run_id(str): The run's ID.
Raises
NotFoundError: The run is not yours, or it has already finished.
cancel_session
cancel_session(session_id: str) -> StanSession
Stop the runs a STAN session is working on or has queued; returns the session.
Parameters
session_id(str): The session's ID.
create_session
create_session(*, model_id: str, message: str, mode: str | None = None, active_workflow_id: str | None = None, active_workflow_name: str | None = None, attachments: Sequence[str | os.PathLike[str]] | None = None, wait: bool = True) -> StanRun
Start a new STAN session, beside your other sessions, with its first message.
A session is stored with its first message, so it starts with one. Returns the run
that answers it; session_id is the new session, to send it more messages with
send_message.
Parameters
model_id(str): The model STAN uses in the session; one you may use (required).message(str): The session's first message: what you ask STAN (required).mode(str | None, optional): The working area:general,workflowsordevelop;workflowswhen omitted.active_workflow_id(str | None, optional): A workflow the session works on.active_workflow_name(str | None, optional): That workflow's name.attachments(Sequence[str | os.PathLike[str]] | None, optional): Paths of images (PNG, JPEG, GIF, WebP) and PDF documents to send with the message, assend_messagesends them.wait(bool, optional):True(the default) waits for the run to finish;Falseanswers at once with the run to poll.
Raises
NotFoundError: The model does not exist or you may not use it.
delete_artifact
delete_artifact(artifact_id: str) -> None
Delete one of your STAN artifacts for good.
Every version and its stored content go. Another user's artifact is not found (404).
Parameters
artifact_id(str): The artifact's ID.
end_session
end_session(session_id: str) -> None
End and delete one of your STAN sessions.
Your current session is ended and kept as a past conversation (its artifacts stay with it until that conversation is deleted); any other session is deleted with its history, attachments and the STAN artifacts saved in it.
Parameters
session_id(str): The session's ID.
history
history(*, session_id: str | None = None, turns: int | None = None) -> StanHistory
Read a STAN conversation's messages, without changing which session is current.
Parameters
session_id(str | None, optional): The session; your current (main) session when omitted.turns(int | None, optional): Only the last this many turns; every turn when omitted.
list_checkpoints
list_checkpoints(session_id: str) -> StanCheckpoints
List a STAN session's checkpoints: the points its work can be reverted to.
Parameters
session_id(str): The session's ID.
list_sessions
list_sessions(*, limit: int | None = None) -> SyncPaginator[StanSession]
Your STAN sessions; current marks your main session.
Parameters
limit(int | None, optional): The most sessions to return; all of them when omitted.
list_tool_executions
list_tool_executions(*, run_id: str | None = None, limit: int | None = None) -> SyncPaginator[StanToolExecution]
STAN's tool calls for you, newest first.
Parameters
run_id(str | None, optional): Only one run's calls.limit(int | None, optional): The most calls to return; all of them when omitted.
retrieve_artifact
retrieve_artifact(artifact_id: str, *, version: int | None = None) -> StanArtifact
Get one of your STAN artifacts with its content (one a run saved, StanRun.artifacts).
Parameters
artifact_id(str): The artifact's ID.version(int | None, optional): The version to read; the current version when omitted.
retrieve_run
retrieve_run(run_id: str) -> StanRun
Get a STAN run: poll it until run_status is final, then read its response.
Parameters
run_id(str): The run's ID (from a message sent withwait=False, or a 202 answer).
retrieve_session
retrieve_session(session_id: str) -> StanSession
One of your STAN sessions, without making it your current one.
Parameters
session_id(str): The session's ID.
revert
revert(session_id: str, *, resource_ids: Sequence[str]) -> StanRevertOutcome
Delete resources a STAN session created; only those listed are deleted.
Parameters
session_id(str): The session's ID.resource_ids(Sequence[str]): The resources to delete (fromrevert_plan).
Returns
StanRevertOutcome: What wasdeleted, whatfailedand what wasskipped.
revert_plan
revert_plan(session_id: str) -> StanRevertPlan
Show what undoing a STAN session would delete; changes nothing.
These are the resources the session created, each with the tool that deletes it.
Parameters
session_id(str): The session's ID.
send_message
send_message(session_id: str, *, message: str, attachments: Sequence[str | os.PathLike[str]] | None = None, wait: bool = True) -> StanRun
Send a message to one of your STAN sessions and return the run that answers it.
The run's response holds STAN's reply once run_status is final; a run still
working (is_async) is polled with retrieve_run. A busy session queues
the message.
Parameters
session_id(str): The session's ID.message(str): What you ask STAN (required).attachments(Sequence[str | os.PathLike[str]] | None, optional): Paths of images (PNG, JPEG, GIF, WebP) and PDF documents to send with the message. Each reaches the session's model the way the model declares it can take it: an image to a model that takes images, a PDF as a document to a model that takes PDFs and as its text to one that does not. An attachment the model cannot take is refused with a400that says why.wait(bool, optional):True(the default) waits for the run to finish;Falseanswers at once with the run to poll.
submit_credentials
submit_credentials(run_id: str, *, values: Mapping[str, str]) -> StanRun
Give a paused STAN run the credentials it asked for; they never reach the model.
They are stored in the component that needs them and STAN resumes in a run,
which is returned (poll retrieve_run).
Parameters
run_id(str): The run that asked for credentials.values(Mapping[str, str]): Each requested field's value, by the field's key.