Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { provider as bedrock } from './adapters/amazon-bedrock.ts'
4import { provider as azure } from './adapters/azure.ts'
5import { provider as workersAi } from './adapters/cloudflare-workers-ai.ts'
6import { provider as cohere } from './adapters/cohere.ts'
7import { provider as deepseek } from './adapters/deepseek.ts'
8import { provider as groq } from './adapters/groq.ts'
9import { provider as lovable } from './adapters/lovable.ts'
10import { provider as mistral } from './adapters/mistral.ts'
11import { provider as neon } from './adapters/neon.ts'
12import { provider as opencode } from './adapters/opencode.ts'
13import { provider as perplexity } from './adapters/perplexity.ts'
14import { provider as together } from './adapters/together.ts'
15import { provider as vercel } from './adapters/vercel.ts'
16
17/** Issue #558: every provider TanStack AI generates a client for declares its data plane. */
18describe('connect profiles', () => {
19 it.each([
20 [groq, 'https://api.groq.com', '/openai/v1/chat/completions'],
21 [mistral, 'https://api.mistral.ai', '/v1/chat/completions'],
22 [deepseek, 'https://api.deepseek.com', null],
23 [together, 'https://api.together.ai', '/v1/chat/completions'],
24 [perplexity, 'https://api.perplexity.ai', '/v1/sonar'],
25 [cohere, 'https://api.cohere.com', '/v2/chat'],
26 [opencode, 'https://opencode.ai', null],
27 [
28 workersAi,
29 'https://api.cloudflare.com/client/v4',
30 '/accounts/{account_id}/ai/run/@cf/meta/llama-3.1-8b-instruct',
31 ],
32 [vercel, 'https://ai-gateway.vercel.sh/v1', '/chat/completions'],
33 [lovable, 'https://ai.gateway.lovable.dev/v1', '/responses'],
34 [neon, 'https://{host}', '/v1/chat/completions'],
35 ])('$id is bearer-addressable', (provider, server, path) => {
36 expect(provider.connect?.servers[0]?.url).toBe(server)
37 expect(provider.connect?.security).toEqual([{ bearerAuth: [] }])
38 // The server plus a classified path is the route the client calls
39 // (DeepSeek and OpenCode classify by operation marker, not path).
40 if (path !== null) expect(provider.classify(path, {})).not.toBeNull()
41 })
42
43 it('azure takes an api-key header or an Entra bearer on the v1 resource host', () => {
44 const connect = azure.connect
45 expect(connect?.servers[0]?.url).toBe(
46 'https://{resource}.openai.azure.com/openai/v1',
47 )
48 expect(connect?.servers[0]?.variables?.resource?.default).toBeTruthy()
49 expect(connect?.securitySchemes.apiKey).toMatchObject({
50 type: 'apiKey',
51 in: 'header',
52 name: 'api-key',
53 })
54 expect(connect?.security).toEqual([{ apiKey: [] }, { bearerAuth: [] }])
55 })
56
57 it('bedrock is SigV4-signed, with the Bedrock API key as the alternative', () => {
58 const connect = bedrock.connect
59 expect(connect?.servers[0]).toMatchObject({
60 url: 'https://bedrock-runtime.{region}.amazonaws.com',
61 variables: { region: { default: 'us-east-1' } },
62 })
63 expect(connect?.securitySchemes.sigv4).toMatchObject({
64 type: 'apiKey',
65 in: 'header',
66 name: 'Authorization',
67 'x-amazon-apigateway-authtype': 'awsSigv4',
68 })
69 expect(connect?.security).toEqual([{ sigv4: [] }, { bearerAuth: [] }])
70 })
71})