Installation

npm install tako-sdk
# or
yarn add tako-sdk
# or
pnpm add tako-sdk

View on npm

Quick Start

To authenticate, you’ll need a Tako API key. It’s best practice to store it as an environment variable to avoid hardcoding sensitive credentials in your code.

1. Set your API key as an environment variable

On macOS/Linux, add this line to your ~/.bashrc, ~/.zshrc, or equivalent shell config:
export TAKO_API_KEY="your-api-key-here"
On Windows (Command Prompt):
setx TAKO_API_KEY "your-api-key-here"
Restart your terminal or IDE after setting the environment variable.

2. Initialize the client and fetch Tako cards

import { createTakoClient } from 'tako-sdk';

// Initialize the client
const tako = createTakoClient(process.env.TAKO_API_KEY!);

// Search Tako Knowledge
const results = await tako.knowledgeSearch('AMD vs. Nvidia headcount since 2015');
console.log(results.outputs.knowledge_cards);

Usage Example: Next.js API Route

// app/api/tako-search/route.ts
import { createTakoClient } from 'tako-sdk';
import { NextResponse } from 'next/server';

export async function POST(request: Request) {
  const { query, sourceIndexes } = await request.json();
  const tako = createTakoClient(process.env.TAKO_API_KEY!);

  try {
    const results = await tako.knowledgeSearch(query, sourceIndexes);
    return NextResponse.json(results);
  } catch (error: any) {
    return NextResponse.json(
      { error: error.message || 'An error occurred' },
      { status: error.status || 500 }
    );
  }
}