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.
OpenAI SDK
Section titled “OpenAI SDK”import osfrom 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"}],)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.milgram.dev/v1/proxy/openai/v1', apiKey: process.env.OPENAI_API_KEY, defaultHeaders: { 'x-milgram-api-key': process.env.MILGRAM_API_KEY },});const reply = await 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.
Anthropic SDK
Section titled “Anthropic SDK”import osfrom 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"}],)import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ baseURL: 'https://api.milgram.dev/v1/proxy/anthropic', apiKey: process.env.ANTHROPIC_API_KEY, defaultHeaders: { 'x-milgram-api-key': process.env.MILGRAM_API_KEY },});const reply = await 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:
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"}]}'Sessions
Section titled “Sessions”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.