Public
Readme
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.
- Server-side: (Optional) An active OpenAI API key
- Client-side: Something that can make POST requests (browser code, Postman, cURL, another Val, etc)
The primary endpoint for this function is designed to handle HTTP POST requests.
- Method: POST
- Content-Type: application/json
- Body: JSON object containing a
prompt
field (e.g.{"prompt": "Help me make a boat."}
)
curl -X POST https://ashryanio-openaiproxy.web.val.run -H "Content-Type: application/json" -d '{"prompt": "Hello, OpenAI!"}'
- Content-Type: application/json
- Body: JSON object containing the response from the OpenAI language model.
{
"llmResponse": "Hi there! How can I assist you today?"
}
- 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.
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
ashryanio-openaiproxy.web.val.run
Updated: July 8, 2024