An open registry of pre-made integrations that can work with any frameworks
Project description
Quickstart
OpenTools provides ready-made toolsets (such as Trading) that return consistent, structured outputs across models and frameworks.
In this quickstart, you’ll build a minimal agent that connects to your Alpaca account and returns account information using OpenAI.
Get started
1. Install the SDK
Open a terminal, create a new project folder, set up a virtual environment, and install the required dependencies.
Using uv (recommended)
mkdir my_agent
cd my_agent
uv venv
uv pip install opentools-sdk openai python-dotenv
Using pip
mkdir my_agent
cd my_agent
python -m venv .venv
source .venv/bin/activate
pip install opentools-sdk openai python-dotenv
Using a virtual environment ensures this demo stays isolated from your other projects.
2. Add your API keys
OpenTools reads credentials from environment variables.
This quickstart uses Alpaca for trading and OpenAI as the model provider.
OpenAI API key
If you already have an OpenAI API key, add it to your environment.
Steps:
- Go to the OpenAI dashboard (API keys section)
- Click Create new secret key
- Copy the key and store it somewhere safe
If you already export OPENAI_API_KEY globally, you can omit it from the .env file.
Alpaca API key
Steps:
- Create an Alpaca account (paper trading requires no funding)
- From the dashboard homepage, find Your API Keys
- Click Generate New Keys
- Copy:
- Key ID
- Secret Key
Note
Alpaca only shows the secret key once. If you lose it, you must generate a new key pair.
Create a .env file
This quickstart uses paper trading by default.
OpenTools does not store credentials or manage OAuth. All keys remain local.
Create a file named .env in the same directory as main.py:
OPENAI_API_KEY="your_openai_api_key"
ALPACA_KEY="your_alpaca_key_id"
ALPACA_SECRET="your_alpaca_secret_key"
3. Run your first tool call
You’re about to run a small tool loop:
- The LLM decides which trading tool to call
- OpenTools executes the tool
- The LLM summarises the result
This example uses paper trading and minimal output.
Create main.py
import asyncio
import os
from dotenv import load_dotenv
from openai import AsyncOpenAI
from opentools import trading
from opentools.adapters.models.openai import run_with_tools
async def main() -> None:
load_dotenv()
client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
service = trading.alpaca(
api_key=os.environ["ALPACA_KEY"],
api_secret=os.environ["ALPACA_SECRET"],
model="openai",
paper=True,
minimal=True,
)
prompt = "Show my account summary and list any open positions."
result = await run_with_tools(
client=client,
model="gpt-4.1-mini",
service=service,
user_prompt=prompt,
)
print(result)
if __name__ == "__main__":
asyncio.run(main())
Run the script
python main.py
If the model does not call tools, make the prompt more explicit, for example:
Get my accountList positionsShow recent orders
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentools_sdk-0.1.0.tar.gz.
File metadata
- Download URL: opentools_sdk-0.1.0.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
938cce092543184829e7aaf62eca3c964608c847a2dfaa778a5a50cd12061679
|
|
| MD5 |
424393bf4e9529ee13f56503377c776d
|
|
| BLAKE2b-256 |
b9c13cf9b05e70d41e6f8d532878ed23f216818193f4e2e09aa11f56d29f3512
|
File details
Details for the file opentools_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opentools_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 65.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fafb5376dbf48c721e4e84e56de6f1f26b1a8adce5a972eca2cc66e5451121ec
|
|
| MD5 |
09a5330fd8e43626503e525ec372eb16
|
|
| BLAKE2b-256 |
2f8f20bbb31ada87479c8200f5bc41284ca93edb17167a2627c1cda448b70456
|