Native SDK
Use the framework selector to see the matching packages and runtime provider code.
Use swy as a shorter alias for swytchcode in any of the commands below.
Choose your framework
-
Install the CLI and SDK
Terminal window npm install -g swytchcodeTerminal window irm https://cli.swytchcode.com/install.ps1 | iexTerminal window curl -fsSL https://cli.swytchcode.com/install.sh | shTerminal window npm install @swytchcode/runtime @anthropic-ai/sdkTerminal window pip install swytchcode-runtime anthropic python-dotenv -
Initialize Swytchcode, fetch a toolkit, and enable a tool
swy initcreates the project’stooling.json,swy getdownloads the GitHub integration bundle, andswy add methodresolves one of its methods intotooling.json.toolsso it can actually be called. The example below stars a repo, so it also connects a GitHub account.Terminal window swy initswy get githubswy add method github.user.starred.updateswy auth connect github -
Initialize the provider
import "dotenv/config";import Anthropic from "@anthropic-ai/sdk";import { Swytchcode, TOOL_USE_INSTRUCTIONS } from "@swytchcode/runtime";import { AnthropicProvider } from "@swytchcode/runtime/providers/anthropic";async function runAgent() {const anthropic = new Anthropic();// 1. Initialize Swytchcode with the Anthropic providerconst swx = new Swytchcode(new AnthropicProvider());// 2. Fetch the tools you want your agent to use (e.g., GitHub tools)const tools = await swx.tools.get({ toolkits: ["github"] });// 3. Build the system prompt: your own instructions plus TOOL_USE_INSTRUCTIONS,// which tells Claude to call the tool directly for action requests instead of// just describing what it would doconst system = `You are a helpful assistant.\n\n${TOOL_USE_INSTRUCTIONS}`;const messages: Anthropic.MessageParam[] = [{ role: "user", content: "Star the swytchcodehq/swytchcode-examples repo on GitHub for me." },];// 4. Loop until Claude stops requesting tool calls: run any tool calls// Claude made and send the results back so it can keep working toward// a final natural-language reply instead of stopping after one roundconst MAX_TURNS = 10;let response: Anthropic.Message;for (let turn = 0; ; turn++) {if (turn >= MAX_TURNS) {throw new Error(`Exceeded ${MAX_TURNS} tool-use turns without a final reply`);}response = await anthropic.messages.create({model: "claude-sonnet-5",max_tokens: 1024,system,tools: tools,messages,});messages.push({ role: "assistant", content: response.content });if (response.stop_reason === "max_tokens") {throw new Error("Response truncated at max_tokens - increase the limit and retry");}if (response.stop_reason !== "tool_use") break;const toolResults = await swx.handleToolCalls(response);messages.push({ role: "user", content: toolResults as Anthropic.ToolResultBlockParam[] });}for (const block of response.content) {if (block.type === "text") console.log(block.text);}}runAgent();import osfrom dotenv import load_dotenvimport anthropicfrom swytchcode_runtime import Swytchcode, TOOL_USE_INSTRUCTIONSfrom swytchcode_runtime.providers.anthropic import AnthropicProviderload_dotenv() # Loads .env automaticallydef run_agent():client = anthropic.Anthropic()# 1. Initialize Swytchcode with the Anthropic providerswx = Swytchcode(provider=AnthropicProvider())# 2. Fetch the tools you want your agent to use (e.g., GitHub tools)tools = swx.tools.get(toolkits=["github"])# 3. Build the system prompt: your own instructions plus TOOL_USE_INSTRUCTIONS,# which tells Claude to call the tool directly for action requests instead of# just describing what it would dosystem = f"You are a helpful assistant.\n\n{TOOL_USE_INSTRUCTIONS}"messages = [{"role": "user", "content": "Star the swytchcodehq/swytchcode-examples repo on GitHub for me."}]# 4. Loop until Claude stops requesting tool calls: run any tool calls# Claude made and send the results back so it can keep working toward# a final natural-language reply instead of stopping after one roundwhile True:response = client.messages.create(model="claude-sonnet-5",max_tokens=1024,system=system,tools=tools,messages=messages,)messages.append({"role": "assistant", "content": response.content})if response.stop_reason == "max_tokens":raise RuntimeError("Response truncated at max_tokens - increase the limit and retry")if response.stop_reason != "tool_use":breaktool_results = swx.handle_tool_calls(response)messages.append({"role": "user", "content": tool_results})for block in response.content:if block.type == "text":print(block.text)if __name__ == "__main__":run_agent() -
Handle the tool loop
Pass the tool result back to Claude. For a manual loop in Python, use
swx.handle_tool_calls(response)to execute tool calls and createtool_resultblocks. -
Run the file
Save the example as
main.jsormain.py, then run:Terminal window node main.jsTerminal window python main.py
-
Install the CLI and SDK
Terminal window npm install -g swytchcodeTerminal window irm https://cli.swytchcode.com/install.ps1 | iexTerminal window curl -fsSL https://cli.swytchcode.com/install.sh | shTerminal window npm install @swytchcode/runtime @openai/agentsTerminal window pip install swytchcode-runtime openai-agents python-dotenv -
Initialize Swytchcode and fetch a toolkit
swy initcreates the project’stooling.json;swy get githubdownloads the GitHub integration bundle thattools.getreads from below.Terminal window swy initswy get github -
Initialize the provider
import { Swytchcode } from '@swytchcode/runtime';import { OpenAIAgentsProvider } from '@swytchcode/runtime/providers/openai-agents';const swx = new Swytchcode(new OpenAIAgentsProvider());const tools = await swx.tools.get({ toolkits: ['github'] });from swytchcode_runtime import Swytchcodefrom swytchcode_runtime.providers.openai_agents import OpenAIAgentsProviderswx = Swytchcode(provider=OpenAIAgentsProvider())tools = swx.tools.get(toolkits=['github']) -
Pass
toolsto your agentThe returned tools use the native OpenAI Agents format. Pass them into your agent and let Swytchcode handle execution, authentication, and policy checks.
-
Run the file
Save the example as
main.jsormain.py, then run the matching command:Terminal window node main.jsTerminal window python main.py
-
Install the CLI and SDK
Terminal window npm install -g swytchcodeTerminal window irm https://cli.swytchcode.com/install.ps1 | iexTerminal window curl -fsSL https://cli.swytchcode.com/install.sh | shTerminal window npm install @swytchcode/runtime ai @ai-sdk/openai -
Initialize Swytchcode and fetch a toolkit
swy initcreates the project’stooling.json;swy get githubdownloads the GitHub integration bundle thattools.getreads from below.Terminal window swy initswy get github -
Initialize the provider and run the model
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'] });const result = await generateText({model: openai('gpt-4.1'),tools,prompt: 'Summarize my open pull requests from GitHub.',});console.log(result.text); -
Run the file
Save the example as
main.js, then run:Terminal window node main.js
Choose a framework-specific guide to see its provider and tool setup:
Where to go next
Browse all examples →Gmail Assistant
Searches, reads, drafts, and sends Gmail messages through an Anthropic tool-use loop powered by Swytchcode.
Star Repo Agent
Minimal OpenAI Agents SDK example that stars a GitHub repo through Swytchcode-brokered OAuth.
OpenAI SDK
Integrate Swytchcode tools with the OpenAI Agents SDK to build reliable agents.
Anthropic SDK
Connect Claude-based agents to trusted tools using the Anthropic integration.
LangGraph
Build stateful, multi-step workflows and execute tools through Swytchcode.
CrewAI
Enable CrewAI agents to discover and execute trusted tools.
Runtime SDKs
Learn how the JavaScript and Python Runtime SDKs power tool execution across frameworks.