Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
/**
* Session-management Example
*
* This example demonstrates how to use Composio SDK for session-management.
*
* Prerequisites:
* 1. Set up your COMPOSIO_API_KEY in the .env file
* 3. Run the example: pnpm start
*/
import { Composio } from '@composio/core';
import 'dotenv/config';
/**
* Initialize Composio
*/
const composio = new Composio({
apiKey: process.env.COMPOSIO_API_KEY,
});
/**
* Main function to run the example
*/
async function main() {
try {
console.log('π Starting Session-management Example...');
// create a session with custom request options
const session = composio.createSession({
headers: {
'x-request-id': 'custom-value',
},
});
// use the session to make API calls
const tools = await session.tools.get('default', 'HACKERNEWS_GET_USER');
console.log(`β
Found ${tools.length} tools`);
} catch (error) {
console.error('β Error running example:', error);
process.exitCode = 1;
}
}
// Run the example
main().catch(error => {
console.error(error);
process.exitCode = 1;
});