[go: up one dir, main page]

Guide
Use GitHub tools in your first AI SDK call in under five minutes.

Install everything at once

If you haven't completed Installation yet:

pnpm add @github-tools/sdk ai zod

Use tools directly

The simplest integration: pass all tools to generateText and let the model pick the right GitHub operations:

list-prs.ts
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4.6',
  tools: createGithubTools(),
  prompt: 'List open pull requests on vercel/ai and summarize each one.',
})

console.log(text)

The SDK reads GITHUB_TOKEN from your environment automatically. This gives the model access to all 42 tools — see the Tools Catalog for what each one does.

Narrow tools with a preset

When you want to limit which GitHub operations are available, use a preset. This gives the model only pull request and commit tools:

review-only.ts
import { createGithubTools } from '@github-tools/sdk'
import { streamText } from 'ai'

const result = streamText({
  model: 'anthropic/claude-sonnet-4.6',
  tools: createGithubTools({ preset: 'code-review' }),
  prompt: 'Review the latest PR on vercel-labs/github-tools for security issues.',
})

for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}

Learn how each preset maps to tools in Scope with Presets.

Wrap tools in a reusable agent

When you need the same configuration across multiple calls, use createGithubAgent to get a persistent agent:

triage-agent.ts
import { createGithubAgent } from '@github-tools/sdk'

const triager = createGithubAgent({
  model: 'anthropic/claude-sonnet-4.6',
  preset: 'issue-triage',
  system: 'You classify issues as bug, feature, or question. Always post a comment with the classification.',
})
Start with createGithubTools() to learn the tools. Add a preset when you want focus. Move to createGithubAgent() when you need reusable behavior.

Durable workflows (optional)

If you deploy on Vercel (or use the Workflow SDK elsewhere) and need durable execution — retries, resume after failure, observable steps — use createDurableGithubAgent from @github-tools/sdk/workflow inside a function marked with "use workflow". GitHub tools already run as individual "use step" calls.

See the dedicated guide: Durable workflows (Vercel Workflow).

AI assistant prompts

First call (align with this page):

Prompt
Add a minimal example using @github-tools/sdk with the Vercel AI SDK: createGithubTools() with generateText or streamText, model of my choice, and GITHUB_TOKEN from env. Link https://github-tools.com/guide/quick-start and https://github-tools.com/api/tools-catalog.

New Next.js or Nuxt server route / handler:

Prompt
Create a minimal AI route or server handler that uses @github-tools/sdk: createGithubTools with an appropriate preset, read GITHUB_TOKEN from env, use generateText or streamText with full TypeScript, short env comment. Point to https://github-tools.com/guide/presets and https://github-tools.com/api/tools-catalog.

External references

Copyright © 2026