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.
import osfrom tako.client import TakoClientfrom tako.types.knowledge_search.types import KnowledgeSearchSourceIndex# Securely load your API keyTAKO_API_KEY = os.getenv("TAKO_API_KEY")# Initialize the Tako clienttako_client = TakoClient(TAKO_API_KEY)# Define your queryquery = "what's the msft stock price today?"# (Optional) Define which source indexes to searchsource_indexes = [ KnowledgeSearchSourceIndex.TAKO, KnowledgeSearchSourceIndex.WEB]# Execute the knowledge searchresults = tako_client.knowledge_search(query, source_indexes=source_indexes)# Print or inspect the resultsprint(results)