Frameworks

Framework integration for the Agentuity JavaScript SDK

The Agentuity JavaScript SDK provides a flexible and powerful way to integrate other frameworks with your Agent.

The following frameworks are currently supported:

Using Frameworks with Agentuity

To use a framework with Agentuity, choose the framework template when creating a new project.

$
agentuity create

When you select one of the framework templates, the Agentuity CLI will install the necessary dependencies and create a new project with the framework already configured.

Vercel AI SDK

Example Agent using Vercel AI SDK:

import type { AgentContext, AgentRequest, AgentResponse } from '@agentuity/sdk';
import { anthropic } from '@ai-sdk/anthropic';
import { generateObject } from 'ai';
import { z } from 'zod';
 
export default async function Agent(
  req: AgentRequest,
  resp: AgentResponse,
  ctx: AgentContext
) {
  const prompt =
    (await req.data.text()) ?? 'Recommend dinner spots in Austin, TX';
 
  // Get user intent
  const userIntent = await generateObject({
    model: anthropic('claude-3-7-sonnet-latest'),
    system: `
			You serve as a central hub that routes user requests to the right
			AI agent based on the user's intent. Classify the user's intent
			and select the best agent to handle it.
		`,
    schema: z.object({
      agentType: z.enum(['LocalGuide']),
    }),
    prompt,
  });
 
  // Route to appropriate agent based on intent
  if (userIntent.object?.agentType === 'LocalGuide') {
    return await resp.handoff(
      { name: 'LocalGuide' },
      {
        data: prompt,
        contentType: 'text/plain',
      }
    );
  }
 
  return resp.text("Sorry, I don't know how to help with that.");
}

Mastra

Example Agent using Mastra:

import type { AgentContext, AgentRequest, AgentResponse } from '@agentuity/sdk';
import { anthropic } from '@ai-sdk/anthropic';
import { Agent } from '@mastra/core/agent';
 
export default async function AgentuityAgent(
  req: AgentRequest,
  resp: AgentResponse,
  ctx: AgentContext
) {
  const prompt =
    (await req.data.text()) ?? 'Recommend dinner spots in Austin, TX';
 
  // Get user intent
  const agent = new Agent({
    name: 'Concierge',
    model: anthropic('claude-3-7-sonnet-latest'),
    instructions: `
			You serve as a central hub that routes user requests to the right
			AI agent based on the user's intent. Classify the user's intent and
			select the best agent (for now, just "LocalGuide") to handle it.
			Respond ONLY with the agent name.
		`,
  });
 
  const result = await agent.generate(prompt, { maxSteps: 5 });
  const userIntent = result.text?.trim();
 
  // Route to appropriate agent based on intent
  if (userIntent === 'LocalGuide') {
    return await resp.handoff(
      { name: 'LocalGuide' },
      {
        data: prompt,
        contentType: 'text/plain',
      }
    );
  }
 
  return resp.text("Sorry, I don't know how to help with that.");
}

LangChain

Example Agent using LangChain:

import type { AgentContext, AgentRequest, AgentResponse } from '@agentuity/sdk';
import { anthropic } from '@ai-sdk/anthropic';
import { Agent } from '@mastra/core/agent';
 
export default async function AgentuityAgent(
  req: AgentRequest,
  resp: AgentResponse,
  ctx: AgentContext
) {
  const prompt =
    (await req.data.text()) ?? 'Recommend dinner spots in Austin, TX';
 
  // Get user intent
  const agent = new Agent({
    name: 'Concierge',
    model: anthropic('claude-3-7-sonnet-latest'),
    instructions: `
			You serve as a central hub that routes user requests to the right
			AI agent based on the user's intent. Classify the user's intent and
			select the best agent (for now, just "LocalGuide") to handle it.
			Respond ONLY with the agent name.
		`,
  });
 
  const result = await agent.generate(prompt, { maxSteps: 5 });
  const userIntent = result.text?.trim();
 
  // Route to appropriate agent based on intent
  if (userIntent === 'LocalGuide') {
    return await resp.handoff(
      { name: 'LocalGuide' },
      {
        data: prompt,
        contentType: 'text/plain',
      }
    );
  }
 
  return resp.text("Sorry, I don't know how to help with that.");
}

Need Help?

Join our DiscordCommunity for assistance or just to hang with other humans building agents.

Send us an email at hi@agentuity.com if you'd like to get in touch.

Please Follow us on

If you haven't already, please Signup for your free account now and start building your first agent!

On this page