Inference Logoinference.sh

Template Agents

Use existing agents from your workspace.


Basic Usage

1from inferencesh import inference2 3client = inference(api_key="inf_your_key")4 5# Reference by namespace/name@version6agent = client.agent("my-team/support-agent@latest")7 8# Send a message9response = agent.send_message("Hello!")10print(response.text)

Agent Reference Formats

code
1# Latest version2namespace/agent-name@latest3 4# Specific version5namespace/agent-name@abc123

Multi-turn Conversations

State is maintained automatically:

1agent = client.agent("my-team/support-agent@latest")2 3response1 = agent.send_message("What's my account status?")4print(response1.text)5 6response2 = agent.send_message("Can you explain that more?")7print(response2.text)  # Has context from previous message

Reset Conversation

Start a new conversation:

1agent.reset()2 3response = agent.send_message("Start fresh!")

Get Chat History

1chat = agent.get_chat()2 3for 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)

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.