60
61 let body: string | ReadableStream<Uint8Array> | null = null;
62 // https://api.fireworks.ai/inference/v1/models
63 if (pathname == COMPLETION) {
64 const params = await req.clone().json();
74 body = req.body;
75 }
76 url.host = "api.fireworks.ai";
77 url.port = "443";
78 url.protocol = "https";
92 const response = await fetch(url.toString(), init);
93 const responseHeaders = new Headers(response.headers);
94 // Special handling for /api/v1/models
95 if (pathname == MODELS) {
96 // Clone the response to read it without consuming the original stream
1import vtApi from "https://esm.town/v/neverstew/vtApi";
2
3const res = await vtApi.GET("/v1/search/vals", {
4 params: { query: { query: "api" } },
5});
6const vals = res.data.data;
1Migrated from folder: vtapi/vtApiExample
1import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
2import openapiTS from "npm:openapi-typescript";
3
4export default async () => {
5 const output = await openapiTS("https://www.val.town/docs/openapi.yaml");
6 await updateValByName({
7 token: Deno.env.get("valtown"),
8 name: "vtApiTypes",
9 code: output,
10 });
1Migrated from folder: vtapi/vtApiTypes
1Migrated from folder: vtapi/updateVtApiTypes
1```
2curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \
3 -H 'accept: application/json' \
4 -H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3/**
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3/**
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
53 headers: {