Toolhouse
Last updated
Was this helpful?
Was this helpful?
TOOLHOUSE_API_KEY=<your_toolhouse_api_key>
AIMLAPI_KEY=<your_aimlapi_key>import os
from dotenv import load_dotenv
from toolhouse import Toolhouse
from openai import OpenAI
load_dotenv()
th = Toolhouse(api_key=os.getenv("TOOLHOUSE_API_KEY"))
client = OpenAI(
api_key=os.getenv("AIMLAPI_KEY"),
base_url="https://api.aimlapi.com/v1",
)
MODEL = "alibaba/qwen3.5-plus-20260218"
messages = [
{
"role": "user",
"content": "List 3 innovative uses of AI in healthcare."
}
]
response = client.chat.completions.create(
model=MODEL,
messages=messages,
tools=th.get_tools()
)
tool_run = th.run_tools(response)
messages.extend(tool_run)
response = client.chat.completions.create(
model=MODEL,
messages=messages,
tools=th.get_tools()
)
print(response.choices[0].message.content)npm install @toolhouseai/sdk openai dotenvTOOLHOUSE_API_KEY=<Your Toolhouse API Key>
AIMLAPI_KEY=<Your AIMLAPI Key>import 'dotenv/config';
import { Toolhouse } from '@toolhouseai/sdk';
import OpenAI from 'openai';
const MODEL = 'alibaba/qwen3.5-plus-20260218';
async function main() {
const toolhouse = new Toolhouse({
apiKey: process.env.TOOLHOUSE_API_KEY,
metadata: {
id: "aimlapi-integration",
timezone: "0"
}
});
const client = new OpenAI({
baseURL: "https://api.aimlapi.com/v1",
apiKey: process.env.AIMLAPI_KEY
});
const messages = [{
role: "user",
content: "List three use cases of AI in retail."
}];
const tools = await toolhouse.getTools();
const chatCompletion = await client.chat.completions.create({
model: MODEL,
messages,
tools
});
const toolResponses = await toolhouse.runTools(chatCompletion);
const finalMessages = [...messages, ...toolResponses];
const finalResponse = await client.chat.completions.create({
model: MODEL,
messages: finalMessages,
tools
});
console.log(JSON.stringify(finalResponse, null, 2));
}
main();npx ts-node toolhouse.ts