@apicity/google 0.2.6

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 Justin Tanner
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 ADDED
@@ -0,0 +1,76 @@
1
+ # @apicity/google
2
+
3
+ [![npm](https://img.shields.io/npm/v/@apicity/google?color=cb0000)](https://www.npmjs.com/package/@apicity/google)
4
+ [![zero dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](package.json)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue?logo=typescript&logoColor=white)](tsconfig.json)
6
+ [![docs](https://img.shields.io/badge/docs-docs.cloud.google.com-blue)](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/express-mode/rest/v1/publishers.models/generateContent)
7
+
8
+ Google Gemini provider for express-mode generateContent.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @apicity/google
14
+ # or
15
+ pnpm add @apicity/google
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```typescript
21
+ import { createGoogle } from "@apicity/google";
22
+
23
+ const google = createGoogle({ apiKey: process.env.GOOGLE_API_KEY! });
24
+ ```
25
+
26
+ ## API Reference
27
+
28
+ 2 endpoints across 1 group. Each method mirrors an upstream URL path.
29
+
30
+ ### publishers
31
+
32
+ <details>
33
+ <summary><code>POST</code> <b><code>google.v1.publishers.google.models.countTokens</code></b></summary>
34
+
35
+ <code>POST https://aiplatform.googleapis.com/v1/publishers/google/models/{model}:countTokens</code>
36
+
37
+ [Upstream docs ↗](https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/express-mode/rest/v1/publishers.models/countTokens)
38
+
39
+ ```typescript
40
+ const res = await google.v1.publishers.google.models.countTokens(
41
+ "gemini-2.5-flash",
42
+ {
43
+ contents: [{ role: "user", parts: [{ text: "How does AI work?" }] }],
44
+ }
45
+ );
46
+ ```
47
+
48
+ Source: [`packages/provider/google/src/google.ts`](src/google.ts)
49
+
50
+ </details>
51
+
52
+ <details>
53
+ <summary><code>POST</code> <b><code>google.v1.publishers.google.models.generateContent</code></b></summary>
54
+
55
+ <code>POST https://aiplatform.googleapis.com/v1/publishers/google/models/{model}:generateContent</code>
56
+
57
+ [Upstream docs ↗](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/express-mode/rest/v1/publishers.models/generateContent)
58
+
59
+ ```typescript
60
+ const res = await google.v1.publishers.google.models.generateContent(
61
+ "gemini-2.5-flash",
62
+ {
63
+ contents: [{ role: "user", parts: [{ text: "How does AI work?" }] }],
64
+ }
65
+ );
66
+ ```
67
+
68
+ Source: [`packages/provider/google/src/google.ts`](src/google.ts)
69
+
70
+ </details>
71
+
72
+ Part of the [apicity](https://github.com/justintanner/apicity) monorepo.
73
+
74
+ ## License
75
+
76
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,8 @@
1
+ export interface EndpointExample {
2
+ source: string;
3
+ payload: unknown;
4
+ }
5
+ declare const EXAMPLES: Record<string, EndpointExample>;
6
+ export default EXAMPLES;
7
+ export declare function attachExamples<T>(provider: T): T;
8
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,QAAA,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAsC7C,CAAC;AAEF,eAAe,QAAQ,CAAC;AAOxB,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CA6ChD"}
@@ -0,0 +1,123 @@
1
+ // Auto-generated by `pnpm run gen:examples` — do not edit by hand.
2
+ // Source: tests/recordings/<provider>_*/<test>_*/recording.har
3
+ //
4
+ // Each entry is the green-path payload for one endpoint, mined from a real
5
+ // integration-test recording. `attachExamples` walks the provider tree and
6
+ // hangs the matching entry off each endpoint function as `.example`.
7
+ const EXAMPLES = {
8
+ "POST v1.publishers.google.models.countTokens": {
9
+ "source": "google/count-tokens",
10
+ "payload": {
11
+ "contents": [
12
+ {
13
+ "role": "user",
14
+ "parts": [
15
+ {
16
+ "text": "Count the tokens in this short prompt."
17
+ }
18
+ ]
19
+ }
20
+ ]
21
+ }
22
+ },
23
+ "POST v1.publishers.google.models.generateContent": {
24
+ "source": "google/generate-content",
25
+ "payload": {
26
+ "contents": [
27
+ {
28
+ "role": "user",
29
+ "parts": [
30
+ {
31
+ "text": "Say hello in one short sentence."
32
+ }
33
+ ]
34
+ }
35
+ ],
36
+ "generationConfig": {
37
+ "temperature": 0,
38
+ "thinkingConfig": {
39
+ "thinkingBudget": 0
40
+ },
41
+ "maxOutputTokens": 32
42
+ }
43
+ }
44
+ }
45
+ };
46
+ export default EXAMPLES;
47
+ // Walks each "<METHOD> <dotPath>" key onto the provider's tree. Tries the
48
+ // standard `provider.<method>.<dotPath>` shape first, then a few fallbacks
49
+ // to cover providers with non-standard layouts (fal's `.run.` namespace,
50
+ // kie's sub-providers, `free`'s flat root). Returns the same provider for
51
+ // drop-in use as `return attachExamples({ ... });`.
52
+ export function attachExamples(provider) {
53
+ const root = provider;
54
+ const HTTP_KEYS = new Set(["post", "get", "put", "delete", "patch", "head"]);
55
+ for (const [key, example] of Object.entries(EXAMPLES)) {
56
+ const sp = key.indexOf(" ");
57
+ if (sp < 0)
58
+ continue;
59
+ const method = key.slice(0, sp).toLowerCase();
60
+ const segs = key.slice(sp + 1).split(".");
61
+ const candidates = [
62
+ root[method],
63
+ root[method]?.run,
64
+ root,
65
+ ];
66
+ if (segs.length > 1) {
67
+ const sub = root[segs[0]];
68
+ if (sub && typeof sub === "object") {
69
+ const subMethod = sub[method];
70
+ if (subMethod)
71
+ candidates.push({ __nested: subMethod, __segs: segs.slice(1) });
72
+ }
73
+ }
74
+ let attached = false;
75
+ for (const c of candidates) {
76
+ const fn = walkToFn(c, segs);
77
+ if (fn) {
78
+ Object.assign(fn, { example });
79
+ attached = true;
80
+ break;
81
+ }
82
+ }
83
+ if (attached)
84
+ continue;
85
+ for (const k of Object.keys(root)) {
86
+ if (HTTP_KEYS.has(k))
87
+ continue;
88
+ if (!segs.includes(k))
89
+ continue;
90
+ const sub = root[k];
91
+ if (!sub || typeof sub !== "object")
92
+ continue;
93
+ const subMethod = sub[method];
94
+ if (!subMethod)
95
+ continue;
96
+ const fn = walkToFn(subMethod, segs);
97
+ if (fn) {
98
+ Object.assign(fn, { example });
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ return provider;
104
+ }
105
+ function walkToFn(start, segs) {
106
+ if (start && typeof start === "object" && "__nested" in start) {
107
+ const wrapper = start;
108
+ return walkToFn(wrapper.__nested, wrapper.__segs);
109
+ }
110
+ let cur = start;
111
+ for (const seg of segs) {
112
+ if (cur === null || cur === undefined)
113
+ return null;
114
+ const t = typeof cur;
115
+ if (t !== "object" && t !== "function")
116
+ return null;
117
+ cur = cur[seg];
118
+ }
119
+ return typeof cur === "function"
120
+ ? cur
121
+ : null;
122
+ }
123
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/example.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,qEAAqE;AAOrE,MAAM,QAAQ,GAAoC;IAChD,8CAA8C,EAAE;QAC9C,QAAQ,EAAE,qBAAqB;QAC/B,SAAS,EAAE;YACT,UAAU,EAAE;gBACV;oBACE,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE;wBACP;4BACE,MAAM,EAAE,wCAAwC;yBACjD;qBACF;iBACF;aACF;SACF;KACF;IACD,kDAAkD,EAAE;QAClD,QAAQ,EAAE,yBAAyB;QACnC,SAAS,EAAE;YACT,UAAU,EAAE;gBACV;oBACE,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE;wBACP;4BACE,MAAM,EAAE,kCAAkC;yBAC3C;qBACF;iBACF;aACF;YACD,kBAAkB,EAAE;gBAClB,aAAa,EAAE,CAAC;gBAChB,gBAAgB,EAAE;oBAChB,gBAAgB,EAAE,CAAC;iBACpB;gBACD,iBAAiB,EAAE,EAAE;aACtB;SACF;KACF;CACF,CAAC;AAEF,eAAe,QAAQ,CAAC;AAExB,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,oDAAoD;AACpD,MAAM,UAAU,cAAc,CAAI,QAAW;IAC3C,MAAM,IAAI,GAAG,QAAmC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IA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AI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,UAAU;YAAE,OAAO,IAAI,CAAC;QACpD,GAAG,GAAI,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,GAAG,KAAK,UAAU;QAC9B,CAAC,CAAE,GAAuC;QAC1C,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GoogleOptions, GoogleProvider } from "./types";
2
+ export declare function createGoogle(opts: GoogleOptions): GoogleProvider;
3
+ //# sourceMappingURL=google.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/google.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,aAAa,EACb,cAAc,EACf,MAAM,SAAS,CAAC;AA0CjB,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,cAAc,CA2GhE"}
@@ -0,0 +1,95 @@
1
+ import { GoogleError } from "./types.js";
2
+ import { GoogleCountTokensRequestSchema, GoogleGenerateContentRequestSchema, } from "./zod.js";
3
+ import { attachExamples } from "./example.js";
4
+ function isGoogleErrorBody(value) {
5
+ return (typeof value === "object" &&
6
+ value !== null &&
7
+ "error" in value &&
8
+ typeof value.error === "object");
9
+ }
10
+ function attachAbortHandler(signal, controller) {
11
+ if (signal.aborted) {
12
+ controller.abort();
13
+ return;
14
+ }
15
+ signal.addEventListener("abort", () => controller.abort(), { once: true });
16
+ }
17
+ function formatErrorMessage(status, body) {
18
+ if (isGoogleErrorBody(body) && body.error?.message) {
19
+ return `Google API error ${status}: ${body.error.message}`;
20
+ }
21
+ return `Google API error: ${status}`;
22
+ }
23
+ export function createGoogle(opts) {
24
+ const baseURL = opts.baseURL ?? "https://aiplatform.googleapis.com/v1";
25
+ const normalizedBaseURL = baseURL.replace(/\/+$/, "");
26
+ const doFetch = opts.fetch ?? fetch;
27
+ const timeout = opts.timeout ?? 30000;
28
+ async function makeRequest(path, body, signal) {
29
+ const controller = new AbortController();
30
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
31
+ if (signal) {
32
+ attachAbortHandler(signal, controller);
33
+ }
34
+ try {
35
+ const res = await doFetch(`${normalizedBaseURL}${path}`, {
36
+ method: "POST",
37
+ headers: {
38
+ "Content-Type": "application/json",
39
+ "x-goog-api-key": opts.apiKey,
40
+ },
41
+ body: JSON.stringify(body),
42
+ signal: controller.signal,
43
+ });
44
+ clearTimeout(timeoutId);
45
+ if (!res.ok) {
46
+ let resBody = null;
47
+ try {
48
+ resBody = await res.json();
49
+ }
50
+ catch {
51
+ // ignore parse errors
52
+ }
53
+ throw new GoogleError(formatErrorMessage(res.status, resBody), res.status, resBody, isGoogleErrorBody(resBody) ? resBody.error?.status : undefined);
54
+ }
55
+ return (await res.json());
56
+ }
57
+ catch (error) {
58
+ clearTimeout(timeoutId);
59
+ if (error instanceof GoogleError)
60
+ throw error;
61
+ throw new GoogleError(`Google request failed: ${error}`, 500);
62
+ }
63
+ }
64
+ const postV1 = {
65
+ publishers: {
66
+ google: {
67
+ models: {
68
+ // sig-ok: aiplatform service host omitted from provider namespace
69
+ // POST https://aiplatform.googleapis.com/v1/publishers/google/models/{model}:countTokens
70
+ // Docs: https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/express-mode/rest/v1/publishers.models/countTokens
71
+ countTokens: Object.assign(async (model, req, signal) => {
72
+ return makeRequest(`/publishers/google/models/${encodeURIComponent(model)}:countTokens`, req, signal);
73
+ }, {
74
+ schema: GoogleCountTokensRequestSchema,
75
+ }),
76
+ // sig-ok: aiplatform service host omitted from provider namespace
77
+ // POST https://aiplatform.googleapis.com/v1/publishers/google/models/{model}:generateContent
78
+ // Docs: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/express-mode/rest/v1/publishers.models/generateContent
79
+ generateContent: Object.assign(async (model, req, signal) => {
80
+ return makeRequest(`/publishers/google/models/${encodeURIComponent(model)}:generateContent`, req, signal);
81
+ }, {
82
+ schema: GoogleGenerateContentRequestSchema,
83
+ }),
84
+ },
85
+ },
86
+ },
87
+ };
88
+ return attachExamples({
89
+ v1: postV1,
90
+ post: {
91
+ v1: postV1,
92
+ },
93
+ });
94
+ }
95
+ //# sourceMappingURL=google.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAStC,OAAO,EACL,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAU3C,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAO,IAAI,KAAK;QAChB,OAAQ,KAA6B,CAAC,KAAK,KAAK,QAAQ,CACzD,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAmB,EACnB,UAA2B;IAE3B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc,EAAE,IAAa;IACvD,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,oBAAoB,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,qBAAqB,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,I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ACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { createGoogle } from "./google";
2
+ export { GoogleError } from "./types";
3
+ export type { GoogleProvider, GooglePostNamespace, GooglePostV1Namespace, GooglePostV1PublishersNamespace, GooglePostV1PublishersGoogleNamespace, GooglePostV1PublishersGoogleModelsNamespace, GoogleCountTokensMethod, GoogleCountTokensResponse, GoogleGenerateContentMethod, GoogleGenerateContentResponse, GoogleCandidate, GoogleModalityTokenCount, GooglePromptFeedback, GoogleUsageMetadata, } from "./types";
4
+ export type { GoogleOptions, GoogleBlob, GoogleFileData, GoogleFunctionCall, GoogleFunctionResponse, GooglePart, GoogleContent, GoogleSafetySetting, GoogleGenerationConfig, GoogleFunctionDeclaration, GoogleTool, GoogleToolConfig, GoogleGenerateContentRequest, GoogleCountTokensRequest, } from "./zod";
5
+ export { GoogleOptionsSchema, GoogleBlobSchema, GoogleFileDataSchema, GoogleFunctionCallSchema, GoogleFunctionResponseSchema, GooglePartSchema, GoogleContentSchema, GoogleSafetySettingSchema, GoogleGenerationConfigSchema, GoogleFunctionDeclarationSchema, GoogleToolSchema, GoogleToolConfigSchema, GoogleGenerateContentRequestSchema, GoogleCountTokensRequestSchema, } from "./zod";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,+BAA+B,EAC/B,qCAAqC,EACrC,2CAA2C,EAC3C,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,EAC7B,eAAe,EACf,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,aAAa,EACb,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,4BAA4B,EAC5B,+BAA+B,EAC/B,gBAAgB,EAChB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createGoogle } from "./google.js";
2
+ export { GoogleError } from "./types.js";
3
+ export { GoogleOptionsSchema, GoogleBlobSchema, GoogleFileDataSchema, GoogleFunctionCallSchema, GoogleFunctionResponseSchema, GooglePartSchema, GoogleContentSchema, GoogleSafetySettingSchema, GoogleGenerationConfigSchema, GoogleFunctionDeclarationSchema, GoogleToolSchema, GoogleToolConfigSchema, GoogleGenerateContentRequestSchema, GoogleCountTokensRequestSchema, } from "./zod.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAoCtC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,4BAA4B,EAC5B,+BAA+B,EAC/B,gBAAgB,EAChB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,OAAO,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { z } from "zod";
2
+ import type { GoogleCountTokensRequest, GoogleGenerateContentRequest } from "./zod";
3
+ export type { GoogleOptions, GoogleBlob, GoogleFileData, GoogleFunctionCall, GoogleFunctionResponse, GooglePart, GoogleContent, GoogleSafetySetting, GoogleGenerationConfig, GoogleFunctionDeclaration, GoogleTool, GoogleToolConfig, GoogleGenerateContentRequest, GoogleCountTokensRequest, } from "./zod";
4
+ export declare class GoogleError extends Error {
5
+ readonly status: number;
6
+ readonly body: unknown;
7
+ readonly code?: string;
8
+ constructor(message: string, status: number, body?: unknown, code?: string);
9
+ }
10
+ export interface GoogleCandidate {
11
+ content?: import("./zod").GoogleContent;
12
+ finishReason?: string;
13
+ safetyRatings?: Array<Record<string, unknown>>;
14
+ citationMetadata?: Record<string, unknown>;
15
+ groundingMetadata?: Record<string, unknown>;
16
+ avgLogprobs?: number;
17
+ index?: number;
18
+ logprobsResult?: Record<string, unknown>;
19
+ }
20
+ export interface GooglePromptFeedback {
21
+ blockReason?: string;
22
+ safetyRatings?: Array<Record<string, unknown>>;
23
+ blockReasonMessage?: string;
24
+ }
25
+ export interface GoogleUsageMetadata {
26
+ promptTokenCount?: number;
27
+ candidatesTokenCount?: number;
28
+ totalTokenCount?: number;
29
+ cachedContentTokenCount?: number;
30
+ thoughtsTokenCount?: number;
31
+ [key: string]: unknown;
32
+ }
33
+ export interface GoogleGenerateContentResponse {
34
+ candidates?: GoogleCandidate[];
35
+ promptFeedback?: GooglePromptFeedback;
36
+ usageMetadata?: GoogleUsageMetadata;
37
+ modelVersion?: string;
38
+ responseId?: string;
39
+ [key: string]: unknown;
40
+ }
41
+ export interface GoogleModalityTokenCount {
42
+ modality?: string;
43
+ tokenCount?: number;
44
+ [key: string]: unknown;
45
+ }
46
+ export interface GoogleCountTokensResponse {
47
+ totalTokens?: number;
48
+ totalBillableCharacters?: number;
49
+ promptTokensDetails?: GoogleModalityTokenCount[];
50
+ [key: string]: unknown;
51
+ }
52
+ export interface GoogleGenerateContentMethod {
53
+ (model: string, req: GoogleGenerateContentRequest, signal?: AbortSignal): Promise<GoogleGenerateContentResponse>;
54
+ schema: z.ZodType<GoogleGenerateContentRequest>;
55
+ }
56
+ export interface GoogleCountTokensMethod {
57
+ (model: string, req: GoogleCountTokensRequest, signal?: AbortSignal): Promise<GoogleCountTokensResponse>;
58
+ schema: z.ZodType<GoogleCountTokensRequest>;
59
+ }
60
+ export interface GooglePostV1PublishersGoogleModelsNamespace {
61
+ countTokens: GoogleCountTokensMethod;
62
+ generateContent: GoogleGenerateContentMethod;
63
+ }
64
+ export interface GooglePostV1PublishersGoogleNamespace {
65
+ models: GooglePostV1PublishersGoogleModelsNamespace;
66
+ }
67
+ export interface GooglePostV1PublishersNamespace {
68
+ google: GooglePostV1PublishersGoogleNamespace;
69
+ }
70
+ export interface GooglePostV1Namespace {
71
+ publishers: GooglePostV1PublishersNamespace;
72
+ }
73
+ export interface GooglePostNamespace {
74
+ v1: GooglePostV1Namespace;
75
+ }
76
+ export interface GoogleProvider {
77
+ v1: GooglePostV1Namespace;
78
+ post: GooglePostNamespace;
79
+ }
80
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,aAAa,EACb,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,OAAO,CAAC;AAEf,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC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M,WAAW,mBAAmB;IAClC,EAAE,EAAE,qBAAqB,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,qBAAqB,CAAC;IAC1B,IAAI,EAAE,mBAAmB,CAAC;CAC3B"}
@@ -0,0 +1,13 @@
1
+ export class GoogleError extends Error {
2
+ status;
3
+ body;
4
+ code;
5
+ constructor(message, status, body, code) {
6
+ super(message);
7
+ this.name = "GoogleError";
8
+ this.status = status;
9
+ this.body = body ?? null;
10
+ this.code = code;
11
+ }
12
+ }
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAuBA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,MAAM,CAAS;IACf,IAAI,CAAU;IACd,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAc,EAAE,IAAc,EAAE,IAAa;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}