@anvia/gemini 1.1.6 → 1.1.8

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.
Files changed (2) hide show
  1. package/README.md +23 -100
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,129 +1,52 @@
1
1
  # @anvia/gemini
2
2
 
3
- Gemini and Vertex AI provider adapter for Anvia.
3
+ Run Anvia agents and retrieval workflows with Gemini. Connect through the Gemini
4
+ API or Vertex AI using the same provider-neutral agent interfaces.
4
5
 
5
- Use this package when you want Anvia agents, extractors, pipelines, embeddings, image generation, or transcription to run on Google's Gemini APIs.
6
-
7
- ## Installation
6
+ ## Install
8
7
 
9
8
  ```sh
10
9
  pnpm add @anvia/gemini @anvia/core
11
10
  ```
12
11
 
13
- In this monorepo, the package is available through the workspace:
12
+ ## Quickstart
14
13
 
15
- ```sh
16
- pnpm --filter @anvia/gemini build
17
- ```
18
-
19
- ## Usage
14
+ Set `GEMINI_API_KEY` before running this example.
20
15
 
21
16
  ```ts
22
17
  import { Agent } from "@anvia/core";
23
18
  import { GeminiClient } from "@anvia/gemini";
24
19
 
25
20
  const client = new GeminiClient({
26
- apiKey,
21
+ apiKey: process.env.GEMINI_API_KEY!,
27
22
  });
28
-
29
- const model = client.completionModel({ modelId: "gemini-3.7-flash" });
30
-
31
23
  const agent = new Agent({
32
24
  id: "assistant",
33
- model: model,
25
+ model: client.completionModel({ modelId: "gemini-3.7-flash" }),
34
26
  instructions: "Answer clearly and concisely.",
35
27
  });
36
28
 
37
- const result = await agent.generate({ prompt: "Summarize Anvia in one sentence." });
38
- if (result.type === "response") console.log(result.output);
39
- ```
40
-
41
- ## Vertex AI
42
-
43
- Use the exclusive Vertex AI configuration with a Google Cloud project and location:
44
-
45
- ```ts
46
- import { GeminiClient } from "@anvia/gemini";
47
-
48
- const client = new GeminiClient({
49
- vertexAi: {
50
- projectId: "my-gcp-project",
51
- location: "us-central1",
52
- },
53
- });
54
-
55
- const model = client.completionModel({ modelId: "gemini-3.7-flash" });
56
- ```
57
-
58
- The Google SDK uses Application Default Credentials. For a service-account JSON file, set
59
- `GOOGLE_APPLICATION_CREDENTIALS` before starting the application:
60
-
61
- ```sh
62
- export GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/service-account.json"
63
- ```
64
-
65
- Trusted credential objects can also be passed explicitly:
66
-
67
- ```ts
68
- const client = new GeminiClient({
69
- vertexAi: {
70
- projectId: "my-gcp-project",
71
- location: "us-central1",
72
- googleAuthOptions: {
73
- credentials: serviceAccountJson,
74
- },
75
- },
29
+ const result = await agent.generate({
30
+ prompt: "What should I check before launching a new product?",
76
31
  });
77
- ```
78
-
79
- Validate externally supplied credential configurations before using them. Never commit credential
80
- JSON or service-account keys.
81
-
82
- ## Embeddings
83
-
84
- ```ts
85
- const embeddings = client.embeddingModel({ modelId: "gemini-embedding-2" });
86
- const vectors = await embeddings.embedTexts(["Anvia is a TypeScript AI runtime."]);
87
- ```
88
-
89
- ## Image Generation
90
-
91
- Choose the image API explicitly. Gemini native image models use `generateContent`; Imagen uses
92
- `generateImages`.
93
-
94
- ```ts
95
- import { GEMINI_2_5_FLASH_IMAGE, IMAGEN_4_GENERATE, GeminiClient } from "@anvia/gemini";
96
32
 
97
- const client = new GeminiClient({ apiKey });
98
-
99
- const nativeImageModel = client.imageGenerationModel({
100
- api: "generateContent",
101
- modelId: GEMINI_2_5_FLASH_IMAGE,
102
- });
103
- const imagenModel = client.imageGenerationModel({
104
- api: "generateImages",
105
- modelId: IMAGEN_4_GENERATE,
106
- });
33
+ if (result.type === "response") {
34
+ console.log(result.output);
35
+ }
107
36
  ```
108
37
 
109
- ## Exports
38
+ ## What you can build
110
39
 
111
- - `GeminiClient`
112
- - structural completion, embedding, image, and transcription handle types
113
- - Gemini model-ID types
114
- - `GEMINI_2_5_FLASH_IMAGE`
115
- - `GEMINI_3_1_FLASH_IMAGE`
116
- - `GEMINI_3_1_FLASH_LITE_IMAGE`
117
- - `GEMINI_3_PRO_IMAGE`
118
- - `IMAGEN_4_GENERATE`
119
- - `gemini`
40
+ - Streaming completions, tools, structured output, and typed reasoning controls.
41
+ - Embeddings with configurable task type and dimensions.
42
+ - Image generation through Gemini native models or Imagen.
43
+ - Transcription, model listing, and Vertex AI authentication.
120
44
 
121
- ## Development
45
+ For Vertex AI, pass `vertexAi: { projectId, location }` instead of `apiKey`.
46
+ The usage guide includes authentication and image API selection.
122
47
 
123
- ```sh
124
- pnpm --filter @anvia/gemini typecheck
125
- pnpm --filter @anvia/gemini test
126
- pnpm --filter @anvia/gemini build
127
- ```
48
+ ## Learn more
128
49
 
129
- Package-local `typecheck` and `build` scripts build `@anvia/core` first so core subpath types are available in a fresh worktree.
50
+ - [Usage guide](https://github.com/anvia-hq/anvia/blob/main/docs/packages/provider-gemini.md)
51
+ - [Anvia overview](https://github.com/anvia-hq/anvia/blob/main/README.md)
52
+ - [Contributing](https://github.com/anvia-hq/anvia/blob/main/CONTRIBUTING.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/gemini",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Gemini provider adapter for Anvia.",
5
5
  "author": "anvia",
6
6
  "license": "MIT",
@@ -25,17 +25,17 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@google/genai": "^2.24.0"
28
+ "@google/genai": "^2.29.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^24.9.1",
32
32
  "tsup": "^8.5.0",
33
33
  "typescript": "^5.9.3",
34
34
  "vitest": "^4.1.11",
35
- "@anvia/core": "1.5.0"
35
+ "@anvia/core": "1.14.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@anvia/core": "^1.5.0"
38
+ "@anvia/core": "^1.14.1"
39
39
  },
40
40
  "scripts": {
41
41
  "prebuild": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",