Use the Blaxel SDK to develop and run a custom agent in Python.
bl create-agent-app
.
main.py
. While you typically wonβt need to modify this file, you can add specific logic there if needed. Your main work will focus on the agent.py
file. Blaxelβs development paradigm lets you leverage its hosting capabilities without modifying your agentβs core logic.
BL_SERVER_HOST
(for the host) and BL_SERVER_PORT
(for the port). These two environment variables are required for the host+port combo.
FRAMEWORK_NAME
specified in the import.
Available frameworks :
langgraph
crewai
llamaindex()
openai()
pydantic()
googleadk()
my-model
in a LlamaIndex agent:
langgraph
(LangGraph/Langchain), llamaindex
(LlamaIndex), crewai
(CrewAI), openai
(OpenAI Agents), pydantic
(PydanticAI Agents) and googleadk
(Google ADK).
You can develop agents by mixing tools defined locally in your agents, and tools defined as remote servers. Using separated tools prevents monolithic designs which make maintenance easier in the long run. Letβs look at a practical example combining remote and local tools. The code below uses two tools:
blaxel-search
: A remote tool server on Blaxel providing web search functionality (learn how to create your own MCP servers here)weather
: A local tool that accepts a city parameter and returns a mock weather response (always βsunnyβ)bl_agent().run()
rather than combining all functionality into a single codebase.
blaxel.toml
file at the root of your directory.
Read the file structure section down below for more details.
type
so Blaxel knows which kind of entity to deploy. Others are not mandatory but allow you to customize the deployment.
name
, workspace
, and type
fields are optional and serve as default values. Any bl command run in the folder will use these defaults rather than prompting you for input.agents
, functions
, and models
fields are also optional. They specify which resources to deploy with the agent. These resources are preloaded during build, eliminating runtime dependencies on the Blaxel control plane and dramatically improving performance.[env]
section defines environment variables that the agent can access via the SDK. Note that these are NOT secrets.[runtime]
section allows to override agent deployment parameters: timeout (in s) or memory (in MB) to allocate.[[triggers]]
and [triggers.configuration]
sections defines ways to send requests to the agent. You can create both synchronous and asynchronous trigger endpoints. You can also make them either private (default) or public.
A private synchronous HTTP endpoint is always created by default, even if you donβt define any trigger here.[entrypoint]
section to specify how Blaxel is going to start your server:
prod
: this is the command that will be used to serve your agentdev
: same as prod in dev mode, it will be used with the command --hotreload
. Example:entrypoint
section is optional. If not specified, Blaxel will automatically detect in the agentβs content and configure your agent startup settings.
BL_SERVER_HOST
& BL_SERVER_PORT
. Blaxel automatically injects these variables during deployment.