Use existing agents from your workspace.
Basic Usage
1from inferencesh import inference23client = inference(api_key="inf_your_key")45# Reference by namespace/name@version6agent = client.agent("my-team/support-agent@latest")78# Send a message9response = agent.send_message("Hello!")10print(response.text)Agent Reference Formats
code
1# Latest version2namespace/agent-name@latest34# Specific version5namespace/agent-name@abc123File attachments
Send images, documents, or other files with a message. The SDK uploads them and attaches FileRef URIs to the user message.
1# Paths, bytes, or data URIs — uploaded automatically2response = agent.send_message(3 "What's in this image?",4 files=[open("photo.png", "rb").read()],5)67# upload_file returns a FileRef (uri, filename, content_type) for logging or custom flows8ref = agent.upload_file(open("doc.pdf", "rb").read(), filename="doc.pdf")9response = agent.send_message("Summarize this PDF", files=[open("doc.pdf", "rb").read()])→ Files API · Python SDK file attachments · JavaScript SDK file attachments
Multi-turn Conversations
State is maintained automatically:
1agent = client.agent("my-team/support-agent@latest")23response1 = agent.send_message("What's my account status?")4print(response1.text)56response2 = agent.send_message("Can you explain that more?")7print(response2.text) # Has context from previous messageReset Conversation
Start a new conversation:
1agent.reset()23response = agent.send_message("Start fresh!")Get Chat History
1chat = agent.get_chat()23for message in chat["messages"]:4 print(f"{message['role']}: {message['content']}")Stop Active Response
1# Start streaming2for chunk in agent.send_message("Tell me a story", stream=True):3 if should_stop:4 agent.stop()5 break6 print(chunk.text)