Quickstart
Make your first AgentKit tool call in Python, Node.js or cURL: install the SDK, add your credentials, and call GitHub as yourself.
Connect your own GitHub account and make your first tool call as that user. New Scalekit environments include a GitHub connection, so there’s nothing to set up in GitHub. About 10 minutes.
Using a coding agent?
Before you start
Section titled “Before you start”- A Scalekit account at app.scalekit.com
- Python 3.10+, Node.js 18.14+, or
curlandjq - Your environment URL, client ID and client secret. Open Developers > Settings > API Credentials: copy the Environment URL and Client ID from Environment details, then select Generate new secret under Client secrets. The secret is shown once, so copy it right away. See API credentials.
- The GitHub connection name from AgentKit > Connections. New environments call it
github-connect.
-
Install the SDK
Section titled “Install the SDK”Terminal window pip install scalekit-sdk-python python-dotenvTerminal window npm init -ynpm pkg set type=modulenpm install @scalekit-sdk/node dotenvnpm install -D tsx -
Add your credentials
Section titled “Add your credentials”Create a
.envfile next to your script. Don’t commit it..env SCALEKIT_ENVIRONMENT_URL=<your-environment-url>SCALEKIT_CLIENT_ID=<client-id>SCALEKIT_CLIENT_SECRET=<client-secret>GITHUB_CONNECTION_NAME=github-connect -
Write the script
Section titled “Write the script”Save this as
agent.py,agent.tsoragent.sh. It connects the user if needed, then calls GitHub as them.agent.py import osfrom dotenv import load_dotenvfrom scalekit import ScalekitClientload_dotenv()scalekit_client = ScalekitClient(env_url=os.environ["SCALEKIT_ENVIRONMENT_URL"],client_id=os.environ["SCALEKIT_CLIENT_ID"],client_secret=os.environ["SCALEKIT_CLIENT_SECRET"],)actions = scalekit_client.actionsconnection_name = os.environ["GITHUB_CONNECTION_NAME"]user_id = "user_123" # your app's ID for this user: stable and hard to guess# Find this user's connected account, or create it on the first runaccount = actions.get_or_create_connected_account(connection_name=connection_name,identifier=user_id,).connected_accountif account.status != "ACTIVE":link = actions.get_authorization_link(connection_name=connection_name,identifier=user_id,).linkprint(f"Open this link and approve access:\n{link}")input("Press Enter when you're done...")account = actions.get_connected_account(connection_name=connection_name,identifier=user_id,).connected_accountif account.status != "ACTIVE":raise SystemExit(f"The account is {account.status}, not ACTIVE. Run the script again.")# Call GitHub as this user. The tool is read-only.result = actions.execute_tool(tool_name="github_user_get_authenticated",tool_input={},connected_account_id=account.id,)print(result.data)agent.ts import 'dotenv/config';import { createInterface } from 'node:readline/promises';import { ConnectorStatus, ScalekitClient } from '@scalekit-sdk/node';const scalekit = new ScalekitClient(process.env.SCALEKIT_ENVIRONMENT_URL!,process.env.SCALEKIT_CLIENT_ID!,process.env.SCALEKIT_CLIENT_SECRET!,);const actions = scalekit.actions;const connectionName = process.env.GITHUB_CONNECTION_NAME!;const userId = 'user_123'; // your app's ID for this user: stable and hard to guess// Find this user's connected account, or create it on the first runlet { connectedAccount: account } = await actions.getOrCreateConnectedAccount({connectionName,identifier: userId,});if (account?.status !== ConnectorStatus.ACTIVE) {const { link } = await actions.getAuthorizationLink({ connectionName, identifier: userId });console.log(`Open this link and approve access:\n${link}`);const rl = createInterface({ input: process.stdin, output: process.stdout });await rl.question("Press Enter when you're done...");rl.close();({ connectedAccount: account } = await actions.getConnectedAccount({connectionName,identifier: userId,}));if (account?.status !== ConnectorStatus.ACTIVE) {throw new Error('The account is not ACTIVE yet. Run the script again.');}}// Call GitHub as this user. The tool is read-only.const result = await actions.executeTool({toolName: 'github_user_get_authenticated',toolInput: {},connectedAccountId: account.id,});console.log(result.data);agent.sh #!/usr/bin/env bashset -euo pipefailset -a; source .env; set +aUSER_ID="user_123" # your app's ID for this user: stable and hard to guessAPI="$SCALEKIT_ENVIRONMENT_URL/api/v1"# Exchange your API credentials for an access tokenTOKEN=$(curl -sS "$SCALEKIT_ENVIRONMENT_URL/oauth/token" \-d grant_type=client_credentials \-d client_id="$SCALEKIT_CLIENT_ID" \-d client_secret="$SCALEKIT_CLIENT_SECRET" | jq -r .access_token)account_status() {curl -sS -G "$API/connected_accounts/details" \-H "Authorization: Bearer $TOKEN" \--data-urlencode "connector=$GITHUB_CONNECTION_NAME" \--data-urlencode "identifier=$USER_ID" |jq -r '.connected_account.status // "NOT_CREATED"'}if [ "$(account_status)" != "ACTIVE" ]; then# Creates the connected account on the first run, and returns a linkLINK=$(curl -sS "$API/connected_accounts/magic_link" \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d "{\"connector\": \"$GITHUB_CONNECTION_NAME\", \"identifier\": \"$USER_ID\"}" |jq -r .link)printf 'Open this link and approve access:\n%s\n' "$LINK"read -r -p "Press Enter when you're done..."STATUS=$(account_status)if [ "$STATUS" != "ACTIVE" ]; thenecho "The account is $STATUS, not ACTIVE. Run the script again." >&2exit 1fifi# Call GitHub as this user. The tool is read-only.curl -sS "$API/execute_tool" \-H "Authorization: Bearer $TOKEN" \-H "Content-Type: application/json" \-d "{\"tool_name\": \"github_user_get_authenticated\", \"connector\": \"$GITHUB_CONNECTION_NAME\", \"identifier\": \"$USER_ID\", \"params\": {}}" |jq .datauser_123stands in for your app’s user ID. Choose an identifier explains what to use in production. -
Run it
Section titled “Run it”Terminal window python agent.pyTerminal window npx tsx agent.tsTerminal window bash agent.shThe first run prints a link. Open it, approve access on GitHub, then press Enter. You’ll see your GitHub profile. Run it again: the account is already
ACTIVE, so the script skips the link.
If it doesn’t work
Section titled “If it doesn’t work”connection not found for the given key
Section titled “connection not found for the given key”GITHUB_CONNECTION_NAME doesn’t match the dashboard exactly. Copy it again from AgentKit > Connections.
The account stays PENDING_AUTH
Section titled “The account stays PENDING_AUTH”The approval wasn’t finished, or the link expired. Links last five minutes by default. Run the script again for a fresh link.
user_verify_url is required when user_verify_mode is b2b
Section titled “user_verify_url is required when user_verify_mode is b2b”User verification is set to Custom user verifier, so the link request needs a verify URL. For this quickstart, use None or Scalekit users only in AgentKit > Settings > User Verification. To set up the custom user verifier, see Verify users.
KeyError: 'SCALEKIT_ENVIRONMENT_URL' or TypeError: Invalid URL
Section titled “KeyError: 'SCALEKIT_ENVIRONMENT_URL' or TypeError: Invalid URL”The .env file wasn’t loaded. Run the script from the folder that contains it.
401 or invalid_client
Section titled “401 or invalid_client”The client ID or secret is wrong, or the secret was regenerated.
Before real users connect accounts, verify users.
API reference
The endpoints this page's code calls, with every field and the SDK method for each: