fetchValInfoREADME.md1 match
11## What's the difference with `extractValInfo` ?
1213@pomdtr/extractValInfo get metadata synchronously by analysing the val import url, while @pomdtr/fetchValInfo perform an http call to the val.town REST api.
1415Only use `fetchValInfo` if you need some metadata that are not available from `extractValInfo`.
getMyValIdREADME.md2 matches
1415Works even if the val is private if you provide
16a Val Town API token for the account that
17owns the private val in question.
1819Below the Val Town SDK is implicitly authenticated,
20because it pulls user's Val Town API token from their
21default `'valtown'` environment variable.
22
handsomeMagentaStoatREADME.md3 matches
1# OpenAI - [Docs ↗](https://docs.val.town/std/openai)
23Use OpenAI's chat completion API with [`std/openai`](https://www.val.town/v/std/openai). This integration enables access to OpenAI's language models without needing to acquire API keys.
45For free Val Town users, [all calls are sent to `gpt-4o-mini`](https://www.val.town/v/std/openaiproxy?v=12#L85).
65If these limits are too low, let us know! You can also get around the limitation by using your own keys:
66671. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
682. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
693. Use the `OpenAI` client from `npm:openai`:
70
handsomeMagentaStoatmain.tsx7 matches
23/**
4* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5*/
6export class OpenAI {
89/**
10* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11*
12* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
14* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
17* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
18* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
19*/
20constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21this.rawOpenAIClient = new RawOpenAI({
22...options,
23baseURL: "https://std-openaiproxy.web.val.run/v1",
24apiKey: Deno.env.get("valtown"),
25organization: null,
26});
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
3import { getLinks } from "https://esm.town/v/tempdev/blue";
4import {
5primewireApiKey,
6primewireBase,
7} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
89async function search(imdbId: string) {
10const searchResult = await fetch(`${primewireBase}/api/v1/show?key=${primewireApiKey}&imdb_id=${imdbId}`);
11return await searchResult.json().then((searchResult) => {
12return searchResult.id;
2627const anthropic = createAnthropic({
28// apiKey = Deno.env.get("ANTHROPIC_API_KEY");
29apiKey: Deno.env.get("ANTHROPIC_API_KEY_COVERSHEET")
30});
3132const openai = createOpenAI({
33// apiKey = Deno.env.get("OPENAI_API_KEY");
34apiKey: Deno.env.get("OPENAI_API_KEY_COVERSHEET")
35});
363738const groq = createOpenAI({
39baseURL: 'https://api.groq.com/openai/v1',
40apiKey: Deno.env.get("GROQ_API_KEY"),
41});
4243const perplexity = createOpenAI({
44apiKey: Deno.env.get("PERPLEXITY_API_KEY") ?? '',
45baseURL: 'https://api.perplexity.ai/',
46});
4748const googleProvider = createGoogleGenerativeAI({
49apiKey: Deno.env.get("GOOGLE_GENERATIVE_AI_API_KEY"),
50});
51214if (toolResults && toolResults.length > 0) {
215// we have to do this bc the AI SDK doesn't seem to let you carry over function calling results,
216// so we pretend to be the user instead of using the official role: tool API, which breaks everything
217for (const toolResult of toolResults) {
218options.messages.push({
512return c.json(response);
513} catch (error) {
514console.error('API error:', error);
515return c.text('Error occurred.', 500);
516}
542return c.json(response);
543} catch (error) {
544console.error('API error:', error);
545return c.text('Error occurred.', 500);
546}
blob_adminREADME.md1 match
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
1011It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
1213# TODO
89let btc = await fetchJSON(
10`https://rest.coinapi.io/v1/quotes/COINBASE_SPOT_BTC_USD/current`,
11{
12headers: {
13"X-CoinAPI-Key": Deno.env.get("COIN_API"),
14},
15},
4const destinationB = encodeURIComponent(String(searchParams.get("b")).trim());
56const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
7if (!apiKey) {
8return new Response("Google Maps API key is not set", { status: 500 });
9}
1011const response = await fetch(
12`https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${destinationA}&origins=${destinationB}&units=imperial&key=${apiKey}`,
13);
1415if (!response.ok) {
16return new Response("Failed to fetch data from Google Maps API", { status: response.status });
17}
18