Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"_": "@cloudflare/vitest-pool-workers is pinned because of https://github.com/cloudflare/workers-sdk/issues/10506",
"devDependencies": {
"@anthropic-ai/vertex-sdk": "^0.13.2",
"@cloudflare/vitest-pool-workers": "0.8.44",
"@cloudflare/workers-types": "^4.20250712.0",
"groq-sdk": "^0.30.0",
Expand Down
17 changes: 8 additions & 9 deletions deploy/test.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { env } from 'cloudflare:workers'
import type { Config } from '@deploy/types'

type ProviderKeys = 'openai' | 'groq'
type ProviderKeys = 'openai' | 'groq' | 'google'

export const config: Config<ProviderKeys> = {
// the name of the organization, doesn't matter in this case
Expand Down Expand Up @@ -45,13 +45,12 @@ export const config: Config<ProviderKeys> = {
injectCost: true,
credentials: env.GROQ_API_KEY,
},
// google: {
// baseUrl:
// 'https://us-central1-aiplatform.googleapis.com/v1beta1/projects/{gcp-project-name}/locations/us-central1/publishers/google/models',
// providerId: 'google',
// injectCost: true,
// credentials: env.GOOGLE_SERVICE_ACCOUNT_KEY,
// },
google: {
baseUrl: 'http://localhost:8005/google',
providerID: 'google-vertex',
injectCost: true,
credentials: env.GOOGLE_SERVICE_ACCOUNT_KEY,
},
},
// individual apiKeys
apiKeys: {
Expand All @@ -61,7 +60,7 @@ export const config: Config<ProviderKeys> = {
// user is optional
user: 'testberto',
// providers is required and identifies which providers this apiKey is allowed to use
providers: ['openai', 'groq'],
providers: ['openai', 'groq', 'google'],
// you can also optionally add limits to a single key here
spendingLimitDaily: 1,
spendingLimitWeekly: 5,
Expand Down
22 changes: 22 additions & 0 deletions deploy/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import OpenAI from 'openai'
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk'
import { GoogleAuth } from 'google-auth-library'

import Groq from 'groq-sdk'
import { SELF, env, fetchMock } from 'cloudflare:test'
import { describe, it, expect, beforeAll, afterEach, beforeEach } from 'vitest'
Expand Down Expand Up @@ -115,3 +118,22 @@ describe('groq', () => {
expect(completion).toMatchSnapshot('llm')
})
})

describe('anthropic', () => {
it('should call anthropic via gateway', async () => {
const client = new AnthropicVertex({
baseURL: 'https://example.com/anthropic',
fetch: SELF.fetch.bind(SELF),
googleAuth: new GoogleAuth({
apiKey: 'o-QBrunFudqD99879C5jkFZgZrueCLlCJGSMAbzFGFY',
}),
})

const completion = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: 'What is the capital of France?' }],
})
expect(completion).toMatchSnapshot('llm')
})
})
3 changes: 2 additions & 1 deletion deploy/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ export default defineWorkersConfig({
poolOptions: {
workers: {
wrangler: {
isolatedStorage: true,
Copy link
Member Author

@Kludex Kludex Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it seems this is true by default.

configPath: './wrangler.jsonc',
},
miniflare: {
bindings: {
// put variables here
OPENAI_API_KEY: `${process.env.OPENAI_API_KEY}`,
GROQ_API_KEY: `${process.env.GROQ_API_KEY}`,
GOOGLE_SERVICE_ACCOUNT_KEY: `${process.env.GOOGLE_SERVICE_ACCOUNT_KEY}`,
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proxy-vcr/proxy_vcr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

OPENAI_BASE_URL = 'https://api.openai.com/v1/'
GROQ_BASE_URL = 'https://api.groq.com'
GOOGLE_VERTEX_BASE_URL = 'https://us-central1-aiplatform.googleapis.com/v1beta1/projects/pydantic-ai/locations/us-central1/publishers/google/models'

current_file_dir = pathlib.Path(__file__).parent

Expand Down
Loading