Use existing agents from your workspace.
Basic Usage
typescript
1import { inference } from '@inferencesh/sdk';23const client = inference({ apiKey: 'inf_your_key' });45const agent = client.agent('my-team/support-agent@latest');67const response = await agent.sendMessage('Hello!');8console.log(response.text);Agent Reference Formats
typescript
1// Latest version2const agent = client.agent('namespace/agent-name@latest');34// Specific version5const agent = client.agent('namespace/agent-name@abc123');Multi-turn Conversations
State is maintained automatically:
typescript
1const agent = client.agent('my-team/support-agent@latest');23const r1 = await agent.sendMessage("What's my account status?");4console.log(r1.text);56const r2 = await agent.sendMessage('Can you explain that more?');7console.log(r2.text); // Has context from previous messageReset Conversation
typescript
1agent.reset();23const response = await agent.sendMessage('Start fresh!');Get Chat History
typescript
1const chat = await agent.getChat();23for (const message of chat.messages) {4 console.log(`${message.role}: ${message.content}`);5}Stop Active Response
typescript
1// Start streaming2for await (const chunk of agent.sendMessage('Tell me a story', { stream: true })) {3 if (shouldStop) {4 await agent.stopChat();5 break;6 }7 console.log(chunk.text);8}