OllamaYarpProxy is an ASP.NET Core reverse proxy that emulates Ollama's API endpoints and transparently forwards requests to a configurable backend (default: http://localhost:4000). It uses YARP (Yet Another Reverse Proxy) and custom transforms to rewrite paths and adapt responses, enabling compatibility with clients expecting Ollama's API.
- Ollama API Compatibility: Exposes endpoints like
/api/tags,/api/show,/api/version, and/v1/chat/completions, rewriting and transforming requests/responses as needed. - Configurable Backend: Forwards requests to a backend server, configurable via
appsettings.json. - Custom Transforms: Uses YARP's transform pipeline to rewrite paths and adapt JSON schemas for Ollama compatibility.
- Logging: Logs incoming requests, proxy destinations, and errors for easier debugging.
- Solves vscode-copilot-release#7518: Enables Copilot and similar tools to interact with Ollama-compatible endpoints even when the backend differs.
- Build and run the project:
dotnet run --project src/OllamaYarpProject
- Access the proxy:
By default, it listens onhttp://localhost:11434and forwards requests tohttp://localhost:4000.
- Backend URL:
Change the backend target inappsettings.jsonunder theReverseProxysection. - Logging:
Logging is controlled viaappsettings.jsonor environment variables.
/api/tags→/models(rewritten and response schema adapted)/api/show→ Returns model info in Ollama format/api/version→ Returns Ollama-compatible version info/v1/chat/completions→/chat/completions(rewritten)- All other endpoints are proxied as-is
This proxy allows tools (like Copilot) that expect Ollama's API to work with alternative backends, solving integration issues such as vscode-copilot-release#7518.