Assumptions
This example assumes that you have the following:- An Anthropic API key, required by Claude Agent SDK. If not, sign up for an Anthropic account and obtain an API key.
- A Blaxel account and API key. If not, sign up for a Blaxel account and obtain an API key.
- The Blaxel CLI. If not, download and install the Blaxel CLI
1. Install required dependencies
Create a directory for the project:2. Configure the environment
Add your API keys to a.env file in the project directory:
3. Build the agent
In your project directory, create a file namedindex.ts (TypeScript) or main.py (Python) with the following code:
my-sandbox and an agent using the Claude Agent SDK.
- The sandbox exposes a streamable HTTP MCP server at the sandbox’s base URL:
https://<SANDBOX_BASE_URL>/mcp. The base URL can be retrieved undermetadata.urlin the sandbox. - The agent exposes an HTTP endpoint at
/queryto accept user requests. - The agent’s HTTP service is bound to the host and port provided by Blaxel. Blaxel automatically injects these values as
HOSTandPORTvariables into the runtime environment. - The agent configuration includes the sandbox MCP server URL and uses the Blaxel API key as credential to gain access to it (the
Authorizationheader).
scripts section of the package.json file. Update your package.json to ensure that start and dev scripts are defined in the scripts section (TypeScript only).
Next steps
Blaxel isn’t just a sandbox platform. It also lets you co-host and deploy your agent as a serverless auto-scalable endpoint, with near-instant latency. Agent hosting provides endpoints for both synchronous and asynchronous requests and includes full observability and tracing out of the box. The following resources will help you go further:Build and deploy an agent on Blaxel with Claude Agent SDK
Complete guide for building an agent with Claude Agent SDK and deploying it on Blaxel as a serverless auto-scalable API.
Give compute to your agent with the TypeScript SDK
Complete guide for using the TypeScript SDK to develop an agent using Blaxel services.
Give compute to your agent with the Python SDK
Complete guide for using the Python SDK to develop an agent using Blaxel services.
Deploy your agent code to Blaxel
Complete guide for deploying AI agents on Blaxel.
Manage environment variables
Complete guide for managing variables and secrets when deploying on Blaxel.
