Skip to content

1. Install the CLI

Terminal window
npm install -g swytchcode

Use swy as a shorter alias for swytchcode.

2. Install the packages

Terminal window
npm install @swytchcode/runtime ai @ai-sdk/openai dotenv

3. Initialize Swytchcode and fetch a toolkit

Terminal window
swy init
swy get github

swy init creates .swytchcode/ and tooling.json for the project. swy get github downloads the GitHub integration bundle - the schemas that tools.get reads from in a later step.

4. List available methods

Terminal window
swy list methods

This lists every method from the integrations you’ve downloaded, so you can see what the GitHub bundle exposes before you load tools in the SDK.

5. Enable a tool and connect GitHub

Terminal window
swy add <canonical_id>
swy auth connect github

Copy a canonical ID from swy list methods. For example:

Terminal window
swy add github.issues.create

swy add writes that method into tooling.json so the SDK can execute it. swy auth connect github opens a browser so you can authorize GitHub.

6. Create the tool set

import 'dotenv/config';
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { Swytchcode } from '@swytchcode/runtime';
import { VercelProvider } from '@swytchcode/runtime/providers/vercel';
const swx = new Swytchcode(new VercelProvider());
const tools = await swx.tools.get({ toolkits: ['github'] });

7. Run the prompt

const result = await generateText({
model: openai('gpt-4.1'),
tools,
prompt: 'Summarize my open pull requests from GitHub.',
});
console.log(result.text);

8. Run the file

Save the example as main.js, then run:

Terminal window
node main.js

Swytchcode provides the tool execution layer while the SDK handles the model loop.