Skip to main content

The official Python SDK for Toolhouse API

Project description

Toolhouse Python SDK

This is the Python SDK for Toolhouse.

Toolhouse allows you to unlock the best LLM knowledge and actions. It works across a wide ranges or LLMs and providers.

With Toolhouse, you can install tools from the Tool Store and execute them in the cloud, without the need to handling their execution locally.

For more details, you can check out our documentation.

Installation

With pip:

pip install toolhouse

With poetry:

poetry add toolhouse

Getting started

In order to use the SDK, you will need a Toolhouse API key. To get the API key:

  1. Sign up for Toolhouse or log in if you are an existing Toolhouse user.
  2. Go to your user ➡️ API Keys (direct link)
  3. Give your API key a name and click Generate.

Copy the API Key and save it where you save your secrets. We'll assume you have a .env file.

We suggest saving your API Key as TOOLHOUSE_API_KEY in your environment file. This allows Toolhouse to pick up its value directly in your code.

TOOLHOUSE_API_KEY=<Your API Key value>

Alternatively, you can set the API key when you initialize the SDK. You can do this in the constructor:

tools = Toolhouse('YOUR_API_KEY')

You can also use the set_access_token method:

tools = Toolhouse()
tools.set_access_token('YOUR_API_KEY')

Our Quick start guide has all you need to get you set up quickly.

Providers

Toolhouse works with the widest possible range of LLMs across different providers. By default, the Toolhouse API will work with any LLM that is compatible with the OpenAI chat completions API.

You can switch providers when initializing the SDK through the constructor:

from toolhouse import Toolhouse, Provider
tools = Toolhouse(provider=provider.ANTHROPIC)

If you are passing your API key:

from toolhouse import Toolhouse, Provider
tools = Toolhouse('YOUR_API_KEY', provider.ANTHROPIC)

Sample usage

In this example, we'll use the OpenAI SDK as well as dotenv.

pip install python-dotenv

Create a .env and add your API keys there.

TOOLHOUSE_API_KEY=
OPENAI_API_KEY=

Head over to Toolhouse and install the Current time tool.

import os
from dotenv import load_dotenv
from toolhouse import Toolhouse
from openai import OpenAI
from typing import List

load_dotenv()

client = OpenAI()
tools = Toolhouse()

#Metadata to convert UTC time to your localtime
th.set_metadata("timezone", -7)

messages: List = [{
    "role": "user",
    "content": "What's the current time?"
}]

response = client.chat.completions.create(
    model='gpt-4o',
    messages=messages,
    tools=tools.get_tools(),
    tool_choice="auto"
)

messages += th.run_tools(response)

response = client.chat.completions.create(
            model="gpt-4o-mini",
            messages=messages,
            tools=tools.get_tools(),
            tool_choice="auto"
        )
print(response.choices[0].message.content)

Contributing

We welcome pull requests that add meaningful additions to these code samples, particularly for issues that can expand compability.

You can submit issues (for example for feature requests or improvements) by using the Issues tab.

Publishing tools

Developers can also contribute to Toolhouse by publishing tools for the Tool Store. The Tool Store allows developers to submit their tools and monetize them every time they're executed. Developers and tools must go through an review and approval process, which includes adhering to the Toolhouse Privacy and Data Protection policy. If you're interested in becoming a publisher, submit your application.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolhouse-1.0.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

toolhouse-1.0.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file toolhouse-1.0.0.tar.gz.

File metadata

  • Download URL: toolhouse-1.0.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for toolhouse-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5a39dd0b36306c9329cf6e2db5e310af2750f59ae637dcdc3d515afeb9b44e2e
MD5 1dec3ba181a49cb161f26754fb433b88
BLAKE2b-256 cae3b276e249f1b8448859ab030f4aedcd9f92d71b2d38e5a437953fc30649b9

See more details on using hashes here.

File details

Details for the file toolhouse-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: toolhouse-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for toolhouse-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5601fbdd8b03ea5cafd1ac8fd528b71c7bae336cc4b97b1df8d17f7a381e588
MD5 ed04102797a23bf249717747111e775b
BLAKE2b-256 966620ed214ff676520e4e64aa489e1df29949deaa58f12cd70d14ef136077a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page