|  | 
|  | 1 | +import { GoogleGenAI } from '@google/genai' | 
|  | 2 | +import { describe, expect } from 'vitest' | 
|  | 3 | +import { test } from '../setup' | 
|  | 4 | + | 
|  | 5 | +describe('google', () => { | 
|  | 6 | + test('should call google via gateway', async ({ gateway }) => { | 
|  | 7 | + const { fetch, otelBatch } = gateway | 
|  | 8 | + | 
|  | 9 | + // The `authToken` is passed as `Authorization` header with the anthropic client. | 
|  | 10 | + const client = new GoogleGenAI({ | 
|  | 11 | + apiKey: 'healthy', | 
|  | 12 | + httpOptions: { baseUrl: 'https://example.com/google-vertex' }, | 
|  | 13 | + }) | 
|  | 14 | + | 
|  | 15 | + const response = await client.models.generateContent({ | 
|  | 16 | + model: 'gemini-2.5-flash', | 
|  | 17 | + contents: 'What is the capital of france?', | 
|  | 18 | + config: { maxOutputTokens: 1024, topP: 0.95, topK: 1, temperature: 0.5, stopSequences: ['potato'] }, | 
|  | 19 | + }) | 
|  | 20 | + | 
|  | 21 | + expect(response).toMatchSnapshot('llm') | 
|  | 22 | + expect(otelBatch, 'otelBatch length not 1').toHaveLength(1) | 
|  | 23 | + expect(JSON.parse(otelBatch[0]!).resourceSpans?.[0].scopeSpans?.[0].spans?.[0]?.attributes).toMatchSnapshot('span') | 
|  | 24 | + }) | 
|  | 25 | +}) | 
0 commit comments