FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
ashryanio
ashryanioopenAiProxy
Public
Like
1
openAiProxy
Home
Code
2
README.md
H
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
Code
/
Search
main.tsx
https://ashryanio--28c8c30c278511f0b46e569c3dd06744.web.val.run
README.md

openAiProxy

Overview

This val is a proxy server that interacts with the OpenAI API to generate responses based on prompts in the request body. The function handles incoming HTTP POST requests, processes the prompt, and returns a response generated by the LLM.

Prerequisites

  • Server-side: (Optional) An active OpenAI API key
  • Client-side: Something that can make POST requests (browser code, Postman, cURL, another Val, etc)

Usage

Endpoint

The primary endpoint for this function is designed to handle HTTP POST requests.

Request

  • Method: POST
  • Content-Type: application/json
  • Body: JSON object containing a prompt field (e.g. {"prompt": "Help me make a boat."})

Example Request

curl -X POST https://ashryanio-openaiproxy.web.val.run -H "Content-Type: application/json" -d '{"prompt": "Hello, OpenAI!"}'

Response

  • Content-Type: application/json
  • Body: JSON object containing the response from the OpenAI language model.

Example Response

{ "llmResponse": "Hi there! How can I assist you today?" }

Error Handling

  • 400 Bad Request: Returned if the prompt field is missing in the request body.
  • 405 Method Not Allowed: Returned if any method other than POST or OPTIONS is used.
  • 500 Internal Server Error: Returned if there is an error processing the request.
HTTP
  • main.tsx
    ashryanio--28…44.web.val.run
Code
README.md
H
main.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.