Skip to content

Kirow/OpenRouterXcodeProxy

Repository files navigation

OpenRouter Proxy for Xcode 26 Beta

This project creates a proxy for OpenRouter that modifies API responses to work with Xcode 26 beta as a model provider. The proxy transforms OpenRouter responses to match OpenAI's format, which is required by Xcode's native AI integration.

Features

  • /models endpoint returns models in OpenAI format
  • /chat/completions endpoint proxies requests directly to OpenRouter
  • Containerized with Docker
  • Standalone pre-compiled executable

Setup

Docker Deployment

Option 1: Docker Compose (Recommended)

  1. Create docker-compose.yml (already created in project)
  2. Start the service:
docker-compose up

To use a different host port (e.g., 9090):

HOST_PORT=9090 docker-compose up

Option 2: Manual Docker Commands

  1. Build the Docker image:
docker build -t openrouter-proxy ./proxy
  1. Run the container:
docker run --rm -p ${HOST_PORT:-8080}:8080 openrouter-proxy

Standalone Executable Deployment

  1. Make the build script executable:
chmod +x build_executable.sh
  1. Build the standalone executable:
./build_executable.sh
  1. Run the executable (default port 8080):
./proxy/dist/app

To run on a different port (e.g., 9090):

PORT=9090 ./proxy/dist/app

Environment Variables

  • DISABLE_SSL_VERIFY: Set to 'true' to disable SSL verification (useful for debugging with proxies like Charles). Default: SSL verification is enabled.
  • MODEL_FILTER_FILE: Set to the absolute path of a text file containing allowed model IDs (one per line). If set, the /v1/models endpoint will only return models whose IDs are in this file.

Xcode Setup

  • Setting > Intelligence > Add a Model Provider...

    • URL: http://localhost:8080
    • API Key: Bearer sk-...
    • API Key Header: Authorization
    • Description: OpenRouter
    Xcode Settings

Using with Proxyman (Debugging Proxy)

When using a debugging proxy like Proxyman, you might encounter SSL certificate verification errors. To resolve this:

  1. Set the DISABLE_SSL_VERIFY environment variable to true:
# For Docker Compose
DISABLE_SSL_VERIFY=true docker-compose up

# For standalone executable
DISABLE_SSL_VERIFY=true ./proxy/dist/app
  1. Trust Proxyman's root certificate in your system keychain (macOS):
    • Open Proxyman
    • Go to Certificate → Install Certificate on This Mac...
    • Follow prompts to add to System keychain
    • Open Keychain Access, find "Proxyman" certificate
    • Double-click it, expand Trust, and set "When using this certificate" to "Always Trust"

Important Security Note: Disabling SSL verification should only be done for debugging purposes. Never use this in production environments as it makes connections vulnerable to man-in-the-middle attacks.

Usage

  • Get models in OpenAI format: GET http://localhost:8080/models (include your OpenRouter API key in the Authorization header)
  • Use chat completions: POST http://localhost:8080/chat/completions with your request payload and Authorization header

About

OpenRouter API Proxy to allow usage as model provider in Xcode 26 beta

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published