Anthropic::BetaSessions
Sessions API resource (beta)
Constructors
new(client : Client)
SourceInstance methods
archive(session_id : String, betas : Array(String) = [] of String, workspace_id : String | Nil = nil) : BetaManagedAgentsSession
Archive a session
create(environment_id : String, agent : BetaManagedAgentsAgentParamLike, title : String | Nil = nil, metadata : Hash(String, String) | Nil = nil, resources : Enumerable(BetaManagedAgentsSessionResourceParam) | Nil = nil, vault_ids : Array(String) | Nil = nil, initial_events : Array(JSON::Any | Hash(String, JSON::Any)) | Nil = nil, budget : BetaManagedAgentsBudgetLimit | Nil = nil, workspace_id : String | Nil = nil, betas : Array(String) = [] of String) : BetaManagedAgentsSession
Create a session.
initial_events sends events to the session at creation (processed in
order). Supports user.message and user.define_outcome events.
Maximum 50 events per the API.
client.beta.sessions.create(
environment_id: env.id,
agent: agent.id,
initial_events: [
JSON.parse(%({"type":"user.message","content":[{"type":"text","text":"Hello"}]})),
],
)
delete(session_id : String, betas : Array(String) = [] of String, workspace_id : String | Nil = nil) : BetaManagedAgentsDeletedSession
Delete a session
events
Sourcelist(include_archived : Bool | Nil = nil, limit : Int32 = 20, page : String | Nil = nil, betas : Array(String) = [] of String, workspace_id : String | Nil = nil) : BetaSessionListResponse
List sessions
resources
Sourceretrieve(session_id : String, workspace_id : String | Nil = nil, betas : Array(String) = [] of String) : BetaManagedAgentsSession
Retrieve a session
threads
Sourceupdate(session_id : String, agent : BetaManagedAgentsAgentParamLike | Nil = nil, title : String | Nil = nil, metadata : Hash(String, String) | Hash(String, String | Nil) | Nil = nil, budget : BetaManagedAgentsBudgetLimit | Nil = nil, vault_ids : Array(String) | Nil = nil, workspace_id : String | Nil = nil, betas : Array(String) = [] of String) : BetaManagedAgentsSession
Update a session
metadata is a patch: set a key to a string to upsert it, or to
nil to delete it. Omit it to leave metadata untouched.