Skip to main content

Installation

Get up and running with The Prompting Company TypeScript SDK in your Next.js or Node.js project.

Prerequisites

Before installing the SDK, ensure you have:
  • Node.js version 18.0 or higher
  • npm, yarn, or pnpm package manager
  • A Next.js project (recommended) or Node.js application

Install the SDK

Choose your preferred package manager:
  • npm
  • yarn
  • pnpm
npm install @promptingcompany/sdk

Environment Setup

Create a .env.local file in your project root and add your configuration:
# The Prompting Company Configuration
TPC_API_KEY=your_api_key_here  # Automatically read by the SDK
TPC_ORG_SLUG=your_organization_slug
TPC_PRODUCT_SLUG=your_product_slug
The SDK automatically reads the TPC_API_KEY environment variable, so you don’t need to pass it explicitly in your code configuration.

Getting Your API Key

You’ll need to create an API key from The Prompting Company dashboard:
  1. Go to API Keys Settings: Visit The Prompting Company API Keys Page
  2. Create New Key: Click “Create New API Key”
  3. Copy the Key: Save the generated API key securely (it will only be shown once)

Finding Your Organization and Product Slugs

Both your organization slug and product slug can be found on the API Keys Settings page. The current organization slug and product slugs are displayed there for easy reference when setting up your SDK configuration.
Never commit API keys to version control. Always use environment variables and add .env.local to your .gitignore file.

TypeScript Configuration

If you’re using TypeScript, the SDK includes built-in type definitions. No additional configuration is required, but you can enhance your experience by adding these compiler options to your tsconfig.json:
{
  "compilerOptions": {
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  }
}

Verify Installation

Create a simple test file to verify your installation:
// test-sdk.ts
import tpc from '@promptingcompany/sdk';

const client = new tpc({
  organizationSlug: process.env.TPC_ORG_SLUG!,
  productSlug: process.env.TPC_PRODUCT_SLUG!,
});

console.log('SDK installed successfully!');
Run the test:
npx tsx test-sdk.ts
If you see “SDK installed successfully!” without errors, you’re ready to proceed.

Next.js Configuration

For Next.js applications, you may want to configure the SDK in a utility file:
// lib/prompting-company.ts
import tpc from '@promptingcompany/sdk';

if (!process.env.TPC_API_KEY) {
  throw new Error('TPC_API_KEY is required');
}

if (!process.env.TPC_ORG_SLUG) {
  throw new Error('TPC_ORG_SLUG is required');
}

if (!process.env.TPC_PRODUCT_SLUG) {
  throw new Error('TPC_PRODUCT_SLUG is required');
}

export const client = new tpc({
  organizationSlug: process.env.TPC_ORG_SLUG,
  productSlug: process.env.TPC_PRODUCT_SLUG,
  // TPC_API_KEY is automatically read by the SDK
});

Troubleshooting

Common Issues

Module not found error:
  • Ensure you’ve installed the package correctly
  • Restart your development server after installation
Environment variable errors:
  • Verify your .env.local file is in the project root
  • Check that variable names match exactly
  • Restart your development server after changing environment variables
TypeScript errors:
  • Make sure you’re using TypeScript 4.5 or higher
  • Verify your tsconfig.json includes the necessary compiler options

Next Steps

Now that you have the SDK installed, let’s build your first integration:

Quick Start Guide

Build your first integration and start accessing your documentation data.