Quickstart
Build your first flow with Timbal with 5 lines of code.
We'll start implementing an agent. It will be a simple chatbot and gradually enhance it with advanced features. Let's dive in!
Before moving forward, ensure you've completed the installation of Timbal. If you haven't set it up yet, follow the installation guide to get started.
Part 0: Creating a Timbal Projectโ
Timbal makes your life easier by automatically setting up a complete project structure. When you run timbal init
, it creates a directory with the following structure:
-
Run the timbal CLI command:
-
This creates a new project with the following structure:
my-project
agent.py
.dockerignore
pyproject.toml
timbal.yaml
File Description agent.py Main entry point for your AI flow logic. Define your agents, tools, and workflow here. .dockerignore Lists files and directories to exclude when building Docker images. pyproject.toml Manages project dependencies and settings. Used by Python tools. timbal.yaml Main configuration file for Timbal, where you set up project options and integrations.
You will have a file agent.py
with a basic structure of a flow.
This is the only file you need to edit to create your own flow.
๐ If you want to use LLM models, you might have to provide your API keys for the LLM providers corresponding to the models you are using.
Store sensitive information like API keys in a .env
file.
Timbal automatically sets up a Python environment using uv
. You can manage your project dependencies using uv
commands just like in any other Python project. For example:
This makes it easy to add new packages and manage your project's dependencies.
Part 1: Build a Simple Chatbotโ
๐ Let's create a simple chatbot that can respond to user messages.
1. Import the class Agent
from the timbal
package.
2. Initialize an Agent
object.
3. Set your environment variables
Before running your flow, make sure you have the keys needed set as environment variables in your .env
file:
๐ It will depend on the LLM you're using, in this case we are using a Gemini model
Only with the Agent
class we have a flow that represents a llm that receives a prompt
and returns a response
.
Now let's run the chatbot!
You will see an output like this:
You've just created your first Timbal flow!
This is the simplest flow you can create.
You can modify it as you want. For example, you can add tools to the agent.
Part 2: Enhancing the Chatbot with Toolsโ
A great feature of Timbal is that you can easily add tools to your agent, allowing it to perform actions or fetch information in real time.
You can use both prebuilt tools (already provided by Timbal or the community) and custom tools (functions you create yourself).
Let's see both approaches with practical examples:
Example 1: Using a Prebuilt Toolโ
Timbal comes with several tools ready to use. Here are two powerful examples:
a) Internet Searchโ
You can use the search tool to let your agent search the internet for up-to-date information:
b) SQL/Postgres Queryโ
Timbal also provides a prebuilt tool to query a Postgres database:
Example 2: Creating Your Own Toolโ
You can also create your own tools. Here's a very simple example: a tool that returns the current date and time.
With Timbal, you can combine as many tools as you wantโprebuilt or customโto make your agent as powerful as you need!
That's it! With 5 lines of code we've created a chatbot with tools.
Looking for the full list of integrations or examples?
Head over to integrations/examples or, even better, check out our GitHub! We're adding new examples as fast as we can.
Want the latest and greatest? Just do a git pull to make sure you have all the newest content! ๐
Deploying Timbalโ
The best way to deploy your Timbal project is through the official Timbal Platform. Itโs fast, easy, and gives you access to all the latest features and integrations.
๐ Go to the [Timbal Platform] to get started!
Prefer to run things locally or on your own infrastructure?
No problem! You can use timbal build
to generate a ready-to-use Docker container with your flow and an HTTP server preconfigured. This makes it simple to deploy anywhere Docker runs.