Skip to main content
The Ollama API Proxy uses environment variables to configure API keys, server settings, and behavior. You can set these variables in a .env file in your project root or export them in your shell.

Required Variables

At least one API provider key must be configured for the proxy to start.
OPENAI_API_KEY
string
API key for OpenAI provider. Required if you want to use OpenAI models like gpt-4o, gpt-4o-mini, etc.
OPENAI_API_KEY=sk-proj-...
The proxy will initialize the OpenAI provider only if this key is set (src/index.js:104-106).
GEMINI_API_KEY
string
API key for Google’s Gemini provider. Required if you want to use Gemini models like gemini-2.5-flash.
GEMINI_API_KEY=AIzaSy...
The proxy will initialize the Google provider only if this key is set (src/index.js:107-109).
OPENROUTER_API_KEY
string
API key for OpenRouter provider. Required if you want to use OpenRouter models like deepseek-r1.
OPENROUTER_API_KEY=sk-or-v1-...
The proxy will initialize the OpenRouter provider only if this key is set (src/index.js:110-117).
If no API keys are configured, the proxy will fail to start with the error:
❌ No API keys found. Set OPENAI_API_KEY, GEMINI_API_KEY, or OPENROUTER_API_KEY
This check occurs at src/index.js:119-122.

Optional Variables

PORT
number
default:"11434"
Port number for the HTTP server. Defaults to 11434 to match Ollama’s default port.
PORT=3000
The server will start on http://localhost:PORT (src/index.js:20).
OPENROUTER_API_URL
string
default:"https://openrouter.ai/api/v1"
Custom base URL for OpenRouter API. Only used if OPENROUTER_API_KEY is set.
OPENROUTER_API_URL=https://openrouter.ai/api/v1
Useful for testing or using alternative OpenRouter endpoints (src/index.js:113).
NODE_ENV
string
default:"development"
Node environment setting. When set to production, timestamps are disabled in console logs.
NODE_ENV=production
This affects the ColorConsole timestamp behavior (src/index.js:15).

Example Configuration

Create a .env file in your project root:
PORT=11434
OPENAI_API_KEY=sk-proj-...
GEMINI_API_KEY=AIzaSy...
OPENROUTER_API_KEY=sk-or-v1-...
NODE_ENV=production

Loading Environment Variables

The proxy automatically loads environment variables using dotenv at startup (src/index.js:18). Make sure your .env file is in the same directory where you run the proxy.
Environment variables set in your shell will override values in the .env file.

Verification

When the proxy starts successfully, you’ll see which providers are initialized:
🚀 Ollama Proxy with Streaming running on http://localhost:11434
🔑 Providers: openai, google, openrouter
📋 Available models: gpt-4o-mini, gemini-2.5-flash, deepseek-r1
This output confirms which API keys were detected and which providers are available (src/index.js:560-562).

Build docs developers (and LLMs) love