@typochat-sdk/core
v0.1.2
Published
Proxy-aware `fetch` wrapper for routing AI API requests through a centralized proxy. Strips provider API keys from the client and authenticates via your proxy token.
Readme
@typochat-sdk/core
Proxy-aware fetch wrapper for routing AI API requests through a centralized proxy. Strips provider API keys from the client and authenticates via your proxy token.
Installation
npm install @typochat-sdk/coreUsage
import { createProxyFetch } from "@typochat-sdk/core";
const proxyFetch = createProxyFetch({
proxyUrl: "https://your-proxy.example.com",
apiKey: "tmk_xxxxx",
});The returned proxyFetch is a drop-in replacement for fetch. Pass it to any AI SDK that accepts a custom fetch.
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { createProxyFetch } from "@typochat-sdk/core";
const proxyFetch = createProxyFetch({
proxyUrl: "https://your-proxy.example.com",
apiKey: "tmk_xxxxx",
});
const google = createGoogleGenerativeAI({
apiKey: "proxy-managed",
fetch: proxyFetch,
});
const model = google("gemini-3.1-flash-lite-preview");Google Vertex
import { createVertex } from "@ai-sdk/google-vertex/edge";
import { createProxyFetch } from "@typochat-sdk/core";
const proxyFetch = createProxyFetch({
proxyUrl: "https://your-proxy.example.com",
apiKey: "tmk_xxxxx", // express mode
});
const vertex = createVertex({
apiKey: "proxy-managed",
fetch: proxyFetch,
});
const model = vertex("gemini-3.1-flash-lite-preview");What it does
- Rewrites request URLs to route through your proxy
- Strips sensitive headers (
Authorization,x-goog-api-key) so provider keys never leave the server - Adds proxy authentication automatically
- Supports streaming via
duplex: "half"
API
createProxyFetch(config): typeof fetch
| Parameter | Type | Description |
|-----------|------|-------------|
| config.proxyUrl | string | Base URL of your proxy |
| config.apiKey | string | Proxy authentication token |
getBaseUrl(proxyUrl?): string
Resolves the proxy base URL.
License
MIT
