A maintainable Go-based proxy for LLMs that allows JetBrains IDEs to communicate with various AI providers using the Ollama API format.
go-llm-proxy/
โโโ bin/ # Compiled binaries
โ โโโ llm-proxy
โ โโโ llm-proxy-linux
โ โโโ llm-proxy-macos
โ โโโ llm-proxy-windows.exe
โโโ cmd/llm-proxy/ # Main application entry point
โ โโโ main.go
โโโ internal/ # Internal packages
โ โโโ config/ # Configuration management
โ โ โโโ config.go
โ โโโ models/ # Model registry and management
โ โ โโโ models.go
โ โโโ backend/ # Backend abstraction layer
โ โ โโโ backend.go
โ โโโ proxy/ # Main proxy server logic
โ โ โโโ proxy.go
โ โโโ streaming/ # Streaming response handling
โ โ โโโ streaming.go
โ โโโ types/ # Shared type definitions
โ โโโ types.go
โโโ pkg/ # Public packages
โ โโโ anthropic/ # Anthropic Claude integration
โ โ โโโ anthropic_backend.go
โ โโโ openai/ # OpenAI GPT integration
โ โโโ openai_backend.go
โโโ test/ # Test files
โ โโโ unit/ # Unit tests
โ โ โโโ config_test.go
โ โ โโโ model_management_test.go
โ โ โโโ ollama_api_test.go
โ โ โโโ proxy_test.go
โ โโโ integration/ # Integration tests
โ โโโ integration_test.go
โโโ scripts/ # Build and utility scripts
โ โโโ setup.sh
โ โโโ test_proxy.sh
โโโ examples/ # Usage examples
โ โโโ main.go
โโโ docs/ # Documentation
โ โโโ README.md
โ โโโ TEST_SUMMARY.md
โโโ .env.example # Environment variables template
โโโ go.mod # Go module definition
โโโ go.sum # Go module checksums
โโโ Makefile # Build automation
- Go 1.21 or later
- API keys for Anthropic and/or OpenAI
-
Clone the repository:
git clone <repository-url> cd go-llm-proxy
-
Install dependencies:
make deps
-
Set up environment variables:
cp .env.example .env # Edit .env with your API keys -
Build the proxy:
make build
-
Run the proxy:
./bin/llm-proxy
# Build for current platform
make build
# Build for all platforms
make build-all
# Clean build artifacts
make clean# Run the built binary
./bin/llm-proxy
# Or run directly without building
make run# Run all tests
make test
# Run with verbose output
make test-verbose
# Run with coverage
make test-coverage
# Run specific test suites
make test-api # API compatibility tests
make test-integration # Integration tests
make test-models # Model management tests
make test-config # Configuration testsThe main source files are organized as follows:
cmd/llm-proxy/main.go- Main application entry point
internal/types/types.go- Shared type definitions and interfacesinternal/config/config.go- Configuration managementinternal/models/models.go- Model registry and managementinternal/backend/backend.go- Backend abstraction layerinternal/proxy/proxy.go- Main proxy server logicinternal/streaming/streaming.go- Streaming response handling
pkg/anthropic/anthropic_backend.go- Anthropic Claude integrationpkg/openai/openai_backend.go- OpenAI GPT integration
All test files are organized by type:
config_test.go- Configuration testsmodel_management_test.go- Model management testsollama_api_test.go- Ollama API compatibility testsproxy_test.go- Basic proxy tests
integration_test.go- End-to-end integration tests
The project includes comprehensive tests:
- Unit Tests - Individual component testing
- Integration Tests - End-to-end workflow testing
- API Compatibility Tests - Ollama API compliance verification
- Model Management Tests - Model registry functionality
- Configuration Tests - Environment variable handling
See TEST_SUMMARY.md for detailed test documentation.
The proxy can be configured via environment variables:
# Server configuration
PORT=11434
GIN_MODE=release
# API Keys
ANTHROPIC_API_KEY=your_anthropic_key_here
OPENAI_API_KEY=your_openai_key_here
# Model configuration
DEFAULT_MAX_TOKENS=4096
STREAMING_CHUNK_SIZE=3
STREAMING_DELAY_MS=50- Ollama API Compatibility - Full compatibility with Ollama API format
- JetBrains IDE Support - Works seamlessly with GoLand AI Assistant
- Multi-Backend Support - Anthropic and OpenAI backends
- Streaming Support - Both streaming and non-streaming responses
- Dynamic Model Fetching - Automatically discovers models from APIs at startup
- CORS Support - Cross-origin request handling
- Comprehensive Testing - Full test coverage
README.md- This file (main documentation)TEST_SUMMARY.md- Comprehensive test documentationexamples/main.go- Usage examplesscripts/- Build and utility scripts
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite:
make test - Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the documentation
- Run the test suite to verify setup
- Check the logs for error messages
- Open an issue on GitHub