FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
tkneisly
tkneislyautonomous-val
Remix of nbbaier/autonomous-val
Public
Like
autonomous-val
Home
Code
7
README.md
H
agent.tsx
H
demo.tsx
H
diagram.tsx
prompt.tsx
tools.tsx
utils.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
2
Settings
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
https://tkneisly--353d429201d741449e083d14321996ff.web.val.run
README.md

Autonomous Val

This project demonstrates how to build autonomous agents on Val Town that can be triggered by API calls, cron jobs, etc.

Screenshot 2025-05-29 at 8.03.54 PM.png

Setup

Remix this Val into your Val Town account.

Configure the following variables in your environment:

  • AGENT_API_KEY (This is a secure token that you choose to secure the agent.tsx POST endpoint)
  • OPENAI_API_KEY (An OpenAI API Key)
  • EXA_API_KEY (Optional, though needed if you use the web search tool)

Usage

Use demo.tsx to send objectives to your agent.

API Usage

To use the API from another client, you can POST authenticated requests to the agent.tsx endpoint:

const requestBody = { messages: [ { role: "user", content: "What is the difference in height between the Salesforce Tower and the Empire State Building?" }, ], streamResults: false, }; const response = await fetch("https://<your-val-id>.web.val.run/", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${Deno.env.get("AGENT_API_KEY")}`, }, body: JSON.stringify(requestBody), });

Streaming Chat

The API will also work with streaming chat front ends based on the Vercel AI SDK's useChat hook.

You just need to pass streamResults: true in your API POST request.

Using Other Models

It is easy to reconfigure the agent to work with other providers that are supported by Vercel's AI SDK, though not all models support tool calling.

Anthropic's models should work well, but the system prompt would need to be retuned to work with Claude.

Learn more: https://ai-sdk.dev/docs/foundations/providers-and-models

HTTP
  • agent.tsx
    tkneisly--35…ff.web.val.run
  • demo.tsx
    tkneisly--ff…83.web.val.run
  • diagram.tsx
    tkneisly--80…30.web.val.run
Code
README.md
H
agent.tsx
H
demo.tsx
H
diagram.tsx
prompt.tsxtools.tsxutils.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.