Empower any LLM with function calling capabilities.
Toolify is a middleware proxy designed to inject OpenAI-compatible function calling capabilities into Large Language Models that do not natively support it, or into OpenAI API interfaces that do not provide this functionality. It acts as an intermediary between your application and the upstream LLM API, injecting necessary prompts and parsing tool calls from the model's response.
- Universal Function Calling: Enables function calling for LLMs or APIs that adhere to the OpenAI format but lack native support.
- Multiple Function Calls: Supports executing multiple functions simultaneously in a single response.
- Flexible Initiation: Allows function calls to be initiated at any stage of the model's output.
- Think Tag Compatibility: Seamlessly handles
<think>
tags, ensuring they don't interfere with tool parsing. - Streaming Support: Fully supports streaming responses, detecting and parsing function calls on the fly.
- Multi-Service Routing: Routes requests to different upstream services based on the requested model name.
- Client Authentication: Secures the middleware with configurable client API keys.
- Enhanced Context Awareness: Provides LLMs with the details (name and parameters) of previous tool calls alongside the execution results, improving contextual understanding.
- Intercept Request: Toolify intercepts the
chat/completions
request from the client, which includes the desired tools. - Inject Prompt: It generates a specific system prompt instructing the LLM how to output function calls using a structured XML format and a unique trigger signal.
- Proxy to Upstream: The modified request is sent to the configured upstream LLM service.
- Parse Response: Toolify analyzes the upstream response. If the trigger signal is detected, it parses the XML structure to extract the function calls.
- Format Response: It transforms the parsed tool calls into the standard OpenAI
tool_calls
format and sends it back to the client.
You can run Toolify using Python directly or via Docker Compose.
- Python 3.8+
-
Clone the repository:
git clone https://github.com/yourusername/toolify.git cd toolify
-
Install dependencies:
pip install -r requirements.txt
-
Configure the application:
Copy the example configuration file and edit it:
cp config.example.yaml config.yaml
Edit
config.yaml
to set up your upstream services, API keys, and allowed client keys. -
Run the server:
uvicorn main:app --host 0.0.0.0 --port 8000
This is the recommended way for easy deployment.
- Docker and Docker Compose installed.
-
Clone the repository:
git clone https://github.com/yourusername/toolify.git cd toolify
-
Configure the application:
Copy the example configuration file and edit it:
cp config.example.yaml config.yaml
Edit
config.yaml
. Thedocker-compose.yml
file is configured to mount this file into the container. -
Start the service:
docker-compose up -d --build
This will build the Docker image and start the Toolify service in detached mode, accessible at
http://localhost:8000
.
Refer to config.example.yaml
for detailed configuration options.
server
: Middleware host, port, and timeout settings.upstream_services
: List of upstream LLM providers (e.g., Groq, OpenAI, Anthropic).- Define
base_url
,api_key
, supportedmodels
, and set one service asis_default: true
.
- Define
client_authentication
: List ofallowed_keys
for clients accessing this middleware.features
: Toggle features like logging, streaming, and role conversion.
Once Toolify is running, configure your client application (e.g., using the OpenAI SDK) to use Toolify's address as the base_url
. Use one of the configured allowed_keys
for authentication.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1", # Toolify endpoint
api_key="sk-my-secret-key-1" # Your configured client key
)
# The rest of your OpenAI API calls remain the same, including tool definitions.
Toolify handles the translation between the standard OpenAI tool format and the prompt-based method required by unsupported LLMs.
This project is licensed under the GPL-3.0-or-later license.