This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an LLM bridge/proxy library that provides a universal interface for multiple AI providers (OpenAI, Anthropic, Google). It translates between different provider formats and a common universal format, enabling seamless switching between providers while maintaining observability and request modification capabilities.
The codebase follows a modular architecture with clear separation of concerns:
src/handler.ts: Main entry point containinghandleUniversalRequest()- the core function that orchestrates request processingsrc/models/: Contains the translation layer between provider formats and universal formatdetector.ts: Detects which provider is being used based on URL/bodytranslate.ts: Main translation functionstoUniversal()andfromUniversal()*-format/directories: Provider-specific translation implementationshelpers.ts: Token counting and observability utilities
src/types/: TypeScript type definitionsuniversal.ts: Core universal format types (UniversalBody,UniversalMessage, etc.)providers.ts: Provider-specific type definitionsobservability.ts: Observability and metrics types
src/helpers/: Utility functions for request processingsrc/errors/: Custom error definitions
- Universal Format: A common format that abstracts away provider differences
- Provider Translation: Bidirectional conversion between provider formats and universal format
- Observability: Token counting and metrics collection for request analysis
- Request Modification: Supports an
editFunctionparameter to modify requests before forwarding
# Install dependencies
pnpm install
# Build the library
pnpm run build
# Build without type declaration files (faster)
pnpm run build-fast
# Run tests
pnpm run test
# Run tests with Vitest
vitest run- Uses Vitest for testing
- Test files are located in
test/directory - Run single test files with
vitest run test/filename.test.ts - No additional test configuration files present
- Uses
tsupfor building with both CommonJS and ESM outputs - TypeScript configuration supports both module formats
- Main entry point:
src/index.ts - Built files output to
dist/directory