FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
rozek
rozekOpenAIChatCompletion
Public
Like
OpenAIChatCompletion
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 miliseconds.
Sign up now
Code
/
Code
/
Search
Open in new tab
README.md

Use Val.Town's Open AI access wherever you need to enter AI Provider Credentials

Perhaps, you are going to build an AI application for the public with Val.Town.

Personally, you may want to use the Open AI access that comes with Val.Town, but for the entirety of your users the rate limits of that access will be too low.

Thus, you may want them to bring their own AI provider with their own server URL and access key.

But, wait, how do you than use your own application, still using Val.Town's Open AI access?

This is where this val comes in (assuming that you already have a Val.Town account, either a free or a paid one):

  • fork this val
  • use the fork's HTTP endpoint URL (in the form "https://XXX-openaichatcompletion.web.val.run") as AI server URL
  • define an environment variable called "OpenAIChatCompletion" with any kind of content (but without any blanks or control characters, e.g., a UUID) and use that as your personal access key

Now, you can ask everybody to provide their AI credentials and still use the OpenAI access provided by Val.Town for your personal tests.

Nota bene: if the environment variable "OpenAIChatCompletion" has not been defined, access to your fork's endpoint is free for everybody!

In addition to the described authorization, this val also provides resource "throttling" (using val floatingQuotaTracker in sqlite tables "OpenAIChatCompletion_Info" and "OpenAIChatCompletion_Log") and calculates some access statistics (using val InvocationTracker in sqlite tables "OpenAIChatCompletion_Usage_Info" and "OpenAIChatCompletion_Usage_Log")

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.