Reference · Deploying
- The language
- Agents and tools
- Model providers
- The Anthropic API
- Talking agents
- Standard library
- Glossary
- Package docs
- Telemetry
- Robots
- Servers
- Deploying
- tin.ad
- The tin command
- How it works
On this page
Deploying
tin deploy: a Tin program on Cloudflare, Vercel, Cloud Run, Azure or Lambda, with the target checked like a capability and keys kept out of the build.
From zero to a URL
tin new hello --template hello-agent
cd hello
tin deploy main.tin --target cloudflare The last line compiles the program, checks that Cloudflare Workers can run everything it uses, writes
dist/cloudflare/, and uploads it with Cloudflare's own CLI (wrangler, logged in once with
npx wrangler login). On the machine this page was written on, that took 11 seconds and printed
live: https://tin-hello.<account>.workers.dev. The template's agent uses model: "mock", so it
deploys before you have a key.
The deployed program is the same handler tin serve runs: the routes of its server, and for every agent
POST /agents/<Name> (JSON, or streamed with Accept: text/event-stream), GET /agents/<Name>
and a tool on POST /mcp; GET / lists them and GET /healthz answers
{"ok":true}. A file with agents and no server gets those endpoints too. A program with only
fn main() answers GET / by running main and returning what it printed.
curl -X POST https://tin-hello.<account>.workers.dev/agents/Greeter -d 'hi'
curl -N -X POST https://tin-hello.<account>.workers.dev/agents/Greeter -H 'accept: text/event-stream' -d 'hi' Every target
| Target | Platform | HTTP | WebSockets | Secrets go to | Deployed for real |
|---|---|---|---|---|---|
--target cloudflare | Cloudflare Workers | yes | yes | Worker secrets (wrangler secret put NAME) | yes, from this repo |
--target vercel | Vercel Functions | yes | no | Environment variables, encrypted (vercel env add NAME production) | yes, from this repo |
--target cloudrun | Google Cloud Run | yes | yes | Secret Manager, mounted as env (gcloud run deploy --set-secrets NAME=NAME:latest) | no: built and run locally only |
--target azure | Azure Functions | yes | no | App settings, or Key Vault references (az functionapp config appsettings set) | no: built and run locally only |
--target lambda | AWS Lambda (Function URL) | yes | no | Function environment variables from a NoEcho template parameter | no: built and run locally only |
--target pages | GitHub Pages (static) | no | no | none: a static site has no secrets; visitors bring their own model key | no: built and run locally only |
- cloudflare: WebAssembly with JSPI runs in Workers, so agents pause on model calls the same way they do in Node. WebSockets are held by the Worker; Durable Objects when a connection must outlive one request.
- vercel: Streaming responses (SSE) work. Functions do not hold WebSockets.
- cloudrun: A container running Node. WebSockets and voice agents work; requests time out after 60 minutes.
- azure: HTTP functions stream responses. Functions do not hold WebSockets; the same container as cloudrun runs on Azure Container Apps and does.
- lambda: A Function URL with response streaming carries SSE. WebSockets on API Gateway are a different model (one invocation per message), so Tin does not target them.
- pages: A static page that runs main() in the visitor's browser. No server, no routes; a model key is typed in by the visitor, kept in the page's memory only and sent only to that model's API. Agents, sleep and fetch need Chrome or Edge 137+ (JSPI).
Every Node target runs Node 24 or newer, the first Node with WebAssembly JSPI on by default; that is how an agent waits for a model without blocking other requests. Cloudflare Workers have JSPI too.
The target is a capability
A program that uses something its target cannot do does not deploy. The error comes from tin build,
before anything is written or uploaded, and says what to do instead:
$ tin build code.tin --target cloudflare
error[target-codegen]: an agent with `code: true` compiles the Tin it writes at run time, and Cloudflare Workers forbid compiling WebAssembly from bytes
--> code.tin (--target cloudflare)
= fix: use --target vercel, cloudrun, azure or lambda (all run Node), or drop `code: true` and give the agent tools instead The checks: WebSocket routes and voice agents need cloudflare or cloudrun; raw TCP deploys
nowhere; import py needs cloudrun (its container installs python3); import js,
import mcp and bedrock-sonic: need Node; pages takes no server and no secrets.
An agent's automatic WebSocket endpoint is dropped on targets without WebSockets; a ws route you wrote is
an error there.
Secrets
The build lists the environment variables the program reads (the model keys, from each agent's
model) by name. Values never go into the build: tests plant a key in the environment, build every target
and search every file for it. tin deploy:
- takes each key from your environment, or asks for it without echoing;
- shows the names and the platform, and asks
upload AWS_BEARER_TOKEN_BEDROCK to Cloudflare Workers (Worker secrets)? [y/N](--yesanswers for CI; with no terminal and no--yesit stops); - hands the values to the platform CLI on standard input (
wrangler secret bulk,vercel env add --sensitive), never as a command-line argument and never in a file.
Long-lived AWS access keys (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) in your environment are
not used: they are usually your own account's keys. Use a scoped key such as a Bedrock API key, or pass
--allow-access-keys when the keys were made for this deployment.
Deploy buttons
--repo writes a one-click button into the build's DEPLOY.md, pointing at the build folder in
your repository:
tin build main.tin --target vercel -o deploy/vercel --repo https://github.com/you/hello Commit deploy/ and push. Cloudflare, Vercel and Cloud Run have buttons. Azure's needs an ARM template and a
code package at public URLs, and a CloudFormation quick-create link needs an S3 bucket; their DEPLOY.md says
what to run instead (az deployment group create, sam deploy --guided). A button clones a public
repository; on a private one it does not work.
What a build contains
A build folder runs without the Tin repo and without a bundler: app.wasm, the Tin runtime as plain JavaScript in
tin/, server.js (createHandler: one web-standard fetch(Request) → Response),
worker.js and node.js entries, manifest.json (routes, agents, secret names, what the program
needs), and the platform's own files: wrangler.toml; api/index.js + vercel.json;
Dockerfile + app.json + deploy.sh; an Azure Functions trigger + azuredeploy.bicep;
a streaming Lambda handler + a SAM template.yaml. tin build --target cloudrun also runs anywhere a
container runs (Azure Container Apps, Fly, a VM): node node.js listens on $PORT.
A page instead of a server
tin build main.tin --target pages -o site writes a static page (index.html, page.js,
app.wasm, the runtime) that runs main in the visitor's browser when they press Run. If the program's
agents need a key, the page has a password field for each; the visitor's key stays in that tab's memory and goes only
to the model's API. Push the folder to any static host (a gh-pages branch, a Pages workflow). A
server, import js/py/mcp and code: true agents are errors for this target. Agents need
Chrome or Edge 137+.
One request, one instance
Each request gets a fresh WebAssembly instance of the same compiled module, so nothing in Tin memory outlives a
request and a panic fails only that request (500). Many requests run at once on one event loop; each one pauses only
at a model call, a fetch or a sleep.
What does not work yet
- WebSocket endpoints (
/agents/<Name>/ws,ws "/voice" = VoiceAgent) work ontin serve, Node containers, Cloudflare and tin.ad; Vercel, Lambda and Pages cannot hold a socket. - Cloud Run, Azure and Lambda are built and run locally only; nobody has deployed them for real from this repo.
tin deploywith no target goes to aname.tin.adaddress: see tin.ad.