Skip to content

SDKs and cURL

Your own application integrates like any client: set the SDK’s base URL to the proxy path of its provider and add your Milgram API key as a default header. Keep your provider key where it is; it is forwarded.

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

Both the Chat Completions and the Responses API work through the same base URL.

import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.milgram.dev/v1/proxy/anthropic",
api_key=os.environ["ANTHROPIC_API_KEY"],
default_headers={"x-milgram-api-key": os.environ["MILGRAM_API_KEY"]},
)
reply = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=256,
messages=[{"role": "user", "content": "hi"}],
)

The proxy also accepts your Milgram key as Authorization: Bearer mlg_… when the provider’s key travels in a header of its own, as Anthropic’s x-api-key does:

Terminal window
curl https://api.milgram.dev/v1/proxy/anthropic/v1/messages \
-H "Authorization: Bearer mlg_YOUR_KEY" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":256,"messages":[{"role":"user","content":"hi"}]}'

The proxy follows a conversation by itself: a client that resends its history on every turn continues the same session. To group requests your own way (one per user task, say), send a session name in the X-Milgram-Session header, at most 512 bytes.