Requirements

  • Python >= 3.9

Install packages

To get started with the SDK, install it using pip:

pip install tako-sdk

View on PyPI

Set up your client

To authenticate, you’ll need to use a Tako API key. We generate an API key for you when you sign up, and you can manage it on your API dashboard. 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 in your code

2.1 Synchronous Client

import os
from tako.client import TakoClient

TAKO_API_KEY = os.getenv("TAKO_API_KEY")

tako_client = TakoClient(TAKO_API_KEY)

2.2 Async Client

import os
from tako.client import AsyncTakoClient

TAKO_API_KEY = os.getenv("TAKO_API_KEY")

tako_client = AsyncTakoClient(TAKO_API_KEY)
Make sure your .env files or exported variables are never committed to version control.

Usage Example

import os
from tako.client import TakoClient
from tako.types.knowledge_search.types import KnowledgeSearchSourceIndex

# Securely load your API key
TAKO_API_KEY = os.getenv("TAKO_API_KEY")

# Initialize the Tako client
tako_client = TakoClient(TAKO_API_KEY)

# Define your query
query = "what's the msft stock price today?"

# (Optional) Define which source indexes to search
source_indexes = [
    KnowledgeSearchSourceIndex.TAKO,
    KnowledgeSearchSourceIndex.WEB
]

# Execute the knowledge search
results = tako_client.knowledge_search(query, source_indexes=source_indexes)

# Print or inspect the results
print(results)