Quickstart
Before you begin
- Make sure your organization has at least one agent that you can run. If it has none, create one in the app or with Create an agent.
- Install the tools for the language you use:
curlandjq, theanthropicPython package, or the@anthropic-ai/sdkNode package.
env_default. For every other difference, see
Coming from Anthropic’s API.-
Create a key and set your host
Create a personal task API key with the default capabilities, and copy it. If you aren’t an organization administrator, first clear the two capabilities that only an administrator can grant, as step 4 of Create a key says. If an automation calls your agents instead of you, see Choose a key. In every shell you use, export
CONTEXT_BASE_URLandCONTEXT_API_KEYas shown in the cURL tab. The Python and TypeScript clients read both from the environment. SetCONTEXT_BASE_URLto the host without/v1, because the SDKs add/v1themselves. -
Pick an agent
List the agents your key can run. In the last line, replace the example ID with the ID of the agent you want.
-
Upload a file
Make a small CSV and upload it.
-
Create a session with the file
Create a session that runs the agent with the file attached, in the
env_defaultenvironment. The response lists the file underresourceswith themount_pathwhere the session finds it. -
Open the stream, then send a message
Open the stream, then send a message. With cURL, run the stream in one terminal and send the message from a second terminal that has the same variables set. The loop stops at the first
session.status_idleevent whosestop_reason.typeisn’trequires_action. If the agent asks to run a tool that needs your approval, follow the tool approvals playbook.The agent replies with something like
Tokyo is the largest city, with 37,400,000 people.With cURL, terminal 1 prints one frame per event. The reply arrives as anagent.messageframe, and asession.status_idleframe marks the end of the reply. Each frame hasid,eventanddatalines, as shown in Stream events. -
Archive the session and delete the file
Archive the session, then delete the file. Archive first, because a file that a session still uses can’t be deleted.
What happened in this quickstart
- The session is a task in the Context app. Its transcript is there, under the title you gave it.
- The upload went to your Drive in the app. The session reads it from its
inputs/folder. - The stream was live from the moment it opened and carried nothing from before. List events returns the whole history.
- Archiving ended the session and kept its history readable. To remove a session for good, use Delete a session with a key that has
sessions:delete.
Next steps
- Sessions explains what each session status means and how to rename and archive a session.
- Stream events shows which frames the stream sends, how it ends and how to reconnect without losing events.
- The tool approvals playbook shows how to approve or deny a tool call when a session goes idle with
requires_action.