Skip to main content
Majordomo controls all gateway behavior through HTTP headers. This page covers every X-Majordomo-* header you can send — required authentication, optional provider selection, and the open-ended metadata headers you use to tag requests for cost attribution and usage analysis.

Request headers

HeaderRequiredDescription
X-Majordomo-KeyYesYour Majordomo API key (mdm_sk_...). Identifies your account and associates each request with your usage log.
X-Majordomo-ProviderNoExplicit provider override: openai, anthropic, or gemini. If omitted, the gateway infers the provider from the request path.

Provider inference

When you omit X-Majordomo-Provider, the gateway infers the provider from the request path:
Path prefixInferred provider
/v1/chat/completionsOpenAI
/v1/messagesAnthropic
/v1beta/modelsGemini
Set X-Majordomo-Provider explicitly when your request path does not match the defaults above, or when you are routing the same path to multiple different providers.

Metadata headers

Any header with the X-Majordomo- prefix — other than -Key and -Provider — is treated as a metadata dimension and stored on the request log.
X-Majordomo-Feature: document-review
X-Majordomo-Team: legal
X-Majordomo-Environment: production
X-Majordomo-User-Id: user_123
Metadata lands in the raw_metadata JSONB column on llm_requests. From the dashboard, you can promote any key to the indexed_metadata column, which is GIN-indexed for fast @> queries. Naming convention: The X-Majordomo- prefix is stripped; the rest of the header name is stored as-is. X-Majordomo-Feature becomes Feature in the metadata map. No schema changes required. You can start sending a new metadata key at any time and it is stored immediately — no database migrations needed.
HeaderExample valueUse for
X-Majordomo-Featurechat, summarizerPer product feature
X-Majordomo-Teamplatform, dataPer team
X-Majordomo-Environmentproduction, stagingPer environment
X-Majordomo-User-Iduser_abc123Per end user (opaque ID, not PII)
X-Majordomo-User-Tierfree, pro, enterprisePer pricing tier
X-Majordomo-Experimentmodel-test-v2Per A/B test
See Cost Attribution for query examples using these dimensions.

Full example

from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.gomajordomo.com/v1",
    api_key="your-openai-key",
    default_headers={
        "X-Majordomo-Key": "mdm_sk_your_key_here",
        "X-Majordomo-Feature": "document-review",
        "X-Majordomo-Team": "legal",
        "X-Majordomo-Environment": "production",
    }
)

Header forwarding

X-Majordomo-* headers are not forwarded to upstream providers. The gateway consumes and strips them before proxying the request. All other headers — including custom X-* headers your provider supports, Authorization, and Content-Type — are forwarded as-is.