Skip to content

AI agent stdlib that works with any LLM and TypeScript AI SDK.

License

Notifications You must be signed in to change notification settings

code/lib-agentic

 
 

Repository files navigation

Agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.

Build Status NPM MIT License Prettier Code Formatting

Agentic

Intro

Agentic is a standard library of AI functions / tools which are optimized for both normal TS-usage as well as LLM-based usage. Agentic works with all of the major TS AI SDKs (Vercel AI SDK, Mastra, LangChain, LlamaIndex, OpenAI SDK, MCP, etc).

Agentic clients like WeatherClient can be used as normal TS classes:

import { WeatherClient } from '@agentic/stdlib'

// Requires `process.env.WEATHER_API_KEY` (free from weatherapi.com)
const weather = new WeatherClient()

const result = await weather.getCurrentWeather({
  q: 'San Francisco'
})
console.log(result)

Or you can use these clients as LLM-based tools. Here's an example using Vercel's AI SDK:

// sdk-specific imports
import { openai } from '@ai-sdk/openai'
import { generateText } from 'ai'
import { createAISDKTools } from '@agentic/ai-sdk'

// sdk-agnostic imports
import { WeatherClient } from '@agentic/stdlib'

const weather = new WeatherClient()

const result = await generateText({
  model: openai('gpt-4o-mini'),
  // this is the key line which uses the `@agentic/ai-sdk` adapter
  tools: createAISDKTools(weather),
  toolChoice: 'required',
  prompt: 'What is the weather in San Francisco?'
})

console.log(result.toolResults[0])

You can use our standard library of thoroughly tested AI functions with your favorite AI SDK – without having to write any glue code!

Using Multiple Tools

All adapters (like createAISDKTools) accept a very flexible var args of AIFunctionLike parameters, so you can pass as many tools as you'd like.

They also expose a .functions property which is an AIFunctionSet. This combination makes it really easy to mix & match different tools together.

import { SerperClient, WikipediaClient, FirecrawlClient } from '@agentic/stdlib'
import { createAIFunction } from '@agentic/core'
import { z } from 'zod'

const googleSearch = new SerperClient()
const wikipedia = new WikipediaClient()
const firecrawl = new FirecrawlClient()

const result = await generateText({
  model: openai('gpt-4o-mini'),
  // This example uses tools from 4 different sources. You can pass as many
  // AIFunctionLike objects as you want.
  tools: createAISDKTools(
    googleSearch,
    wikipedia,
    // Pick a single function from the firecrawl client's set of AI functions
    firecrawl.functions.pick('firecrawl_search'),
    // Create a custom AI function (based off of Anthropic's think tool: https://www.anthropic.com/engineering/claude-think-tool)
    createAIFunction({
      name: 'think',
      description: `Use this tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.`,
      inputSchema: z.object({
        thought: z.string().describe('A thought to think about.')
      }),
      execute: ({ thought }) => thought
    })
  ),
  prompt:
    'What year did Jurassic Park the movie come out, and what else happened that year?'
})

An AIFunctionLike can be any agentic client instance, a single AIFunction selected from the client's .functions property (which holds an AIFunctionSet of available AI functions), or an AI function created manually via createAIFunction.

AIFunctionLike and AIFunctionSet are implementation details that you likely won't have to touch directly, but they're important because of their flexibility.

Features

  • ✅ All tools are thoroughly tested in production
  • ✅ Tools work across all leading TS AI SDKs
  • ✅ Tools are hand-coded and extremely minimal
  • ✅ Tools have both a good manual DX and LLM DX via the @aiFunction decorator
  • ✅ Tools use native fetch
  • ✅ Tools use ky to wrap fetch, so HTTP options, throttling, retries, etc are easy to customize
  • ✅ Supports tools from any MCP server (createMcpTools(...))
  • ✅ Generate new Agentic tool clients from OpenAPI specs (@agentic/openapi-to-ts)
  • ✅ 100% open source && not trying to sell you anything 💯

Docs

Full docs are available at agentic.so.

AI SDKs

Vercel AI SDK

Agentic adapter docs for the Vercel AI SDK

Mastra

Agentic adapter docs for the Mastra AI Agent framework

LangChain

Agentic adapter docs for LangChain

LlamaIndex

Agentic adapter docs for LlamaIndex

Firebase Genkit

Agentic adapter docs for Genkit

Dexa Dexter

Agentic adapter docs for Dexter

OpenAI

Agentic adapter docs for OpenAI

GenAIScript

Agentic support in GenAIScript

xsAI SDK

Agentic adapter docs for the xsAI SDK

Tools

Service / Tool Package Docs Description
Apollo @agentic/apollo docs B2B person and company enrichment API.
ArXiv @agentic/arxiv docs Search for research articles.
Bing @agentic/bing docs Bing web search.
Calculator @agentic/calculator docs Basic calculator for simple mathematical expressions.
Clearbit @agentic/clearbit docs Resolving and enriching people and company data.
Dexa @agentic/dexa docs Answers questions from the world's best podcasters.
Diffbot @agentic/diffbot docs Web page classification and scraping; person and company data enrichment.
DuckDuckGo @agentic/duck-duck-go docs Privacy-focused web search API.
E2B @agentic/e2b docs Hosted Python code interpreter sandbox which is really useful for data analysis, flexible code execution, and advanced reasoning on-the-fly.
Exa @agentic/exa docs Web search tailored for LLMs.
Firecrawl @agentic/firecrawl docs Website scraping and structured data extraction.
Gravatar @agentic/gravatar docs Gravatar profile API.
HackerNews @agentic/hacker-news docs Official HackerNews API.
Hunter @agentic/hunter docs Email finder, verifier, and enrichment.
Jina @agentic/jina docs URL scraper and web search.
LeadMagic @agentic/leadmagic docs B2B person, company, and email enrichment API.
Midjourney @agentic/midjourney docs Unofficial Midjourney client for generative images.
McpTools @agentic/mcp docs Model Context Protocol (MCP) client, supporting any MCP server. Use createMcpTools to spawn or connect to an MCP server.
Novu @agentic/novu docs Sending notifications (email, SMS, in-app, push, etc).
People Data Labs @agentic/people-data-labs docs People & company data (WIP).
Perigon @agentic/perigon docs Real-time news API and web content data from 140,000+ sources. Structured and enriched by AI, primed for LLMs.
Polygon @agentic/polygon docs Stock market and company financial data.
PredictLeads @agentic/predict-leads docs In-depth company data including signals like fundraising events, hiring news, product launches, technologies used, etc.
Proxycurl @agentic/proxycurl docs People and company data from LinkedIn & Crunchbase.
RocketReach @agentic/rocketreach docs B2B person and company enrichment API.
Searxng @agentic/searxng docs OSS meta search engine capable of searching across many providers like Reddit, Google, Brave, Arxiv, Genius, IMDB, Rotten Tomatoes, Wikidata, Wolfram Alpha, YouTube, GitHub, etc.
SerpAPI @agentic/serpapi docs Lightweight wrapper around SerpAPI for Google search.
Serper @agentic/serper docs Lightweight wrapper around Serper for Google search.
Slack @agentic/slack docs Send and receive Slack messages.
SocialData @agentic/social-data docs Unofficial Twitter / X client (readonly) which is much cheaper than the official Twitter API.
Tavily @agentic/tavily docs Web search API tailored for LLMs.
Twilio @agentic/twilio docs Twilio conversation API to send and receive SMS messages.
Twitter @agentic/twitter docs Basic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting. Uses Nango for OAuth support.
Weather @agentic/weather docs Basic access to current weather data based on location.
Wikidata @agentic/wikidata docs Basic Wikidata client.
Wikipedia @agentic/wikipedia docs Wikipedia page search and summaries.
Wolfram Alpha @agentic/wolfram-alpha docs Wolfram Alpha LLM API client for answering computational, mathematical, and scientific questions.
ZoomInfo @agentic/zoominfo docs Powerful B2B person and company data enrichment.

Note

Missing a tool or want to add your own tool to this list? If you have an OpenAPI v3 spec for your tool's API, we make it extremely easy to add support using our @agentic/openapi-to-ts CLI. Otherwise, feel free to open an issue to discuss or submit a PR.

For more details on tool usage, see the docs.

Contributors

License

MIT © Travis Fischer

To stay up to date or learn more, follow @transitive_bs on Twitter.

About

AI agent stdlib that works with any LLM and TypeScript AI SDK.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%