Stacklink
Reference

TypeScript SDK

Certified Vercel AI SDK, OpenAI Agents SDK, and Claude Agent SDK recipes.

Stacklink supplies executable, governed tools. Your selected agent harness owns the model call, tool loop, and final answer.

npm install @stacklink/sdk

Create a project API key in Stacklink Overview, keep it in STACKLINK_API_KEY, and use the complete recipe for your harness below. The API key is for code using the SDK; MCP app connections use OAuth instead.

Vercel AI SDK

Install the Stacklink SDK with the selected harness:

npm install @stacklink/sdk ai@^7.0.0 @ai-sdk/openai@^4.0.0

Required environment: STACKLINK_API_KEY, OPENAI_API_KEY, OPENAI_MODEL.

STACKLINK_BASE_URL is optional and defaults to https://api.stacklink.in.

agent.ts
import { openai } from '@ai-sdk/openai';
import { ToolLoopAgent } from 'ai';
import { Stacklink } from '@stacklink/sdk';
import { createStacklinkVercelTools } from '@stacklink/sdk/vercel-ai';

async function main(): Promise<void> {
  const stacklink = new Stacklink({
    apiKey: requireEnvironment('STACKLINK_API_KEY'),
    baseUrl: process.env.STACKLINK_BASE_URL ?? 'https://api.stacklink.in',
  });

  const session = await stacklink.create({
    tenantId: 'acme',
    userId: 'user_123',
    metaTools: { surface: 'connector' },
  });

  try {
    const agent = new ToolLoopAgent({
      model: openai(requireEnvironment('OPENAI_MODEL')),
      instructions: 'Use Stacklink tools to complete the request. Call STACKLINK_LIST_TOOLKITS before answering.',
      tools: createStacklinkVercelTools(session),
    });
    const result = await agent.generate({
      prompt: 'List the Stacklink toolkits available to me and summarize the result.',
    });
    console.log(result.text);
  } finally {
    await session.close();
  }
}

void main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});

function requireEnvironment(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`${name} is required.`);
  return value;
}

OpenAI Agents SDK

Install the Stacklink SDK with the selected harness:

npm install @stacklink/sdk @openai/agents@^0.13.3

Required environment: STACKLINK_API_KEY, OPENAI_API_KEY, OPENAI_MODEL.

STACKLINK_BASE_URL is optional and defaults to https://api.stacklink.in.

agent.ts
import { Agent, run } from '@openai/agents';
import { Stacklink } from '@stacklink/sdk';
import { createStacklinkOpenAIAgentsTools } from '@stacklink/sdk/openai-agents';

async function main(): Promise<void> {
  const stacklink = new Stacklink({
    apiKey: requireEnvironment('STACKLINK_API_KEY'),
    baseUrl: process.env.STACKLINK_BASE_URL ?? 'https://api.stacklink.in',
  });

  const session = await stacklink.create({
    tenantId: 'acme',
    userId: 'user_123',
    metaTools: { surface: 'connector' },
  });

  try {
    const agent = new Agent({
      name: 'Stacklink assistant',
      model: requireEnvironment('OPENAI_MODEL'),
      instructions: 'Use Stacklink tools to complete the request. Call STACKLINK_LIST_TOOLKITS before answering.',
      tools: createStacklinkOpenAIAgentsTools(session),
    });
    const result = await run(
      agent,
      'List the Stacklink toolkits available to me and summarize the result.',
    );
    console.log(result.finalOutput);
  } finally {
    await session.close();
  }
}

void main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});

function requireEnvironment(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`${name} is required.`);
  return value;
}

Claude Agent SDK

Install the Stacklink SDK with the selected harness:

npm install @stacklink/sdk @anthropic-ai/claude-agent-sdk@^0.3.214

Required environment: STACKLINK_API_KEY, ANTHROPIC_API_KEY, CLAUDE_MODEL.

STACKLINK_BASE_URL is optional and defaults to https://api.stacklink.in.

agent.ts
import { query } from '@anthropic-ai/claude-agent-sdk';
import { Stacklink } from '@stacklink/sdk';
import { createStacklinkClaudeAgentToolConfig } from '@stacklink/sdk/claude-agent';

async function main(): Promise<void> {
  const stacklink = new Stacklink({
    apiKey: requireEnvironment('STACKLINK_API_KEY'),
    baseUrl: process.env.STACKLINK_BASE_URL ?? 'https://api.stacklink.in',
  });

  const session = await stacklink.create({
    tenantId: 'acme',
    userId: 'user_123',
    metaTools: { surface: 'connector' },
  });

  try {
    const stacklinkTools = createStacklinkClaudeAgentToolConfig(session);
    let finalOutput = '';
    for await (const message of query({
      prompt: 'List the Stacklink toolkits available to me and summarize the result.',
      options: {
        model: requireEnvironment('CLAUDE_MODEL'),
        systemPrompt: 'Use Stacklink tools to complete the request. Call STACKLINK_LIST_TOOLKITS before answering.',
        tools: [],
        maxTurns: 6,
        ...stacklinkTools,
      },
    })) {
      if (message.type === 'result' && message.subtype === 'success') {
        finalOutput = message.result;
      }
    }
    console.log(finalOutput);
  } finally {
    await session.close();
  }
}

void main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});

function requireEnvironment(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`${name} is required.`);
  return value;
}

Source of truth

These examples are generated from the same executable files used by Stacklink Overview and release certification. npm and PyPI deliver the packages; this documentation remains the onboarding source of truth.

On this page