Skip to content

@chinmaymk/aikit v0.0.40


@chinmaymk/aikit / createProxyProvider

Function: createProxyProvider()

createProxyProvider(providerType, options): StreamingGenerateFunction<Record<string, unknown>>

Defined in: providers/proxy.ts:55

Creates a proxy provider that forwards requests to a backend server

Parameters

providerType

GenerationProviderType

The AI provider type to use

options

Record<string, unknown>

Combined proxy configuration and provider options. baseURL is required.

Returns

StreamingGenerateFunction<Record<string, unknown>>

A streaming generate function that works with the specified provider

Example

typescript
// Create OpenAI proxy
const openaiProxy = createProxy('openai', {
  baseURL: 'http://localhost:3000',
  model: 'gpt-4o',
  temperature: 0.7
});

// Create Anthropic proxy
const anthropicProxy = createProxy('anthropic', {
  baseURL: 'http://localhost:3000',
  model: 'claude-3-5-sonnet-20241022'
});

// Use the proxy
const stream = openaiProxy([userText('Hello world!')]);
for await (const chunk of stream) {
  console.log(chunk.delta);
}

Released under the MIT License.