Use GitHub tools with the AI SDK
The AI SDK is the core integration path: createGithubTools() returns a standard AI SDK ToolSet, so GitHub tools work anywhere AI SDK tools do: generateText, streamText, agent loops, and any framework built on top of them.
Wire GitHub tools into this AI SDK app
One-shot: generateText
Pass the tools and let the model decide which GitHub operations to call:
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'
const { text } = await generateText({
model: 'anthropic/claude-sonnet-4.6',
tools: createGithubTools({ preset: 'code-review' }),
prompt: 'Summarize the latest merged PR on vercel/ai.',
})
Best for scripts, CLI tools, batch jobs, and webhooks.
Streaming: streamText
Same tools, streamed output, for chat UIs and interactive terminals:
import { createGithubTools } from '@github-tools/sdk'
import { streamText } from 'ai'
const result = streamText({
model: 'anthropic/claude-sonnet-4.6',
tools: createGithubTools({ preset: 'repo-explorer' }),
prompt: 'Explain the architecture of vercel-labs/github-tools.',
})
for await (const chunk of result.textStream) {
process.stdout.write(chunk)
}
Reusable agent: createGithubAgent
createGithubAgent returns a ToolLoopAgent with tools, preset-aware system instructions, and approval policy wired together. Define it once, call .generate() or .stream() everywhere:
import { createGithubAgent } from '@github-tools/sdk'
const reviewer = createGithubAgent({
model: 'anthropic/claude-sonnet-4.6',
preset: 'code-review',
requireApproval: false,
additionalInstructions: 'Always cite file paths and line numbers.',
})
const { text } = await reviewer.generate({
prompt: 'Review PR #42 on vercel-labs/github-tools.',
})
Each preset ships a tailored system prompt. additionalInstructions appends to it, instructions replaces it entirely.
Human approval in the loop
Write tools carry needsApproval by default. When the model calls one, the AI SDK emits an approval request instead of executing. Your app approves or denies, then execution continues:
const tools = createGithubTools({
preset: 'maintainer',
requireApproval: {
mergePullRequest: true,
addIssueComment: false,
},
})
Full policy options (including overrides.needsApproval): Control write safety.
Trim tool context with toolpick
With all 79 tools visible on every step, tool definitions eat tokens. toolpick selects only the most relevant tools per step:
import { createGithubTools } from '@github-tools/sdk'
import { createToolIndex } from 'toolpick'
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'
const tools = createGithubTools()
const index = createToolIndex(tools, {
embeddingModel: openai.embeddingModel('text-embedding-3-small'),
})
const result = await generateText({
model: openai('gpt-4o'),
tools,
prepareStep: index.prepareStep(),
prompt: 'Check if the CI is passing on the main branch of vercel/ai.',
})
Cherry-pick individual tools
Every tool is also exported as a standalone factory, compose your own minimal tool set:
import { listPullRequests, getPullRequest, listPullRequestFiles } from '@github-tools/sdk'
const tools = {
listPullRequests: listPullRequests(token),
getPullRequest: getPullRequest(token),
listPullRequestFiles: listPullRequestFiles(token),
}
See the Tools Catalog for all 79 factories.
When to level up
| Need | Go to |
|---|---|
A standalone agent in 3 files, richer approval (once, predicates) | eve extension |
| Crash-safe execution, retries, resumable streams | Vercel Workflow |
| A GitHub/Slack/Discord bot | Chat SDK |
External references
eve extension
Mount @github-tools/eve-extension under agent/extensions/ to add all 79 GitHub tools to an eve agent, the recommended way to wire GitHub into eve, with durable approval and Vercel Connect support.
Vercel Workflow
Run GitHub tools as durable, retryable steps with createDurableGithubAgent, crash-safe agents for Nuxt and Next.js apps on Vercel.