Public
Like
1
openai-agents
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v33View latest version
A Val Town template for creating HTTP endpoints powered by the OpenAI Agents SDK.
Add your OpenAI API key to the val's environment variables:
- Go to the val settings
- Find the
OPENAI_API_KEYenvironment variable - Enter your OpenAI API key (get one at https://platform.openai.com/api-keys)
Edit the agent configuration in main.ts. You can provide custom instructions, choose a different model, or add custom tools.
Send POST requests to your val endpoint:
curl -X POST https://username-XXX.val.run \ -H "Content-Type: application/json" \ -d '{"message": "Your question here"}'
Request format:
{ "message": "Tell me about the American Revolution" }
Response format:
{ "response": "The American Revolution was a colonial revolt..." }
The endpoint returns appropriate error responses:
- 405 Method Not Allowed: Only POST requests are accepted
- 400 Bad Request: Message field is missing or invalid
- 500 Internal Server Error: Error running the agent