Skip to content

OpenRouter

OpenRouter’s API is OpenAI-compatible, and so is the proxy’s openrouter path, for chat completions (other OpenRouter endpoints, such as the model list, are not proxied). Your OpenRouter key stays in Authorization and is forwarded to OpenRouter; your Milgram API key goes in its own header.

Terminal window
curl https://api.milgram.dev/v1/proxy/openrouter/api/v1/chat/completions \
-H "x-milgram-api-key: mlg_YOUR_KEY" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "content-type: application/json" \
-d '{"model":"anthropic/claude-sonnet-4.6","messages":[{"role":"user","content":"hi"}]}'

In an OpenAI-compatible SDK or client, set:

Setting Value
Base URL https://api.milgram.dev/v1/proxy/openrouter/api/v1
API key your OpenRouter key
Default header x-milgram-api-key: mlg_YOUR_KEY

For example, with the OpenAI Python SDK:

import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.milgram.dev/v1/proxy/openrouter/api/v1",
api_key=os.environ["OPENROUTER_API_KEY"],
default_headers={"x-milgram-api-key": os.environ["MILGRAM_API_KEY"]},
)
reply = client.chat.completions.create(
model="anthropic/claude-sonnet-4.6",
messages=[{"role": "user", "content": "hi"}],
)