Manage conversational sessions with the Node.js SDK
Sessions in Julep enable persistent, stateful interactions between users and agents. They maintain context across multiple exchanges and can be used to build conversational interfaces.
// Send a message and get a responseconst response = await client.sessions.chat(sessionId, { messages: [ { role: 'user', content: 'Hello! Can you help me with my order?' } ]});// Continue the conversation in the same sessionconst followUp = await client.sessions.chat(sessionId, { messages: [ { role: 'user', content: 'I need to change my shipping address.' } ]});
// Add a session-specific toolawait client.sessions.tools.create(sessionId, { name: 'check_order_status', description: 'Check the status of an order', type: 'function', function: { parameters: { type: 'object', properties: { order_id: { type: 'string', description: 'The order ID to check' } }, required: ['order_id'] } }});