vikky 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VSP AI & Robotics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # vikky
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TypeScript client for **Vikky**, VSP's AI API gateway. Vikky speaks the OpenAI API,
4
+ so this package is a thin wrapper over the official `openai` package: anything
5
+ in the OpenAI Node docs works here too.
6
+
7
+ **Server-side only.** Never put a Vikky key in a browser or mobile app: anyone
8
+ can read it and spend your quota. Call Vikky from your own backend, and let your
9
+ app call that. This client does not set `dangerouslyAllowBrowser`.
10
+
11
+ Needs Node 18 or later (Bun and Deno work too).
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install vikky openai
17
+ ```
18
+
19
+ ## Get a key
20
+
21
+ Sign in to the Vikky console at https://vikkyverse.com/platform and create an API key.
22
+
23
+ ```bash
24
+ export VIKKY_API_KEY="your-key"
25
+ ```
26
+
27
+ ## First call (JSON out)
28
+
29
+ ```ts
30
+ import { Vikky } from "vikky";
31
+
32
+ const client = new Vikky(); // reads VIKKY_API_KEY
33
+
34
+ const resp = await client.chat.completions.create({
35
+ model: "vikky-chat",
36
+ messages: [
37
+ { role: "system", content: "Reply in JSON." },
38
+ { role: "user", content: 'List 3 planets as {"planets": [...]}' },
39
+ ],
40
+ response_format: { type: "json_object" },
41
+ });
42
+ const data = JSON.parse(resp.choices[0].message.content ?? "{}");
43
+ console.log(data.planets);
44
+ ```
45
+
46
+ JSON mode works best when your messages say "JSON" and show the shape you want.
47
+
48
+ ## Models
49
+
50
+ | Model | What it does | Call it with |
51
+ |---|---|---|
52
+ | `vikky-chat-flash`, `vikky-chat` | chat with text and images, JSON output, tool calling | `chat.completions.create`, `responses.create` |
53
+ | `vikky-embed*` | embeddings | `embeddings.create` |
54
+ | `vikky-image-flash`, `vikky-image` | image generation and editing | `images.generate`, `images.edit` |
55
+ | `vikky-transcribe-flash`, `vikky-transcribe` | audio to text | `audio.transcriptions.create` |
56
+ | `vikky-speech` | text to audio | `audio.speech.create` |
57
+ | `vikky-rerank-flash`, `vikky-rerank` | rank documents against a query | `rerank` |
58
+ | `vikky-decide-flash`, `vikky-decide` | typed answers: a probability, a label or a score | `decide` |
59
+
60
+ `rerank`, `ocr` and `decide` are not OpenAI routes. They are the only methods this
61
+ package adds, and they return plain JSON objects.
62
+
63
+ ## Images in, images out
64
+
65
+ ```ts
66
+ const resp = await client.chat.completions.create({
67
+ model: "vikky-chat",
68
+ messages: [{ role: "user", content: [
69
+ { type: "text", text: "What is in this picture?" },
70
+ { type: "image_url", image_url: { url: "https://example.com/arm.jpg" } },
71
+ ] }],
72
+ });
73
+ console.log(resp.choices[0].message.content);
74
+
75
+ const img = await client.images.generate({ model: "vikky-image", prompt: "a blue robot arm", response_format: "b64_json" });
76
+ ```
77
+
78
+ For a local image, pass a data URL as the `url`. A generated file's URL is
79
+ temporary: download it in the same run.
80
+
81
+ ## Rerank
82
+
83
+ ```ts
84
+ const resp = await client.rerank({
85
+ query: "how do I reset the arm?",
86
+ documents: ["Press the red button to reset the arm.", "Our office is in Hyderabad."],
87
+ top_n: 1,
88
+ });
89
+ for (const r of resp.results as { index: number; relevance_score: number }[]) {
90
+ console.log(r.index, r.relevance_score);
91
+ }
92
+ ```
93
+
94
+ Results come back best first. `index` points into the `documents` you sent.
95
+
96
+ ## Decisions
97
+
98
+ Ask named questions about an input. You get a probability, a label or a score
99
+ back, never prose. Text in only. One call takes 1 to 128 questions.
100
+
101
+ ```ts
102
+ const resp = await client.decide({
103
+ input: "Help! My payouts have been failing for 3 days.",
104
+ questions: [
105
+ { type: "predicate", name: "is_urgent", instructions: "Does this need action today?" },
106
+ { type: "choice", name: "topic", instructions: "What is it about?",
107
+ choices: [{ value: "billing", description: "money, payouts" }, { value: "other", description: "anything else" }] },
108
+ { type: "score", name: "frustration", instructions: "How frustrated is the writer?",
109
+ levels: [{ label: "calm" }, { label: "annoyed" }, { label: "angry" }] },
110
+ ],
111
+ });
112
+ console.log(resp.answers);
113
+ ```
114
+
115
+ ## OCR
116
+
117
+ ```ts
118
+ const resp = await client.ocr({ document: { type: "document_url", document_url: "https://example.com/invoice.pdf" } });
119
+ ```
120
+
121
+ ## Environment variables
122
+
123
+ | Variable | Required | Default |
124
+ |---|---|---|
125
+ | `VIKKY_API_KEY` | yes | none. `OPENAI_API_KEY` is never used. |
126
+ | `VIKKY_BASE_URL` | no | `https://api.vikkyverse.com/v1` |
127
+
128
+ Options win over environment: `new Vikky({ apiKey, baseURL })`. Every other option
129
+ (`timeout`, `maxRetries`, ...) goes to `OpenAI`. A missing key throws `VikkyError`.
130
+
131
+ ## License
132
+
133
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
34
+ Vikky: () => Vikky,
35
+ VikkyError: () => VikkyError,
36
+ default: () => index_default
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+ var import_openai = __toESM(require("openai"), 1);
40
+ var DEFAULT_BASE_URL = "https://api.vikkyverse.com/v1";
41
+ var VikkyError = class extends import_openai.OpenAIError {
42
+ };
43
+ var Vikky = class extends import_openai.default {
44
+ constructor(opts = {}) {
45
+ const apiKey = opts.apiKey || process.env.VIKKY_API_KEY;
46
+ if (!apiKey) throw new VikkyError("No Vikky API key. Set VIKKY_API_KEY or pass apiKey.");
47
+ const baseURL = opts.baseURL || process.env.VIKKY_BASE_URL || DEFAULT_BASE_URL;
48
+ super({ ...opts, apiKey, baseURL });
49
+ }
50
+ /** Score documents against a query. `POST /v1/rerank`, Cohere-shaped. */
51
+ rerank({ model = "vikky-rerank", ...rest }) {
52
+ return this.post("/rerank", { body: { model, ...rest } });
53
+ }
54
+ /** Read text out of a document or image. `POST /v1/ocr`. */
55
+ ocr({ model = "vikky-ocr", ...rest }) {
56
+ return this.post("/ocr", { body: { model, ...rest } });
57
+ }
58
+ /** Answer named questions about an input. `POST /v1/decisions`. */
59
+ decide({ model = "vikky-decide", ...rest }) {
60
+ return this.post("/decisions", { body: { model, ...rest } });
61
+ }
62
+ };
63
+ var index_default = Vikky;
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ DEFAULT_BASE_URL,
67
+ Vikky,
68
+ VikkyError
69
+ });
@@ -0,0 +1,65 @@
1
+ import OpenAI, { ClientOptions, OpenAIError } from 'openai';
2
+
3
+ /**
4
+ * TypeScript client for Vikky, VSP's OpenAI-compatible AI API gateway.
5
+ *
6
+ * A thin wrapper over the official `openai` package: only the API key and base URL
7
+ * defaults differ. `rerank`, `ocr` and `decide` are the only added methods: they are
8
+ * not OpenAI routes. Server-side only: never put a Vikky key in a browser or mobile app.
9
+ */
10
+
11
+ declare const DEFAULT_BASE_URL = "https://api.vikkyverse.com/v1";
12
+ declare class VikkyError extends OpenAIError {
13
+ }
14
+ type Json = Record<string, unknown>;
15
+ interface RerankParams {
16
+ query: string;
17
+ documents: string[];
18
+ model?: string;
19
+ top_n?: number;
20
+ [key: string]: unknown;
21
+ }
22
+ interface OcrParams {
23
+ document: Json;
24
+ model?: string;
25
+ [key: string]: unknown;
26
+ }
27
+ type DecisionQuestion = {
28
+ type: "predicate";
29
+ name: string;
30
+ instructions: string;
31
+ } | {
32
+ type: "choice";
33
+ name: string;
34
+ instructions: string;
35
+ choices: {
36
+ value: string;
37
+ description?: string;
38
+ }[];
39
+ } | {
40
+ type: "score";
41
+ name: string;
42
+ instructions: string;
43
+ levels: {
44
+ label: string;
45
+ description?: string;
46
+ }[];
47
+ };
48
+ interface DecideParams {
49
+ input: unknown;
50
+ questions: DecisionQuestion[];
51
+ model?: string;
52
+ [key: string]: unknown;
53
+ }
54
+ type VikkyOptions = Omit<ClientOptions, "dangerouslyAllowBrowser">;
55
+ declare class Vikky extends OpenAI {
56
+ constructor(opts?: VikkyOptions);
57
+ /** Score documents against a query. `POST /v1/rerank`, Cohere-shaped. */
58
+ rerank({ model, ...rest }: RerankParams): Promise<Json>;
59
+ /** Read text out of a document or image. `POST /v1/ocr`. */
60
+ ocr({ model, ...rest }: OcrParams): Promise<Json>;
61
+ /** Answer named questions about an input. `POST /v1/decisions`. */
62
+ decide({ model, ...rest }: DecideParams): Promise<Json>;
63
+ }
64
+
65
+ export { DEFAULT_BASE_URL, type DecideParams, type DecisionQuestion, type Json, type OcrParams, type RerankParams, Vikky, VikkyError, type VikkyOptions, Vikky as default };
@@ -0,0 +1,65 @@
1
+ import OpenAI, { ClientOptions, OpenAIError } from 'openai';
2
+
3
+ /**
4
+ * TypeScript client for Vikky, VSP's OpenAI-compatible AI API gateway.
5
+ *
6
+ * A thin wrapper over the official `openai` package: only the API key and base URL
7
+ * defaults differ. `rerank`, `ocr` and `decide` are the only added methods: they are
8
+ * not OpenAI routes. Server-side only: never put a Vikky key in a browser or mobile app.
9
+ */
10
+
11
+ declare const DEFAULT_BASE_URL = "https://api.vikkyverse.com/v1";
12
+ declare class VikkyError extends OpenAIError {
13
+ }
14
+ type Json = Record<string, unknown>;
15
+ interface RerankParams {
16
+ query: string;
17
+ documents: string[];
18
+ model?: string;
19
+ top_n?: number;
20
+ [key: string]: unknown;
21
+ }
22
+ interface OcrParams {
23
+ document: Json;
24
+ model?: string;
25
+ [key: string]: unknown;
26
+ }
27
+ type DecisionQuestion = {
28
+ type: "predicate";
29
+ name: string;
30
+ instructions: string;
31
+ } | {
32
+ type: "choice";
33
+ name: string;
34
+ instructions: string;
35
+ choices: {
36
+ value: string;
37
+ description?: string;
38
+ }[];
39
+ } | {
40
+ type: "score";
41
+ name: string;
42
+ instructions: string;
43
+ levels: {
44
+ label: string;
45
+ description?: string;
46
+ }[];
47
+ };
48
+ interface DecideParams {
49
+ input: unknown;
50
+ questions: DecisionQuestion[];
51
+ model?: string;
52
+ [key: string]: unknown;
53
+ }
54
+ type VikkyOptions = Omit<ClientOptions, "dangerouslyAllowBrowser">;
55
+ declare class Vikky extends OpenAI {
56
+ constructor(opts?: VikkyOptions);
57
+ /** Score documents against a query. `POST /v1/rerank`, Cohere-shaped. */
58
+ rerank({ model, ...rest }: RerankParams): Promise<Json>;
59
+ /** Read text out of a document or image. `POST /v1/ocr`. */
60
+ ocr({ model, ...rest }: OcrParams): Promise<Json>;
61
+ /** Answer named questions about an input. `POST /v1/decisions`. */
62
+ decide({ model, ...rest }: DecideParams): Promise<Json>;
63
+ }
64
+
65
+ export { DEFAULT_BASE_URL, type DecideParams, type DecisionQuestion, type Json, type OcrParams, type RerankParams, Vikky, VikkyError, type VikkyOptions, Vikky as default };
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ // src/index.ts
2
+ import OpenAI, { OpenAIError } from "openai";
3
+ var DEFAULT_BASE_URL = "https://api.vikkyverse.com/v1";
4
+ var VikkyError = class extends OpenAIError {
5
+ };
6
+ var Vikky = class extends OpenAI {
7
+ constructor(opts = {}) {
8
+ const apiKey = opts.apiKey || process.env.VIKKY_API_KEY;
9
+ if (!apiKey) throw new VikkyError("No Vikky API key. Set VIKKY_API_KEY or pass apiKey.");
10
+ const baseURL = opts.baseURL || process.env.VIKKY_BASE_URL || DEFAULT_BASE_URL;
11
+ super({ ...opts, apiKey, baseURL });
12
+ }
13
+ /** Score documents against a query. `POST /v1/rerank`, Cohere-shaped. */
14
+ rerank({ model = "vikky-rerank", ...rest }) {
15
+ return this.post("/rerank", { body: { model, ...rest } });
16
+ }
17
+ /** Read text out of a document or image. `POST /v1/ocr`. */
18
+ ocr({ model = "vikky-ocr", ...rest }) {
19
+ return this.post("/ocr", { body: { model, ...rest } });
20
+ }
21
+ /** Answer named questions about an input. `POST /v1/decisions`. */
22
+ decide({ model = "vikky-decide", ...rest }) {
23
+ return this.post("/decisions", { body: { model, ...rest } });
24
+ }
25
+ };
26
+ var index_default = Vikky;
27
+ export {
28
+ DEFAULT_BASE_URL,
29
+ Vikky,
30
+ VikkyError,
31
+ index_default as default
32
+ };
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "vikky",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "TypeScript client for Vikky, VSP's OpenAI-compatible AI API gateway. Server-side only.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
13
+ "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
14
+ }
15
+ },
16
+ "files": ["dist", "README.md", "LICENSE"],
17
+ "engines": { "node": ">=18" },
18
+ "sideEffects": false,
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
21
+ "typecheck": "tsc --noEmit",
22
+ "test": "vitest run"
23
+ },
24
+ "peerDependencies": { "openai": ">=6.0.0 <8" },
25
+ "devDependencies": {
26
+ "@types/node": "^22.0.0",
27
+ "openai": "^6.49.0",
28
+ "tsup": "^8.0.0",
29
+ "typescript": "^5.6.0",
30
+ "vitest": "^3.0.0"
31
+ }
32
+ }